func CreateGreeter() error {
var mu sync.Mutex
eg, _ := errgroup.WithContext(context.Background())
var info []biz.Info
m := make(map[string]string)
userlist := []string{"User0001", "User0002", "User0003", "User0004", "User0005"}
for _, s := range userlist {
tempNum := s
go func() {}()
eg.Go(
func() error {
err := r.data.db.Table("111").Where("User=?", tempNum).Find(&info).Error
if err != nil {
fmt.Println("查询失败")
return err
}
news := m
for _, b := range info {
mu.Lock()
news[tempNum] = b.Function_ID
mu.Unlock()
}
return nil
},
)
}
if err := eg.Wait(); err != nil {
return err
}
return nil
}