github.com/tinygo-org/tinygo@v0.31.3-0.20240404173401-90b0bf646c27/testdata/alias.go (about) 1 package main 2 3 type x struct{} 4 5 func (x x) name() string { 6 return "x" 7 } 8 9 type y = x 10 11 type a struct { 12 n int 13 } 14 15 func (a a) fruit() string { 16 return "apple" 17 } 18 19 type b = a 20 21 type fruit interface { 22 fruit() string 23 } 24 25 type f = fruit 26 27 func main() { 28 // test a basic alias 29 println(y{}.name()) 30 31 // test using a type alias value as an interface 32 var v f = b{} 33 println(v.fruit()) 34 35 // test comparing an alias interface with the referred-to type 36 println(a{} == b{}) 37 println(a{2} == b{3}) 38 }