I try to generate a sql query using Sprintf()
where I have to use the same variable two times
myStr := "test"
str := Sprintf("SELECT ... WHERE a = '%#[1]s' or b = '%#[1]s'", myStr)
fmt.Println(str)
This snippets outputs the expected string
SELECT ... WHERE a = 'test' or b = 'test'
but go vet
says:
unrecognized printf flag for verb 's': '#' (vet)
And I am puzzled why. Switching the printf verb to v
satisfies go vet
but adds "
around my string. And I honestly doesn't see a mistake in using %#[1]s
.
Any thoughts?