In Python, I can declare a variable as d ='/some/dir/%s'
and later replace %s
with any value as
>>> d = '/some/dir/%s'
>>> d % "hello"
'/some/dir/hello'
Is it possible to do the same in Go? If so, how?
Yes, fmt.Sprintf
does that:
d := "/some/dir/%s"
fmt.Sprintf(d, "hello") // Returns "/some/dir/hello"