basics

Lexer puts semicolon if complete statement i.e must put { on same line as if and else on same line as }

Must explicitly change types for everything

package main

import(
  "fmt"
  "strings"
)

func main() {
  fmt.Println("Hello from Go!")
  fmt.Println(strings.ToUpper("Hello really loud"))
}

Types

  • bool, string

  • uint8, int8, 16, 32, byte

  • float32, float64, complex32

  • uint, int(change on os)

  • functions, interfaces, channels

  • ptrs

  • arrays, slices, maps, structs

Explicit or implicit typing

Same logical operators as C/C++)

Declare

Unintialized vars are given a default value(0 for int, "" for string)

Explicit =

Implicit :=

Future assignment use =

Casting

Ptrs

Basically C ptrs

Panic

Cause program stop and can pass in err to display

Last updated