Skip to content
This repository has been archived by the owner on May 27, 2021. It is now read-only.

Commit

Permalink
cli: fix loop local variable bug in listeners iteration
Browse files Browse the repository at this point in the history
  • Loading branch information
ernado committed May 6, 2019
1 parent f799d9b commit 9a97a79
Showing 1 changed file with 4 additions and 4 deletions.
8 changes: 4 additions & 4 deletions internal/cli/run.go
Original file line number Diff line number Diff line change
Expand Up @@ -354,8 +354,8 @@ func getRoot(v *viper.Viper) *cobra.Command {
wg := new(sync.WaitGroup)
listeners := getListeners(v, l)
wg.Add(len(listeners))
for _, ln := range listeners {
go func() {
for _, lr := range listeners {
go func(ln listener) {
defer wg.Done()
lg := l.With(zap.String("addr", ln.adrr), zap.String("network", "udp"))
lg.Info("gortc/gortcd listening")
Expand All @@ -368,14 +368,14 @@ func getRoot(v *viper.Viper) *cobra.Command {
lg.Fatal("failed to listen", zap.Error(err))
}
}
}()
}(lr)
}
wg.Wait()
},
}

cmd.PersistentFlags().StringVar(&cfgFile, "config", "", "config file (default is $HOME/gortcd.yml)")
cmd.Flags().StringArrayP("listen", "l", []string{"0.0.0.0:3478"}, "listen address")
cmd.Flags().StringSliceP("listen", "l", []string{"0.0.0.0:3478"}, "listen address")
cmd.Flags().String("pprof", "", "pprof address if specified")
cmd.Flags().String("cpuprofile", "", "write cpu profile")

Expand Down

0 comments on commit 9a97a79

Please sign in to comment.