Skip to content

fengyoulin/inspect

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

4 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

inspect

The golang function inspect.TypeOf works just like Class.forName in Java. It's useful when needing the Type of a unexported type.

Example:

package main

import (
	"fmt"
	"github.com/fengyoulin/inspect"
)

func main() {
	typ := inspect.TypeOf("runtime.g")
	if typ != nil {
		for i := 0; i < typ.NumField(); i++ {
			f := typ.Field(i)
			fmt.Println(f.Name, f.Type.Name())
		}
	}
}

About

Find a type by name in Golang.

Resources

License

Stars

Watchers

Forks

Packages

No packages published

Languages