jeudi 28 janvier 2016

reflect: Is it possible to get the underlying typed type information?

I'm porting a program from go/ast to reflect. In order to pass the tests I need to get not only the top type information but also the underlying type if the underlying type is not built-in.

In the example below, is it possible for a program to know that the underlying type of main.T is main.TT?

package main

import "fmt"
import "reflect"

func main() {
    type TT int
    type T TT

    x := T(0)
    fmt.Println(reflect.TypeOf(x))
}

Output:

 main.T





Aucun commentaire:

Enregistrer un commentaire