func newmapInput(jirix *jiri.X, state *project.ProjectState, key project.ProjectKey, index, total int) *mapInput { return &mapInput{ ProjectState: state, key: key, jirix: jirix.Clone(tool.ContextOpts{}), index: index, total: total, } }
func GetProjectStates(jirix *jiri.X, checkDirty bool) (map[ProjectKey]*ProjectState, error) { projects, err := LocalProjects(jirix, FastScan) if err != nil { return nil, err } states := make(map[ProjectKey]*ProjectState, len(projects)) sem := make(chan error, len(projects)) for key, project := range projects { state := &ProjectState{ Project: project, } states[key] = state // jirix is not threadsafe, so we make a clone for each goroutine. go setProjectState(jirix.Clone(tool.ContextOpts{}), state, checkDirty, sem) } for _ = range projects { err := <-sem if err != nil { return nil, err } } return states, nil }