Why don’t you make a struct receiver containing this map (do not export the map) and a lookup or getter (read-only) method on it? Something like this:
type MyMap struct {
myHugeMap map[string]string
}
func (m *MyMap) get(i string) (string, error) {
e, ok := m[i]
if !ok {
return "", fmt.Errorf("element %s not found", i)
}
return e, nil
}
Of course, this should be in a separate package and you should pass around pointer to this struct.