如何解释这种地图语法?

I am going through the following Go Lang Map data structure. I am little confused with the syntax -

//this is fine
countryCapitalMap = make(map[string]string)
/* insert key-value pairs in the map*/
countryCapitalMap["France"] = "Paris"
capital, ok := countryCapitalMap["United States"]

/* print map using keys*/
for country := range countryCapitalMap {
    fmt.Println("Capital of", country, "is", countryCapitalMap[country])
}

Is it that the countryCapitalMap["United States"] returns two return values from the following line

capital, ok := countryCapitalMap["United States"]

Or countryCapitalMap[country] returns single value from the following line

fmt.Println("Capital of", country, "is", countryCapitalMap[country])

How could I decipher this syntax? Is it based on where and which statement the expression is used with?

How could I decipher this syntax?

Read the definition of the syntax.

A primary expression of the form

a[x]

denotes the element of the map a indexed by x. The value x is called the index or map key.

There is a special form of an index expression on a map.

v, ok = a[x]
v, ok := a[x]
var v, ok = a[x]

yields an additional untyped boolean value. The value of ok is true if the key x is present in the map, and false otherwise.


The Go Programming Language Specification

Index expressions

A primary expression of the form

a[x]

denotes the element of the array, pointer to array, slice, string or map a indexed by x. The value x is called the index or map key, respectively.

For a of map type M:

  • x's type must be assignable to the key type of M

  • if the map contains an entry with key x, a[x] is the map element with key x and the type of a[x] is the element type of M

  • if the map is nil or does not contain such an entry, a[x] is the zero value for the element type of M

Otherwise a[x] is illegal.

An index expression on a map a of type map[K]V used in an assignment or initialization of the special form

v, ok = a[x]
v, ok := a[x]
var v, ok = a[x]

yields an additional untyped boolean value. The value of ok is true if the key x is present in the map, and false otherwise.