Share
Embed
Transcript
7 slides
-
Day #1 - Type System Overview Concepts regarding the Go
type system 「 Trying to make you to fall in love with Golang 」 1 / 7 Type System Overview Luca Sepe Software Craftsman, Solution Architect, Trainer https://twitter.com/lucasepe/ https://github.com/lucasepe/ https://lucasepe.it/ -
Basic Types built-in string type: string built-in boolean type: bool
built-in numeric types: int8 , uint8 ( byte ), int16 , uint16 , int32 ( rune ), uint32 , int64 , uint64 , int , uint , uintptr float32 , float64 complex64 , complex128 「Trying to make you to fall in love with Golang」 - Type System Overview 2 / 7 Type System Overview Luca Sepe Software Craftsman, Solution Architect, Trainer https://twitter.com/lucasepe/ https://github.com/lucasepe/ https://lucasepe.it/ -
Composite Types pointer, struct and function types container types: array
types - fixed-length container types slice type - dynamic-capacity container types map types - associative arrays (or dictionaries) channel types - used to synchronize data among goroutines interface types - key role in reflection and polymorphism 「Trying to make you to fall in love with Golang」 - Type System Overview 3 / 7 Type System Overview Luca Sepe Software Craftsman, Solution Architect, Trainer https://twitter.com/lucasepe/ https://github.com/lucasepe/ https://lucasepe.it/ -
Type Definitions We can define new types by using the
type keyword. the new defined type and the source type will share the same underlying type their values can be converted to each other types can be defined within function bodies 「Trying to make you to fall in love with Golang」 - Type System Overview 4 / 7 Type System Overview Luca Sepe Software Craftsman, Solution Architect, Trainer https://twitter.com/lucasepe/ https://github.com/lucasepe/ https://lucasepe.it/ -
Zero Value Concept An instance of a type is called
a value of the specific type . each type has a zero value that can be viewed as the default value Try It! 「Trying to make you to fall in love with Golang」 - Type System Overview 5 / 7 Type System Overview Luca Sepe Software Craftsman, Solution Architect, Trainer https://twitter.com/lucasepe/ https://github.com/lucasepe/ https://lucasepe.it/ -
Zero Value Concept if we don't specify a value for
this type it will be set to this zero value Boolean false Integer 0 Floating Point 0 Complex 0 + 0i String "" (empty string) Pointer nil 「Trying to make you to fall in love with Golang」 - Type System Overview 6 / 7 Type System Overview Luca Sepe Software Craftsman, Solution Architect, Trainer https://twitter.com/lucasepe/ https://github.com/lucasepe/ https://lucasepe.it/ -
Thank you Luca Sepe Solution Architect (@day) / Software Craftsman
(@night) {twitter.com, github.com, linkedin.com} / lucasepe 「Trying to make you to fall in love with Golang」 - Type System Overview 7 / 7 Type System Overview Luca Sepe Software Craftsman, Solution Architect, Trainer https://twitter.com/lucasepe/ https://github.com/lucasepe/ https://lucasepe.it/