Standard library / go/types

go/types.WriteType()

Writes a type representation to a bytes.Buffer. Expected stdout: '[]int\n'.

Formal Syntax & Structure

go syntaxgo
func WriteType(buf *bytes.Buffer, typ Type, qf Qualifier)

Parameters & Attributes

NameTypeDescription
buf*bytes.BufferInput to the operation as described above.
typTypeType associated with the object or value.
qfQualifierOptional package-name qualifier for formatted type names.

Working Example

Example Snippetgo
package main
import (  "bytes"  "fmt"  "go/types")
func main() {  var b bytes.Buffer  types.WriteType(&b, types.NewSlice(types.Typ[types.Int]), nil)  fmt.Println(b.String())}
Go Reference