A closer look at Golang type system

A detailed look of the Go type system, with examples

Why we need a type?

Image for post
Image for post
Binary 0s and 1s
Image for post
Image for post
What happens when you attain nirvana in computer science. (image source Martix movie)
Image for post
Image for post

So what is a type?

The type system in Go

Image for post
Image for post
type system in go
Image for post
Image for post
Type system in Go.

Named types

var i int // named type
type myInt int // named type
var b bool // named type

Unnamed types

[]string // unnamed type
map[string]string // unnamed type
[10]int // unnamed type

Underlying types

Image for post
Image for post

Assignability

Image for post
Image for post
Assignability specs Golang.
8:4: cannot use ai (type aInt) as type int in assignment
9:13: cannot use i (type int) as type aInt in argument to printAiType

Type Conversion

Image for post
Image for post
Type conversion specs.

Type identity

Learning to Learn in Feynman Technique. -https://ankuranand.com

Get the Medium app

A button that says 'Download on the App Store', and if clicked it will lead you to the iOS App store
A button that says 'Get it on, Google Play', and if clicked it will lead you to the Google Play store