Welcome To Golang By Example

Constant Map in Go (Golang)

Table of Contents

Overview

Go only supports four types of constant

Go doesn’t support const map. So below program would raise a compilation error

Example

package main

func main() {
	const e = map[string]int{
		"a": 1,
	}
}

Output

const initializer map[string]int literal is not a constant