util

package
v0.36.0 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Apr 22, 2026 License: Apache-2.0 Imports: 4 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func GetMemberByJSON

func GetMemberByJSON(t *types.Type, jsonName string) *types.Member

GetMemberByJSON returns the child member of the type that has the given JSON name. It returns nil if no such member exists.

func IsDirectComparable

func IsDirectComparable(t *types.Type) bool

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

func IsNilableType(t *types.Type) bool

IsNilableType returns true if the argument type can be compared to nil.

func NativeType

func NativeType(t *types.Type) *types.Type

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

func NonPointer(t *types.Type) *types.Type

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

func ParseBool(val string) (bool, error)

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

func ParseInt(val string) (int, error)

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.

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL