A small tool for easy string interpolation in golang.
import (
"fmt"
"github.com/henvo/go-interpolate"
)
func main() {
m := map[string]interface{}{
"name": "Bob",
"message": "You've got mail!"
}
fmt.Println(interpolate.FromMap("Hello %{name}! %{message}", m))
}
Will print:
Hello Bob! You've got mail!
import (
"fmt"
"net/url"
"github.com/henvo/go-interpolate"
)
func main() {
m := make(url.Values)
m.Add("name", "Bob")
m.Add("message", "You've got mail!")
fmt.Println(interpolate.FromURLValues("Hello %{name}! %{message}", m))
}
Will print:
Hello Bob! You've got mail!