我想将一片 []int64 转换为 []uint64,什么是最有效和优雅的方式?我只知道以下方式:
func convert(userIDs ...int64) []uint64 {
uIDs := make([]uint64, len(userIDs))
for index, uID := range userIDs {
uIDs[index] = uint64(uID)
}
fmt.Printf("%T, %v\n", uIDs, uIDs)
return uIDs
}
炎炎设计
慕斯709654
相关分类