Documentation
¶
Overview ¶
Package derive provides support for deriving go code from existing code. Functions are provided for obtaining the text representations of existing go types and function signatures that can be used when generating annotations.
Index ¶
- Constants
- func ArgsForParams(signature *types.Signature, ignoreAtPosition ...int) (format string, arguments []string)
- func ArgsForResults(signature *types.Signature) (format string, arguments []string)
- func FormatForVar(v *types.Var) (string, string)
- func HasContext(signature *types.Signature) (string, bool)
- func HasCustomContext(signature *types.Signature, customContext string) (string, bool)
- func ParamAt(signature *types.Signature, pos int) (varName, typeName string, ok bool)
Constants ¶
const ContextType = "context.Context"
ContextType is the standard go context type.
Variables ¶
This section is empty.
Functions ¶
func ArgsForParams ¶
func ArgsForParams(signature *types.Signature, ignoreAtPosition ...int) (format string, arguments []string)
ArgsForParams returns the format and arguments to use to log the function's arguments. The option ignoreAtPosition arguments specify that those positions should be ignored altogether. This is useful for handling context.Context like arguments which need often need to be handled separately.
func ArgsForResults ¶
ArgsForResults returns the format and arguments to use to log the function's results.
func FormatForVar ¶
FormatForVar determines an appropriate format spec and argument for a single function argument or result. The format spec is intended to be passed to a fmt style logging function. It takes care to ensure that the log output is bounded as follows:
- strings and types that implement stringer are printed as %.10s
- slices and maps have only their length printed
- errors are printed as %v with no other restrictions
- runes are printed as %c, bytes as %02x and pointers are as %02x
- for all other types, only the name of the variable is printed
func HasContext ¶
HasContext returns true and the name of the first parameter to the function if that first parameter is context.Context.
func HasCustomContext ¶
HasCustomContext returns true and the name of the first parameter to the function if that first parameter is the specified customContext.
Types ¶
This section is empty.