func main() { flag.Parse() if *gofile != "" { *source = *gofile *destination = path.Join("mock", *gofile) } if *source == "" { log.Fatal("-source is required") } if *destination == "" { log.Fatal("-destination is required") } cwd, err := os.Getwd() if err != nil { log.Fatal(err) } importPath, err := buildutils.ImportPath(cwd) if err != nil { log.Fatal(err) } interfaces, err := ListInterfacesFromFile(*source) if err != nil { log.Fatal(err) } arguments := []string{ "-destination=" + *destination, "-package=" + *packageName, importPath, strings.Join(interfaces, ","), } cmd := exec.Command(*mockgen, arguments...) cmd.Stdout = os.Stdout cmd.Stderr = os.Stderr err = cmd.Run() if err != nil { log.Fatal(err) } }
func walkProtoProjectsFromCurrent(walkFn walkProjectFunc) error { root, err := os.Getwd() if err != nil { return err } importPath, err := buildutils.ImportPath(root) if err != nil { return err } state := make(map[string]int) if *dependOnBootstrapProject && importPath != *bootstrapProject { bootstrapRoot, err := buildutils.SrcDir(*bootstrapProject) if err != nil { return err } err = walkProtoProjectsCustom(bootstrapRoot, *bootstrapProject, state, walkFn) if err != nil { return err } } return walkProtoProjectsCustom(root, importPath, state, walkFn) }