'Return empty array from map instead of array with empty string

I have a map of ids that map to an array of strings as such accountIDs := make(map[int64][]string, 0) and in my response this looks like:

"AccountIDs": {
    "1": [
        "19565",
        "21423"
    ],
    "7": [
        ""
    ]
}

How can I return an empty array instead of an array of empty string?

go


Solution 1:[1]

Set the value to []string{}.

myMap[7] = []string{}

See Playground

Sources

This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.

Source: Stack Overflow

Solution Source
Solution 1 Everton