package main import "fmt" func Watch(ch <-chan *CompileReport, doneCh chan<- struct{}) { defer close(doneCh) states := map[*CompileConfig]CompileState{} for _, cfg := range CompileConfigs { states[cfg] = StateWaiting } cleared := false for report := range ch { states[report.Config] = report.State if !*Silent { PrintStates(states, cleared) } cleared = true } doneCh <- struct{}{} } func PrintStates(states map[*CompileConfig]CompileState, clear bool) { if clear { for i := 0; i < len(CompileConfigs); i++ { goUp() clearEOL() } } for _, cfg := range CompileConfigs { state, ok := states[cfg] if !ok { fmt.Println() continue } fmt.Printf("%-16s %s\n", fmt.Sprintf("%s/%s:", cfg.OS, cfg.Arch), state) } }