Standard library / go/types
go/types.Struct.String()
Returns a diagnostic string representation of the type. Expected stdout: 'struct{X int "json:x"}\n'.
Formal Syntax & Structure
go syntaxgo
func (t *Struct) String() stringReturn Value
string
Returns a diagnostic string representation of the type.
Working Example
Example Snippetgo
package main
import ( "fmt" "go/types")
func main() { t := types.NewStruct([]*types.Var{types.NewField(0, nil, "X", types.Typ[types.Int], false)}, []string{"json:x"}) fmt.Println(t.String())}