Skip to content

Change from %s formatting to $<name|index>

Latest

Choose a tag to compare

@NearlyUnique NearlyUnique released this 27 Aug 11:44

A go vet rule "non-constant format string in call to URL()" makes using %s style format difficult without having different methods names depending on how the path might be specified.

previous code

resp := httptestclient.New(t).
    Post("/any/%s", "database-key").
    DoSimple(s)

New style

resp := httptestclient.New(t).
    Post("/any/$0", "database-key").
    DoSimple(s)

or

resp := httptestclient.New(t).
    Get("/any/$key", map[string]any{ "key": "database-key" }).
    DoSimple(s)