github.com/fengyoulin/inspect@v0.2.1/README.md (about)

     1  # inspect #
     2  
     3  The golang function `inspect.TypeOf` works just like `Class.forName` in Java. It's useful when needing the Type of a unexported type.
     4  
     5  Example:
     6  ```go
     7  package main
     8  
     9  import (
    10  	"fmt"
    11  	"github.com/fengyoulin/inspect"
    12  )
    13  
    14  func main() {
    15  	typ := inspect.TypeOf("runtime.g")
    16  	if typ != nil {
    17  		for i := 0; i < typ.NumField(); i++ {
    18  			f := typ.Field(i)
    19  			fmt.Println(f.Name, f.Type.Name())
    20  		}
    21  	}
    22  }
    23  ```