我有这个功能:
func getTableCreationCommands(v string) string {
return `
CREATE TABLE share_` + v + ` PARTITION OF share FOR VALUES IN (` + v + `);
CREATE TABLE nearby_` + v + ` PARTITION OF nearby FOR VALUES IN (` + v + `);
`
}
有点不稳定...有没有办法使用格式化字符串fmt.Sprintf?
是这样的:
func getTableCreationCommands(v string) string {
return fmt.Sprintf(`
CREATE TABLE share_%v PARTITION OF share FOR VALUES IN (%v);
CREATE TABLE nearby_%v PARTITION OF nearby FOR VALUES IN (%v);
`, v, v, v, v)
}
但不需要通过v4 次?
鸿蒙传说
繁花如伊
相关分类