Standard library / reflect
reflect.ArrayOf()
Construct an array type of the specified length and element type. An invalid length or excessive size panics. Expected stdout: '[3]int\n'.
Formal Syntax & Structure
go syntaxgo
func ArrayOf(length int, elem Type) TypeParameters & Attributes
| Name | Type | Description |
|---|---|---|
| length | int | Array length; must be nonnegative and representable. |
| elem | Type | Element type of the new composite type. |
Return Value
Type
Construct an array type of the specified length and element type.
Working Example
Example Snippetgo
package main
import ( "fmt" "reflect")
func main() { fmt.Println(reflect.ArrayOf(3, reflect.TypeOf(0))) }