gen_go

package
v1.4.0 Latest Latest
Warning

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

Go to latest
Published: Jul 6, 2024 License: EPL-1.0 Imports: 8 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func AsTarget

func AsTarget(s string) string

func SortValues

func SortValues(values []reflect.Value, stringSubstitutionFn func(string) string)

SortValues is a sort function that handles both native types and any type that can be converted to error or Stringer. Other inputs are sorted according to their Value.String() value to ensure display stability.

func UnsafeReflectValue

func UnsafeReflectValue(v reflect.Value) reflect.Value

Types

type GenGo

type GenGo struct {
	Statics        *[]string
	Runtime        *[]string
	Generated      map[interface{}]interface{} // key{reflect.Value} => map{string} that is the generated name of the var; else key{name} => map{obj}
	TypeToStringFn func(string) string         // Convert stringize reflect.Type to how generate code will refer to it
	KeySortFn      func(keys []reflect.Value)
	FieldSortFn    func(members []string)
	WhereFn        func() string
	StructHookFn   func(target string, t reflect.Type, obj interface{}) (res string, deferredFunc func(target string, obj interface{}))
	ValueHookFn    func(target string, t reflect.Type, v reflect.Value) string // return non-empty string to short-circuit value expansion
	PointerHookFn  func(target string, ptr, v reflect.Value) string            // return non-empty string to short-circuit value expansion
	PtrToValueFn   func(ptr, v reflect.Value) string                           // typically calls (*GenGo)Var() to generate the variable and returns that result
}

func (*GenGo) Var

func (g *GenGo) Var(name string, atRuntime bool, obj interface{})

Generate Go code to initialize a variable (either statically or at run time) to the value specified by obj.

Jump to

Keyboard shortcuts

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