Newer
Older
01_hello / type.go
yhornisse on 22 Sep 2021 435 bytes Update type.go
package main

import "fmt"

type A int64
type B int64

func main() {
	var i int64 = 1
	var a1 A = 1
	var a2 A = 1
	var b1 B = 1
	fmt.Printf("%d %d %d %d %d\n", i, int64(a1), a1, a2, b1)
	fmt.Printf("a1 == 1: %+v\n", a1 == 1)
	//fmt.Printf("a1 == i: %+v\n", a1 == i) // build error
	fmt.Printf("int64(a1) == i: %+v\n", int64(a1) == i)
	fmt.Printf("a1 == a2: %+v\n", a1 == a2)
	//fmt.Printf("a1 == b1: %+v\n", a1 == b1) // build error
}