Documentation ¶
Overview ¶
Package source provides utilities for handling source-code.
Index ¶
- Variables
- func CallExprArgs(stackIndex int) ([]ast.Expr, error)
- func FormatNode(node ast.Node) (string, error)
- func FormattedCallExprArg(stackIndex int, argPos int) (string, error)
- func GoVersionLessThan(major, minor int64) bool
- func UpdateExpectedValue(stackIndex int, x, y interface{}) error
- func UpdateVariable(filename string, fileset *token.FileSet, astFile *ast.File, ident *ast.Ident, ...) error
Constants ¶
This section is empty.
Variables ¶
var ErrNotFound = fmt.Errorf("failed to find variable for update of golden value")
ErrNotFound indicates that UpdateExpectedValue failed to find the variable to update, likely because it is not a package level variable.
var Update bool
Update is set by the -update flag. It indicates the user running the tests would like to update any golden values.
Functions ¶
func CallExprArgs ¶
CallExprArgs returns the ast.Expr slice for the args of an ast.CallExpr at the index in the call stack.
func FormatNode ¶
FormatNode using go/format.Node and return the result as a string
func FormattedCallExprArg ¶
FormattedCallExprArg returns the argument from an ast.CallExpr at the index in the call stack. The argument is formatted using FormatNode.
func GoVersionLessThan ¶
GoVersionLessThan returns true if runtime.Version() is semantically less than version major.minor. Returns false if a release version can not be parsed from runtime.Version().
func UpdateExpectedValue ¶ added in v3.3.0
UpdateExpectedValue looks for a package-level variable with a name that starts with expected in the arguments to the caller. If the variable is found, the value of the variable will be updated to value of the other argument to the caller.
Types ¶
This section is empty.