Standard library / go/types

go/types.NewSlice()

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

Formal Syntax & Structure

go syntaxgo
func NewSlice(elem Type) *Slice

Parameters & Attributes

NameTypeDescription
elemTypeElement type.

Return Value

*Slice

Constructs a slice type descriptor.

Working Example

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