在Go模板中连接预定义的字符串和变量

I am trying to build a link in my Go template. I want my objects ID to be concatenated with a word to form a dynamic url.

When I print {{.ID}} on the page, I can see the correct ID printed, I am attempting to build the URL using Printf like so.

{{- $id := printf "/%s/%s" "wallet/" .ID -}}
        <a href={{$id}}><h1>Wallet ID {{.ID}}</h1></a>

In my browser it comes out as

http://localhost:8000/wallet//%25!s%28int=1006608996216725456%29

Rather than what it should look like below. ID is of type int.

http://localhost:8000/wallet/1006608996216725456

The (escaped) %!s... indicates that the argument passed to printf is not a string. It even tells you the data type.

For example, if I run the following:

fmt.Printf("%s", int64(1006608996216725456))

I get:

%!s(int64=1006608996216725456)

You should either use %d in your printf or pass a string ID.