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) *SliceParameters & Attributes
| Name | Type | Description |
|---|---|---|
| elem | Type | Element 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])) }