Open ixvick opened 6 years ago
func openPin(p Pin, write bool) (Pin, error) {
flags := os.O_RDONLY
if write {
flags = os.O_RDWR
}
f, err := os.OpenFile(fmt.Sprintf("/sys/class/gpio/gpio%d/value", p.Number), flags, 0600)
if err != nil {
return p, err
}
p.f = f
return p, nil
}
in func openPin(p Pin, write bool) Pin { }
It would be better not to call fmt.Printf() and os.Exit(1) inside openPin() instead please return p, err