Skip to content

proposal: net/url: add (Values).AddAll(key string, values []string) #33498

@tomocy

Description

@tomocy

The current (Values).Add, you know, enables us to add one value to one key, but is less convenient sometimes, especially when you want to add multiple values to one key (etc: coping one Values to another Values).

func copyValues(dest, src url.Value) {
    for k, vs := range src {
        for _, v := range vs {
            dest.Add(k, v)
        }
    }
}

If (Values).AddAll is available, you can write like the blow.

func copyValues(dest, src url.Value) {
    for k, vs := range src {
        dest.AddAll(k, vs)
    }
}

It may make code clearer and improve it. (The code seems to be O(N).)

Is it good idea to (Values).AddAll to add multiple values to one key at the same time?

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions