Standard library / reflect

reflect.SliceOf()

Construct a slice type from its element type. It does not allocate slice storage. Expected stdout: '[]string\n'.

Formal Syntax & Structure

go syntaxgo
func SliceOf(t Type) Type

Parameters & Attributes

NameTypeDescription
tTypeElement type of the new composite type.

Return Value

Type

Construct a slice type from its element type.

Working Example

Example Snippetgo
package main
import (  "fmt"  "reflect")
func main() { fmt.Println(reflect.SliceOf(reflect.TypeOf(""))) }
Go Reference