package main import ( "context" "fmt" "strings" "github.com/Leufolium/test/es" "github.com/mozillazg/go-pinyin" ) func main() { fmt.Println("Start importing...") client, err := es.NewElasticSearch() if err != nil { fmt.Printf("es client init fail : %v", err) return } ctx := context.Background() list, err := client.GetStreamerAcctList(ctx) if err != nil { fmt.Printf("GetStreamerAcctList err :%v", err) } fmt.Printf("总共%v个", len(list)) for _, acct := range list { acct.PinYin = strings.Join(pinyin.LazyConvert(acct.Name, nil), "") err := client.UpdateStreamerAcct(ctx, acct) if err != nil { fmt.Printf("UpdateStreamerAcct err :%v", err) } } fmt.Println("End importing...") }