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
| Name | Type | Description |
|---|---|---|
| buf | *bytes.Buffer | Input to the operation as described above. |
| typ | Type | Type associated with the object or value. |
| qf | Qualifier | Optional 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())}