lint fixes

This commit is contained in:
Sebastian Zagrodzki
2017-05-06 02:54:22 +02:00
parent d68d0c1a41
commit e117225966
3 changed files with 15 additions and 15 deletions

View File

@@ -29,7 +29,7 @@ var debug *log.Logger
const debugEnvVarName = "GOUSB_DEBUG" const debugEnvVarName = "GOUSB_DEBUG"
func init() { func init() {
var out io.Writer = ioutil.Discard out := io.Writer(ioutil.Discard)
if os.Getenv(debugEnvVarName) != "" { if os.Getenv(debugEnvVarName) != "" {
out = os.Stderr out = os.Stderr
} }

View File

@@ -88,7 +88,7 @@ func (f *fakeStreamTransfer) free() error {
func (f *fakeStreamTransfer) cancel() error { return nil } func (f *fakeStreamTransfer) cancel() error { return nil }
func (f *fakeStreamTransfer) data() []byte { return fakeTransferBuf } func (f *fakeStreamTransfer) data() []byte { return fakeTransferBuf }
var sentinelError = errors.New("sentinel error") var errSentinel = errors.New("sentinel error")
type readRes struct { type readRes struct {
n int n int
@@ -150,7 +150,7 @@ func TestTransferReadStream(t *testing.T) {
transfers: [][]fakeStreamResult{ transfers: [][]fakeStreamResult{
{{n: 500}}, {{n: 500}},
{{n: 500}}, {{n: 500}},
{{n: 123, waitErr: sentinelError}}, {{n: 123, waitErr: errSentinel}},
{{n: 500}}, {{n: 500}},
}, },
want: []readRes{ want: []readRes{
@@ -158,18 +158,18 @@ func TestTransferReadStream(t *testing.T) {
{n: 100}, {n: 100},
{n: 400}, {n: 400},
{n: 100}, {n: 100},
{n: 123, err: sentinelError}, {n: 123, err: errSentinel},
{err: io.ErrClosedPipe}, {err: io.ErrClosedPipe},
}, },
}, },
{ {
desc: "2 transfers, second submit fails initialization but error overshadowed by wait error", desc: "2 transfers, second submit fails initialization but error overshadowed by wait error",
transfers: [][]fakeStreamResult{ transfers: [][]fakeStreamResult{
{{n: 123, waitErr: sentinelError}}, {{n: 123, waitErr: errSentinel}},
{{submitErr: errors.New("fake submit error")}}, {{submitErr: errors.New("fake submit error")}},
}, },
want: []readRes{ want: []readRes{
{n: 123, err: sentinelError}, {n: 123, err: errSentinel},
{err: io.ErrClosedPipe}, {err: io.ErrClosedPipe},
}, },
}, },
@@ -177,36 +177,36 @@ func TestTransferReadStream(t *testing.T) {
desc: "2 transfers, second submit fails during initialization", desc: "2 transfers, second submit fails during initialization",
transfers: [][]fakeStreamResult{ transfers: [][]fakeStreamResult{
{{n: 400}}, {{n: 400}},
{{submitErr: sentinelError}}, {{submitErr: errSentinel}},
}, },
want: []readRes{ want: []readRes{
{n: 400}, {n: 400},
{err: sentinelError}, {err: errSentinel},
{err: io.ErrClosedPipe}, {err: io.ErrClosedPipe},
}, },
}, },
{ {
desc: "2 transfers, 3rd submit fails during second round", desc: "2 transfers, 3rd submit fails during second round",
transfers: [][]fakeStreamResult{ transfers: [][]fakeStreamResult{
{{n: 400}, {submitErr: sentinelError}}, {{n: 400}, {submitErr: errSentinel}},
{{n: 400}}, {{n: 400}},
}, },
want: []readRes{ want: []readRes{
{n: 400}, {n: 400},
{n: 400}, {n: 400},
{err: sentinelError}, {err: errSentinel},
{err: io.ErrClosedPipe}, {err: io.ErrClosedPipe},
}, },
}, },
{ {
desc: "fail quickly", desc: "fail quickly",
transfers: [][]fakeStreamResult{ transfers: [][]fakeStreamResult{
{{waitErr: sentinelError}}, {{waitErr: errSentinel}},
{{n: 500}}, {{n: 500}},
{{n: 500}}, {{n: 500}},
}, },
want: []readRes{ want: []readRes{
{err: sentinelError}, {err: errSentinel},
{err: io.ErrClosedPipe}, {err: io.ErrClosedPipe},
}, },
}, },

6
usb.go
View File

@@ -32,7 +32,7 @@ In gousb Device struct represents the USB device, and Device.Desc
contains all the information known about the device. contains all the information known about the device.
Among other information in the device descriptor is a list of configuration Among other information in the device descriptor is a list of configuration
descriptors, accessible through Device.Descriptor.Configs. descriptors, accessible through Device.Desc.Configs.
USB standard allows one physical USB device to switch between different USB standard allows one physical USB device to switch between different
sets of behaviors, or working modes, by selecting one of the offered configs sets of behaviors, or working modes, by selecting one of the offered configs
@@ -45,7 +45,7 @@ a unique identification number.
In gousb a device config needs to be selected through Device.Config(num). In gousb a device config needs to be selected through Device.Config(num).
It returns a Config struct that represents the device in this particular configuration. It returns a Config struct that represents the device in this particular configuration.
The configuration descriptor is accessible through Config.Info. The configuration descriptor is accessible through Config.Desc.
A config descriptor determines the list of available USB interfaces on the device. A config descriptor determines the list of available USB interfaces on the device.
Each interface is a virtual device within the physical USB device and it's active Each interface is a virtual device within the physical USB device and it's active
@@ -70,7 +70,7 @@ except the data transfers are unidirectional.
Endpoints are represented by the Endpoint struct, and all defined endpoints Endpoints are represented by the Endpoint struct, and all defined endpoints
can be obtained through the Endpoints field of the Interface.Setting. can be obtained through the Endpoints field of the Interface.Setting.
Each endpoint descriptor (EndpointInfo) defined in the interface's endpoint Each endpoint descriptor (EndpointDesc) defined in the interface's endpoint
map includes information about the type of the endpoint: map includes information about the type of the endpoint:
- endpoint number - endpoint number