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)
- func ParseSignedInt(val string, bitSize int) (int64, error)
- func ParseUnsignedInt(val string, bitSize int) (uint64, 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".
func ParseSignedInt ¶ added in v0.37.0
ParseSignedInt strictly parses a signed integer from a string input and validates that the result fits within the specified bit size. The bitSize parameter should be 8, 16, 32, or 64, corresponding to the target Go type. Values outside the representable range for the target type are rejected at parse time with a descriptive error.
func ParseUnsignedInt ¶ added in v0.37.0
ParseUnsignedInt strictly parses an unsigned integer from a string input and validates that the result fits within the specified bit size. The bitSize parameter should be 8, 16, 32, or 64, corresponding to the target Go type.
Types ¶
This section is empty.