func main() { bat, err := power.Get() if err != nil { log.Fatalf("failed to get battery info: %v\n", err) } for i, b := range bat { log.Printf("[Battery %d]: %+v\n", i, b) } }
func getIcons() []Icon { bat, err := power.Get() if err != nil { log.Fatalf("failed to get battery info: %v\n", err) } result := make([]Icon, len(bat)) for i, b := range bat { icon := Icon{ Battery: b, } icon.create() result[i] = icon } return result }