// ZeroString returns the string representation of the "zero" value of the type t. // This string can be used on the right-hand side of an assignment where the // left-hand side has that explicit type. // Exception: This does not apply to tuples. Their string representation is // informational only and cannot be used in an assignment. // When assigning to a wider type (such as 'any'), it's the caller's // responsibility to handle any necessary type conversions. // See [ZeroExpr] for a variant that returns an [ast.Expr]. func ZeroString(t types.Type, qf types.Qualifier) string { … } // ZeroExpr returns the ast.Expr representation of the "zero" value of the type t. // ZeroExpr is defined for types that are suitable for variables. // It may panic for other types such as Tuple or Union. // See [ZeroString] for a variant that returns a string. func ZeroExpr(f *ast.File, pkg *types.Package, typ types.Type) ast.Expr { … } // IsZeroExpr uses simple syntactic heuristics to report whether expr // is a obvious zero value, such as 0, "", nil, or false. // It cannot do better without type information. func IsZeroExpr(expr ast.Expr) bool { … } // TypeExpr returns syntax for the specified type. References to named types // from packages other than pkg are qualified by an appropriate package name, as // defined by the import environment of file. // It may panic for types such as Tuple or Union. func TypeExpr(f *ast.File, pkg *types.Package, typ types.Type) ast.Expr { … }