diff --git a/cmd/server.go b/cmd/server.go index d6d2e40..4b74218 100644 --- a/cmd/server.go +++ b/cmd/server.go @@ -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) } diff --git a/pkg/flag/build_flags.go b/pkg/flag/build_flags.go index 7b5986e..bbe17ff 100644 --- a/pkg/flag/build_flags.go +++ b/pkg/flag/build_flags.go @@ -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]) } }