Standard library / go/types

go/types.TypeString()

Formats a type using an optional package qualifier. Expected stdout: '[]int\n'.

Formal Syntax & Structure

go syntaxgo
func TypeString(typ Type, qf Qualifier) string

Parameters & Attributes

NameTypeDescription
typTypeType associated with the object or value.
qfQualifierOptional package-name qualifier for formatted type names.

Return Value

string

Formats a type using an optional package qualifier.

Working Example

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