What is the difference between var exp map[string]string and var exp = map[string]string

what is the difference between
var exp map[string]string
and
var exp = map[string]string

The second expression you posted is invalid first of all. It should be:

var exp = map[string]string{}

The first expression declares an exp variable of type map[string]string. This is only the type however, and the value it holds is currently nil because the map is not initialised.
The second expression also declares an exp variable of type map[string]string, but initialises the map. In this case,

var exp = map[string]string{}

produces the same result as

var exp = make(map[string]string)
3 Likes

is it also a reference type?

It is indeed

This topic was automatically closed 90 days after the last reply. New replies are no longer allowed.