Equivalent of Python string.format in Go?

In Python, you can do this:

"File {file} had error {error}".format(file=myfile, error=err)

or this:

"File %(file)s had error %(error)s" % {"file": myfile, "error": err}

In Go, the simplest option is:

fmt.Sprintf("File %s had error %s", myfile, err)

which doesn’t let you swap the order of the parameters in the format string, which you need to do for I18N. Go does have the template package, which would require something like:

package main

import (

func main() {
    type Params struct {
        File string
        Error string

    var msg bytes.Buffer

    params := &Params{
        File: "abc",
        Error: "def",

    tmpl, _ := template.New("errmsg").Parse("File {{.File}} has error {{.Error}}")
    tmpl.Execute(&msg, params)

which seems like a long way to go for an error message. Is there a more reasonable option that allows me to give string parameters independent of order?