Documentation
¶
Index ¶
Constants ¶
This section is empty.
Variables ¶
View Source
var ( NewProjectCmd = &cobra.Command{ Use: "new-project [project_name]", Short: "New a microservice project based on freedom", Long: `New project from freedom project template. `, RunE: func(cmd *cobra.Command, args []string) (err error) { sysPath, err := filepath.Abs(args[0]) if err != nil { return } gopath := os.Getenv("GOPATH") if !strings.Contains(sysPath, gopath+"/src/") { return fmt.Errorf("Project path must be within '%s'", gopath+"/src/") } projectPath := strings.Replace(sysPath, build.Default.GOPATH+"/src/", "", 1) projectName := args[0] pdata := map[string]interface{}{ "PackagePath": projectPath, "PackageName": projectName, } mkdirAll(sysPath) m := project.FileContent() for filepath, content := range m { var pf *os.File pf, err = os.Create(sysPath + filepath) if err != nil { return err } tmpl, err := template.New(projectName).Parse(content) if err = tmpl.Execute(pf, pdata); err != nil { return err } } exec.Command("gofmt", "-w", sysPath).Output() return nil }, } )
Functions ¶
Types ¶
This section is empty.
Click to show internal directories.
Click to hide internal directories.