There are two things you can get here: one is the type of expression that will ultimately be resolved at compile time, and the other is the code that defines this type.
Delving into the documents, I do not believe that the first is available. However, you can get a later version using End() and Pos() on Node .
Quick example program:
package main import ( "fmt" "go/ast" "go/parser" "go/token" ) func main() { src := ` package foo type Thing struct { Field1 string Field2 []int Field3 map[byte]float64 }` fset := token.NewFileSet() f, err := parser.ParseFile(fset, "", src, 0) if err != nil { panic(err) }
Fingerprints:
string []int map[byte]float64
I'm through this together on the golang playground if you want to mess with her.
Kevin montrose
source share