diff --git a/debug.go b/debug.go index 1716713..021da64 100644 --- a/debug.go +++ b/debug.go @@ -29,7 +29,7 @@ var debug *log.Logger const debugEnvVarName = "GOUSB_DEBUG" func init() { - var out io.Writer = ioutil.Discard + out := io.Writer(ioutil.Discard) if os.Getenv(debugEnvVarName) != "" { out = os.Stderr } diff --git a/transfer_stream_test.go b/transfer_stream_test.go index 1c747aa..b14fe5d 100644 --- a/transfer_stream_test.go +++ b/transfer_stream_test.go @@ -88,7 +88,7 @@ func (f *fakeStreamTransfer) free() error { func (f *fakeStreamTransfer) cancel() error { return nil } func (f *fakeStreamTransfer) data() []byte { return fakeTransferBuf } -var sentinelError = errors.New("sentinel error") +var errSentinel = errors.New("sentinel error") type readRes struct { n int @@ -150,7 +150,7 @@ func TestTransferReadStream(t *testing.T) { transfers: [][]fakeStreamResult{ {{n: 500}}, {{n: 500}}, - {{n: 123, waitErr: sentinelError}}, + {{n: 123, waitErr: errSentinel}}, {{n: 500}}, }, want: []readRes{ @@ -158,18 +158,18 @@ func TestTransferReadStream(t *testing.T) { {n: 100}, {n: 400}, {n: 100}, - {n: 123, err: sentinelError}, + {n: 123, err: errSentinel}, {err: io.ErrClosedPipe}, }, }, { desc: "2 transfers, second submit fails initialization but error overshadowed by wait error", transfers: [][]fakeStreamResult{ - {{n: 123, waitErr: sentinelError}}, + {{n: 123, waitErr: errSentinel}}, {{submitErr: errors.New("fake submit error")}}, }, want: []readRes{ - {n: 123, err: sentinelError}, + {n: 123, err: errSentinel}, {err: io.ErrClosedPipe}, }, }, @@ -177,36 +177,36 @@ func TestTransferReadStream(t *testing.T) { desc: "2 transfers, second submit fails during initialization", transfers: [][]fakeStreamResult{ {{n: 400}}, - {{submitErr: sentinelError}}, + {{submitErr: errSentinel}}, }, want: []readRes{ {n: 400}, - {err: sentinelError}, + {err: errSentinel}, {err: io.ErrClosedPipe}, }, }, { desc: "2 transfers, 3rd submit fails during second round", transfers: [][]fakeStreamResult{ - {{n: 400}, {submitErr: sentinelError}}, + {{n: 400}, {submitErr: errSentinel}}, {{n: 400}}, }, want: []readRes{ {n: 400}, {n: 400}, - {err: sentinelError}, + {err: errSentinel}, {err: io.ErrClosedPipe}, }, }, { desc: "fail quickly", transfers: [][]fakeStreamResult{ - {{waitErr: sentinelError}}, + {{waitErr: errSentinel}}, {{n: 500}}, {{n: 500}}, }, want: []readRes{ - {err: sentinelError}, + {err: errSentinel}, {err: io.ErrClosedPipe}, }, }, diff --git a/usb.go b/usb.go index e4e9486..0474488 100644 --- a/usb.go +++ b/usb.go @@ -32,7 +32,7 @@ In gousb Device struct represents the USB device, and Device.Desc contains all the information known about the device. 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 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). 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. 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 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: - endpoint number