Skip to content

net/url: add a "SetQuery" helper function #24552

@HaraldNordgren

Description

@HaraldNordgren

Hi, I want to create a new helper function called "SetQueryParameters" in net/url. Is this something the community wants too?

Already from my first experience with Go, I was confused about the round-about way that we set query parameters:

v := u.Query()
v.Set("a", 1)
v.Set("b", 2)
u.RawQuery = v.Encode()

So instead we could have a helper function

u.SetQueryParameters(url.Values{
	"a": {"1"},
	"b": {"2"},
})

to hopefully make life a tiny bit easier for me and other developers.

Metadata

Metadata

Assignees

No one assigned

    Labels

    FrozenDueToAgeNeedsDecisionFeedback is required from experts, contributors, and/or the community before a change can be made.

    Type

    No type

    Projects

    No projects

    Milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions