June 2017
Beginner
1091 pages
22h 9m
English
In general, Go considers each type to be different. This means under normal circumstances, values of different types are not fungible in assignment, function parameters, and expression contexts. This is true for built-in and declared types. For instance, the following will cause a build error due to type mismatch:
package main
import "fmt"
type signal int
func main() {
var count int32
var actual int
var test int64 = actual + count
var sig signal
var event int = sig
fmt.Println(test)
fmt.Println(event)
}
golang.fyi/ch04/type_conv.go
The expression actual + count causes a build time error because both variables are of different types. Even though variables actual and count are of numeric types and int32 and int have the same memory ...
Read now
Unlock full access