Get client information with GET request in GO API
If you have m fields and n names then you are iterating O(m * n) times. For all fields and names, circa 60 * 60 = 3600 times. Only loop O(m) times:
for field, _ := range m {
    if !names[field] {
        delete(m, field)
    }
}

With some improvements:
package main

import (
    &quot;encoding/json&quot;
    &quot;fmt&quot;
    &quot;regexp&quot;
    &quot;strings&quot;
)

var fieldNameRegex = regexp.MustCompile(`^\w+$`)

func structToMap(client interface{}, fieldNames []string) (map[string]interface{}, error) {
    names := make(map[string]bool, len(fieldNames))
    for _, name := range fieldNames {
        name = strings.TrimSpace(name)
        if !fieldNameRegex.MatchString(name) {
            return nil, fmt.Errorf(&quot;Invalid field name: `%s`&quot;, name)
        }
        name = strings.ToLower(name)
        names[name] = true
    }

    j, err := json.Marshal(client)
    if err != nil {
        return nil, err
    }
    m := map[string]interface{}{}
    err = json.Unmarshal(j, &amp;m)
    if err != nil {
        return nil, err
    }
    for field, _ := range m {
        if !names[field] {
            delete(m, field)
        }
    }
    if len(m) != len(names) {
        return nil, fmt.Errorf(&quot;field(s) not found&quot;)
    }
    return m, nil
}

type Client struct {
    AltAddress string `json:&quot;alt_address&quot;`
    Firstname  string `json:&quot;firstname&quot;`
    Lastname   string `json:&quot;lastname&quot;`
}

func main() {
    client := Client{
        AltAddress: &quot;HalLo&quot;,
        Lastname:   &quot;smith&quot;,
    }

    m, err := structToMap(client, []string{&quot;alt_address&quot;, &quot;firstname&quot;})
    if err != nil {
        fmt.Println(&quot;error1:&quot;, err)
        return
    }
    j, err := json.Marshal(m)
    if err != nil {
        fmt.Println(&quot;error2:&quot;, err)
        return
    }
    fmt.Println(string(j))
}

Playground: https://play.golang.org/p/Qf8bdygEcVT
{&quot;alt_address&quot;:&quot;HalLo&quot;,&quot;firstname&quot;:&quot;&quot;}