Documentation
¶
Index ¶
- func GetMemberByJSON(t *types.Type, jsonName string) *types.Member
- func IsDirectComparable(t *types.Type) bool
- func IsNilableType(t *types.Type) bool
- func NativeType(t *types.Type) *types.Type
- func NonPointer(t *types.Type) *types.Type
- func ParseBool(val string) (bool, error)
- func ParseInt(val string) (int, error)
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func GetMemberByJSON ¶
GetMemberByJSON returns the child member of the type that has the given JSON name. It returns nil if no such member exists.
func IsDirectComparable ¶
IsDirectComparable returns true if the type is safe to compare using "==". It is similar to gengo.IsComparable, but it doesn't consider Pointers to be comparable (we don't want shallow compare).
func IsNilableType ¶
IsNilableType returns true if the argument type can be compared to nil.
func NativeType ¶
NativeType returns the Go native type of the argument type, with any intermediate typedefs removed. Go itself already flattens typedefs, but this handles it in the unlikely event that we ever fix that.
Examples: * Trivial:
- given `int`, returns `int`
- given `*int`, returns `*int`
- given `[]int`, returns `[]int`
* Typedefs
- given `type X int; X`, returns `int`
- given `type X int; []X`, returns `[]X`
* Typedefs and pointers:
- given `type X int; *X`, returns `*int`
- given `type X *int; *X`, returns `**int`
- given `type X []int; X`, returns `[]int`
- given `type X []int; *X`, returns `*[]int`
func NonPointer ¶
NonPointer returns the value-type of a possibly pointer type. If type is not a pointer, it returns the input type.
func ParseBool ¶ added in v0.36.0
ParseBool strictly parses a bool from a string input, ensuring that when converted back to a string, the resulting bool and the input string have the exact same representation. This prevents scenarios where an input like "TRUE" parses as true and would be re-stringed as "true".
func ParseInt ¶ added in v0.36.0
ParseInt strictly parses an int from a string input, ensuring that when converted back to a string, the resulting int and the input string have the exact same representation. This prevents scenarios where an input like "0100" parses as 100 and would be re-stringed as "100".
Types ¶
This section is empty.