Skip to content

Commit a8f008c

Browse files
committed
fix: fix the range bug
1 parent 83f105d commit a8f008c

File tree

1 file changed

+2
-1
lines changed

1 file changed

+2
-1
lines changed

gmicro/app/app.go

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -92,7 +92,8 @@ func (a *App) Run() error {
9292
wg := sync.WaitGroup{}
9393

9494
for _, srv := range servers {
95-
95+
// 修正 range 中的变量问题, 传递给goroutine的参数, 不能直接传递srv, 因为srv是一个变量, 会被修改
96+
srv := srv
9697
// 启动一个goroutine 监听是否有服务在启动过程中存在失败的情况
9798
errGroup.Go(func() error {
9899
<-ctx.Done()

0 commit comments

Comments
 (0)