Standard library / go/types
go/types.ObjectString()
Formats an object declaration using the supplied package qualifier. Expected stdout: 'var x int\n'.
Formal Syntax & Structure
go syntaxgo
func ObjectString(obj Object, qf Qualifier) stringParameters & Attributes
| Name | Type | Description |
|---|---|---|
| obj | Object | Object associated with the type or scope. |
| qf | Qualifier | Optional package-name qualifier for formatted type names. |
Return Value
string
Formats an object declaration using the supplied package qualifier.
Working Example
Example Snippetgo
package main
import ( "fmt" "go/types")
func main() { v := types.NewVar(0, nil, "x", types.Typ[types.Int]) fmt.Println(types.ObjectString(v, nil))}