fix: del goc flags, still remain some

This commit is contained in:
lyyyuna 2021-06-21 16:47:36 +08:00
parent 2774123526
commit b3e9d7dd78
2 changed files with 10 additions and 4 deletions

View File

@ -18,7 +18,7 @@ var serverCmd = &cobra.Command{
func init() {
// serverCmd.Flags().IntVarP(&config.GocConfig.Port, "port", "", 7777, "listen port to start a coverage host center")
// serverCmd.Flags().StringVarP(&config.GocConfig.StorePath, "storepath", "", "goc.store", "the file to save all goc server information")
serverCmd.Flags().StringVarP(&config.GocConfig.Host, "host", "", "0.0.0.0:7777", "specify the host of the goc server")
serverCmd.Flags().StringVarP(&config.GocConfig.Host, "host", "", "127.0.0.1:7777", "specify the host of the goc server")
rootCmd.AddCommand(serverCmd)
}

View File

@ -85,11 +85,17 @@ func BuildCmdArgsParse(cmd *cobra.Command, args []string) []string {
func findAndDelGocFlag(a []string, x string) []string {
new := make([]string, 0, len(a))
x = "--" + x
for _, v := range a {
if v == x {
for i := 0; i < len(a); i++ {
if a[i] == "--debug" {
// debug 是 bool就一个元素
continue
} else if a[i] == x {
// 其他 goc flag 都是两个元素
i++
continue
} else {
new = append(new, v)
// 剩下的是 go flag
new = append(new, a[i])
}
}