Make golint fail on errors. (#105)

* make lint fail on errors
* fix lint errors
This commit is contained in:
Sebastian Zagrodzki
2021-11-02 12:52:11 +01:00
committed by GitHub
parent d3bdbe53c8
commit bdb184b25c
4 changed files with 11 additions and 10 deletions

View File

@@ -11,7 +11,7 @@ jobs:
- run: sudo apt-get install libusb-1.0-0-dev
- run: go install golang.org/x/tools/cmd/cover@latest
- run: go install golang.org/x/lint/golint@latest
- run: $HOME/go/bin/golint ./...
- run: $HOME/go/bin/golint -set_exit_status ./...
- run: sh ./.github/test-coverage.sh
- uses: shogo82148/actions-goveralls@v1
with:

View File

@@ -209,7 +209,7 @@ func (libusbImpl) getDevices(ctx *libusbContext) ([]*libusbDevice, error) {
for _, d := range devs {
ret = append(ret, (*libusbDevice)(d))
}
// devices must be dereferenced by the caller to prevent memoryleaks
// devices must be dereferenced by the caller to prevent memory leaks.
C.libusb_free_device_list(list, 0)
return ret, nil
}

View File

@@ -269,14 +269,15 @@ func (w *WriteStream) Close() error {
return w.CloseContext(context.Background())
}
// Close signals end of data to write. Close blocks until all transfers
// that were sent are finished. The error returned by Close is the first
// error encountered during writing the entire stream (if any).
// Close returning nil indicates all transfers completed successfully.
// After Close, the total number of bytes successfully written can be
// CloseContext signals end of data to write. CloseContext blocks until all
// transfers that were sent are finished or until the context is canceled. The
// error returned by CloseContext is the first error encountered during writing
// the entire stream (if any).
// CloseContext returning nil indicates all transfers completed successfully.
// After CloseContext, the total number of bytes successfully written can be
// retrieved using Written().
// Close may not be called concurrently with Write, Close or Written.
// CloseContext
// CloseContext may not be called concurrently with Write, WriteContext, Close,
// CloseContext or Written.
func (w *WriteStream) CloseContext(ctx context.Context) error {
if w.s.transfers == nil {
return io.ErrClosedPipe

2
usb.go
View File

@@ -246,7 +246,7 @@ func (c *Context) checkOpenDevs() error {
c.mu.Lock()
defer c.mu.Unlock()
if l := len(c.devices); l > 0 {
return fmt.Errorf("Context.Close called while %d Devices are still open, Close may be called only after all previously opened devices were successfuly closed.", l)
return fmt.Errorf("Context.Close called while %d Devices are still open, Close may be called only after all previously opened devices were successfuly closed", l)
}
return nil
}