github.com/lsg2020/gort@v0.0.0-20220515072951-7a7794baa036/README.md (about)

     1  # gort
     2  * go runtime type: get reflect.Type by name
     3  
     4  # Usage
     5  * lets you call functions in your binary with just the string of their name
     6  ``` go
     7  	rt, err := gort.NewDwarfRT("")
     8  	fmt.Printf("test call fmt.Printf\n")
     9  
    10  	rets, err = rt.CallFunc("fmt.Printf", true, []reflect.Value{
    11  		reflect.ValueOf("test call fmt.Printf:%d %s\n"),
    12  		reflect.ValueOf(1234),
    13  		reflect.ValueOf("hello"),
    14  	})
    15  ```
    16  
    17  * lets you get access to globals in your binary with just the string of their name
    18  ```go
    19  	rt, err := gort.NewDwarfRT("")
    20  	rGlobal, err := rt.FindGlobal("main.testGlobal")
    21  ```
    22  
    23  * lets you get access to all of the `reflect.Types` in your binary of their name
    24      * Caveat: the types must be possible outputs to reflect.TypeOf(val) in your binary 
    25  ```go
    26  	rt, err := gort.NewDwarfRT("")
    27  	typ, err := rt.FindType("main.testStruct")
    28  ```
    29  
    30  # Examples
    31  * `go build -gcflags=all=-l examples/hello/hello.go`
    32  * `./hello`