You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
func ShardingAlgorithm(numberOfShards int, value any) (suffix string, err error) {
var tableFormat string
if numberOfShards == 0 {
return "", errors.New("specify NumberOfShards or ShardingAlgorithm")
}
if numberOfShards < 10 {
tableFormat = "_%01d"
} else if numberOfShards < 100 {
tableFormat = "_%02d"
} else if numberOfShards < 1000 {
tableFormat = "_%03d"
} else if numberOfShards < 10000 {
tableFormat = "_%04d"
}
id := 0
switch value := value.(type) {
case int:
id = value
case int64:
id = int(value)
case string:
id, err = strconv.Atoi(value)
if err != nil {
id = int(crc32.ChecksumIEEE([]byte(value)))
}
default:
return "", errors.Errorf("default algorithm only support integer and string column," +
"if you use other type, specify you own ShardingAlgorithm")
}
return fmt.Sprintf(tableFormat, id%numberOfShards), nil
}
我的sql加上了 for update 提示这个报错
The text was updated successfully, but these errors were encountered: