Documentation ¶
Index ¶
Constants ¶
This section is empty.
Variables ¶
View Source
var Cmd = &cobra.Command{ Use: "rename", Short: "重命名项目总包名", Long: `默认包名为 sniper 可以按需修改`, Run: func(cmd *cobra.Command, args []string) { if rootPkg == "" { panic("package cannot be empty") } module := getModuleName() module = strings.ReplaceAll(module, ".", "\\.") sh := fmt.Sprintf(`grep --exclude .git -rlI '"%s/' %s | xargs sed -i '' 's#"%s/#"%s/#'`, module, goModDir, module, rootPkg) c1 := exec.Command("bash") c1.Stdin = strings.NewReader(sh) c1.Stdout = os.Stdout c1.Stderr = os.Stderr c1.Run() modPath := "go.mod" if len(goModDir) > 0 { modPath = filepath.Join(goModDir, "go.mod") } sh = fmt.Sprintf(`sed -i '' 's#module %s#module %s#' %s`, module, rootPkg, modPath) c2 := exec.Command("bash") c2.Stdin = strings.NewReader(sh) c2.Stdout = os.Stdout c2.Stderr = os.Stderr c2.Run() }, }
Cmd 项目重命名工具
Functions ¶
This section is empty.
Types ¶
This section is empty.
Click to show internal directories.
Click to hide internal directories.