aboutsummaryrefslogtreecommitdiffhomepage
path: root/testdata/alias.go
blob: 244bea5f59cb4ae80320a65d406e59cbcd43356d (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
package main

type x struct{}

func (x x) name() string {
	return "x"
}

type y = x

type a struct {
	n int
}

func (a a) fruit() string {
	return "apple"
}

type b = a

type fruit interface {
	fruit() string
}

type f = fruit

func main() {
	// test a basic alias
	println(y{}.name())

	// test using a type alias value as an interface
	var v f = b{}
	println(v.fruit())

	// test comparing an alias interface with the referred-to type
	println(a{} == b{})
	println(a{2} == b{3})
}