Standard library / go/types

go/types.NewArray()

Constructs a array type descriptor. This does not allocate a runtime value. Expected stdout: '[3]int\n'.

Formal Syntax & Structure

go syntaxgo
func NewArray(elem Type, len int64) *Array

Parameters & Attributes

NameTypeDescription
elemTypeElement type.
lenint64Array length.

Return Value

*Array

Constructs a array type descriptor.

Working Example

Example Snippetgo
package main
import (  "fmt"  "go/types")
func main() { fmt.Println(types.NewArray(types.Typ[types.Int], 3)) }
Go Reference