Upgrade to Pro — share decks privately, control downloads, hide ads and more …

Go Types

Go Types

Introduction to type systems and Go at Startup Edmonton Hack Day (mostly live coding, but here are a few slides).

Nathan Youngman

May 09, 2015
Tweet

More Decks by Nathan Youngman

Other Decks in Programming

Transcript

  1. Today ✴ Variables ✴ Declare, Initialize, Assign ✴ Strong and

    Static Typing ✴ Type Inference ✴ Scope ✴ Numeric Types
  2. play.golang.org package main
 
 import "fmt"
 
 func main() {


    var name string
 name = "Kim"
 fmt.Println("Hello", name)
 }
  3. play.golang.org package main
 
 import "fmt"
 
 func main() {


    var a int
 a, b := 1, 2
 fmt.Println(a, b)
 }

  4. play.golang.org package main
 
 import "fmt"
 
 func main() {


    a, op, b := 1, "+", 2
 
 var result int
 if op == "+" {
 result = a + b
 }
 fmt.Println(result)
 }
  5. Numeric types Signed Minimum Maximum int8 -128 127 int16 -32768

    32767 int32 -2147483648 2147483647 int64 -9223372036854775808 9223372036854775807 Unsigned Minimum Maximum uint8 0 255 uint16 0 65535 uint32 0 4294967295 uint64 0 18446744073709551615