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) stringParameters & Attributes
| Name | Type | Description |
|---|---|---|
| typ | Type | Type associated with the object or value. |
| qf | Qualifier | Optional 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)) }