I have this function:
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 + `);
`
}
It's a little wonky... is there a way to format the string using fmt.Sprintf
?
Something like this:
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)
}
but without the need to pass v
4 times?