Categorygithub.com/nirgedeng/gort
repositorypackage
0.0.4
Repository: https://github.com/nirgedeng/gort.git
Documentation: pkg.go.dev

# Packages

No description provided by the author

# README

gort

  • go runtime type: get reflect.Type by name

Usage

  • lets you call functions in your binary with just the string of their name
	rt, err := gort.NewDwarfRT("")
	fmt.Printf("test call fmt.Printf\n")

	rets, err = rt.CallFunc("fmt.Printf", true, []reflect.Value{
		reflect.ValueOf("test call fmt.Printf:%d %s\n"),
		reflect.ValueOf(1234),
		reflect.ValueOf("hello"),
	})
  • lets you get access to globals in your binary with just the string of their name
	rt, err := gort.NewDwarfRT("")
	rGlobal, err := rt.FindGlobal("main.testGlobal")
  • lets you get access to all of the reflect.Types in your binary of their name
    • Caveat: the types must be possible outputs to reflect.TypeOf(val) in your binary
	rt, err := gort.NewDwarfRT("")
	typ, err := rt.FindType("main.testStruct")

Examples

  • go build -gcflags=all=-l examples/hello/hello.go
  • ./hello