diff --git a/api/robeaux/robeaux.go b/api/robeaux/robeaux.go index 3f3e59ba..3ec74b1d 100644 --- a/api/robeaux/robeaux.go +++ b/api/robeaux/robeaux.go @@ -1019,10 +1019,8 @@ func RestoreAsset(dir, name string) error { return err } err = os.Chtimes(_filePath(dir, name), info.ModTime(), info.ModTime()) - if err != nil { - return err - } - return nil + + return err } // RestoreAssets restores an asset under the given directory recursively diff --git a/examples/ardrone_face_tracking.go b/examples/ardrone_face_tracking.go index e911f953..1dca5efa 100644 --- a/examples/ardrone_face_tracking.go +++ b/examples/ardrone_face_tracking.go @@ -31,7 +31,7 @@ func main() { var image *cv.IplImage gobot.On(camera.Event("frame"), func(data interface{}) { image = data.(*cv.IplImage) - if detect == false { + if !detect { window.ShowImage(image) } }) diff --git a/examples/sphero_conways.go b/examples/sphero_conways.go index c067367d..6ee20c34 100644 --- a/examples/sphero_conways.go +++ b/examples/sphero_conways.go @@ -40,13 +40,13 @@ func main() { }) gobot.Every(3*time.Second, func() { - if conway.alive == true { + if conway.alive { conway.movement() } }) gobot.Every(10*time.Second, func() { - if conway.alive == true { + if conway.alive { conway.birthday() } }) @@ -107,8 +107,8 @@ func (c *conway) birthday() { fmt.Println("Happy birthday", c.cell.Name, "you are", c.age, "and had", c.contacts, "contacts.") - if c.enoughContacts() == true { - if c.alive == false { + if c.enoughContacts() { + if !c.alive { c.rebirth() } } else { @@ -119,7 +119,7 @@ func (c *conway) birthday() { } func (c *conway) movement() { - if c.alive == true { + if c.alive { c.cell.Roll(100, uint16(gobot.Rand(360))) } } diff --git a/gobot.go b/gobot.go index a08dcc80..38939e16 100644 --- a/gobot.go +++ b/gobot.go @@ -73,7 +73,7 @@ func (g *Gobot) Start() (errs []error) { } // waiting for interrupt coming on the channel - _ = <-c + <-c // Stop calls the Stop method on each robot in its collection of robots. g.Stop() diff --git a/platforms/digispark/digispark_adaptor.go b/platforms/digispark/digispark_adaptor.go index c7b37dc4..3907817e 100644 --- a/platforms/digispark/digispark_adaptor.go +++ b/platforms/digispark/digispark_adaptor.go @@ -71,7 +71,7 @@ func (d *DigisparkAdaptor) DigitalWrite(pin string, level byte) (err error) { // PwmWrite writes the 0-254 value to the specified pin func (d *DigisparkAdaptor) PwmWrite(pin string, value byte) (err error) { - if d.pwm == false { + if !d.pwm { if err = d.littleWire.pwmInit(); err != nil { return } @@ -87,7 +87,7 @@ func (d *DigisparkAdaptor) PwmWrite(pin string, value byte) (err error) { // ServoWrite writes the 0-180 degree val to the specified pin. func (d *DigisparkAdaptor) ServoWrite(pin string, angle uint8) (err error) { - if d.servo == false { + if !d.servo { if err = d.littleWire.servoInit(); err != nil { return } diff --git a/platforms/firmata/client/client.go b/platforms/firmata/client/client.go index ed0c6fc1..9227ac4c 100644 --- a/platforms/firmata/client/client.go +++ b/platforms/firmata/client/client.go @@ -469,7 +469,7 @@ func (b *Client) process() (err error) { b.FirmwareName = string(name[:]) gobot.Publish(b.Event("FirmwareQuery"), b.FirmwareName) case StringData: - str := currentBuffer[2:len(currentBuffer)] + str := currentBuffer[2:] gobot.Publish(b.Event("StringData"), string(str[:len(str)-1])) } } diff --git a/platforms/gpio/motor_driver.go b/platforms/gpio/motor_driver.go index 186864df..5861dbaa 100644 --- a/platforms/gpio/motor_driver.go +++ b/platforms/gpio/motor_driver.go @@ -175,10 +175,7 @@ func (m *MotorDriver) Direction(direction string) (err error) { } func (m *MotorDriver) isDigital() bool { - if m.CurrentMode == "digital" { - return true - } - return false + return m.CurrentMode == "digital" } func (m *MotorDriver) changeState(state byte) (err error) { diff --git a/platforms/i2c/jhd1313m1_driver.go b/platforms/i2c/jhd1313m1_driver.go index 2f0e5f09..827b63be 100644 --- a/platforms/i2c/jhd1313m1_driver.go +++ b/platforms/i2c/jhd1313m1_driver.go @@ -218,10 +218,7 @@ func (h *JHD1313M1Driver) Scroll(leftToRight bool) error { func (h *JHD1313M1Driver) Halt() []error { return nil } func (h *JHD1313M1Driver) setReg(command int, data int) error { - if err := h.connection.I2cWrite(h.rgbAddress, []byte{byte(command), byte(data)}); err != nil { - return err - } - return nil + return h.connection.I2cWrite(h.rgbAddress, []byte{byte(command), byte(data)}) } func (h *JHD1313M1Driver) command(buf []byte) error { diff --git a/platforms/i2c/mcp23017_driver.go b/platforms/i2c/mcp23017_driver.go index e45318d1..3b641c06 100644 --- a/platforms/i2c/mcp23017_driver.go +++ b/platforms/i2c/mcp23017_driver.go @@ -171,10 +171,7 @@ func (m *MCP23017Driver) ReadGPIO(pin uint8, portStr string) (val uint8, err err // val = 0 pull up disabled. func (m *MCP23017Driver) SetPullUp(pin uint8, val uint8, portStr string) error { selectedPort := m.getPort(portStr) - if err := m.write(selectedPort.GPPU, pin, val); err != nil { - return err - } - return nil + return m.write(selectedPort.GPPU, pin, val) } // SetGPIOPolarity will change a given pin's polarity based on the value: @@ -182,10 +179,7 @@ func (m *MCP23017Driver) SetPullUp(pin uint8, val uint8, portStr string) error { // val = 0 same logic state of the input pin. func (m *MCP23017Driver) SetGPIOPolarity(pin uint8, val uint8, portStr string) (err error) { selectedPort := m.getPort(portStr) - if err := m.write(selectedPort.IPOL, pin, val); err != nil { - return err - } - return nil + return m.write(selectedPort.IPOL, pin, val) } // write gets the value of the passed in register, and then overwrites diff --git a/platforms/sphero/sphero_driver.go b/platforms/sphero/sphero_driver.go index 9472a8b2..5367f673 100644 --- a/platforms/sphero/sphero_driver.go +++ b/platforms/sphero/sphero_driver.go @@ -174,7 +174,7 @@ func (s *SpheroDriver) Start() (errs []error) { go func() { for { header := s.readHeader() - if header != nil && len(header) != 0 { + if len(header) > 0 { body := s.readBody(header[4]) data := append(header, body...) checksum := data[len(data)-1] @@ -268,7 +268,7 @@ func (s *SpheroDriver) SetHeading(heading uint16) { // SetStabilization enables or disables the built-in auto stabilizing features of the Sphero func (s *SpheroDriver) SetStabilization(on bool) { b := uint8(0x01) - if on == false { + if !on { b = 0x00 } s.packetChannel <- s.craftPacket([]uint8{b}, 0x02, 0x02) diff --git a/robot.go b/robot.go index a90f5b49..c87378b3 100644 --- a/robot.go +++ b/robot.go @@ -152,18 +152,8 @@ func (r *Robot) Start() (errs []error) { // Stop stops a Robot's connections and Devices func (r *Robot) Stop() (errs []error) { log.Println("Stopping Robot", r.Name, "...") - if heers := r.Devices().Halt(); len(heers) > 0 { - for _, err := range heers { - errs = append(errs, err) - } - } - - if ceers := r.Connections().Finalize(); len(ceers) > 0 { - for _, err := range ceers { - errs = append(errs, err) - } - } - + errs = append(errs, r.Devices().Halt()...) + errs = append(errs, r.Connections().Finalize()...) return errs }