package main import ( "fmt" log "github.com/sirupsen/logrus" "os" ) func init() { // log.SetFormatter(&log.JSONFormatter{}) log.SetFormatter(&log.TextFormatter{FullTimestamp: true, DisableColors: false, ForceColors: true}) log.SetOutput(os.Stdout) desiredLogLevel := os.Getenv("LOG_LEVEL") level, err := log.ParseLevel(desiredLogLevel) if err != nil { log.Debugf("Failed to parse log level: %s", desiredLogLevel) log.SetLevel(log.WarnLevel) } else { log.SetLevel(level) } } func main() { // If you wonder why this is slow, see how long even a very basic API request // takes. swapi is very slow! starships, err := AllStarships() if err != nil { log.Errorf("Error loading Starships: %+v", err) os.Exit(1) } data := GetStarshipsPilots(starships) for starship, pilots := range data { if len(pilots) <= 0 { continue } fmt.Println(starship.Name) for _, pilot := range pilots { if pilot != nil { fmt.Println(" " + pilot.Name) } } } }