Standard library / go/types
go/types.NewMap()
Constructs a map type descriptor. This does not allocate a runtime value. Expected stdout: 'map[string]int\n'.
Formal Syntax & Structure
go syntaxgo
func NewMap(key, elem Type) *MapParameters & Attributes
| Name | Type | Description |
|---|---|---|
| key | Type | Map key type. |
| elem | Type | Element type. |
Return Value
*Map
Constructs a map type descriptor.
Working Example
Example Snippetgo
package main
import ( "fmt" "go/types")
func main() { fmt.Println(types.NewMap(types.Typ[types.String], types.Typ[types.Int])) }