1. Alexander Gallego
  2. nyumeetup

Overview

HTTPS SSH
Introduce the language.

Key points: 

New language. 
Borrows ides from C/C++/Java. 
Java progs are written in Java, not Go. Learn the idioms and properties
There are stablished conventions for programming in Go. gofmt. 
      namingConvention, pkg.Exported, make it easy to read.

Naming has *semantic* effect. Upper Case vs lower case

introduce (only interesting things):
 if, else, for, go, lamdas, multiple return types, defer (hints this usage - not the same - boost::shared_ptr), channels. 
 func (equivalent of a C function pointer) (more on that later), range operator 
 
 close(channel) delete(map, entry)

Memory allocation (lang is garbage collected - automatic tansfer from stack to heap)

type A struct {}
 - new(A) vs. &A{}
 - make() for maps, channels, arrays/slices

idiomatic m := make(map[string]string)

Arrays  are values. 
Arrays have a size which is part of its type (new concept)
func Fool( a *[3]int) // pass by pointer not value. // Prefer this
func Fool( a [3]int)  //You'll modify the copy
func Fool(a []int) // int slice.
// Do they want to see slice tricks ? hmm maybe.

// Defining methods on UNKNOWN types
// Defining methods on primitives?
type Foo string
func (f *Foo) Bar() {
     println(f)
}

------------
Go over the C progs.
Introduce Lambdas 
-----------

Explain concurrency.. go func()'s

High level keypoints




-- Advanced Misc: -- Memory management 

`happens before ` == Dist. Comp. Notion.


defining concurrency

Example:

a, b int

e1: a=1, 
e2; b=2. 


To specify the requirements of reads and writes, we define happens before, a partial order on the execution of memory operations in a Go program. If event e1 happens before event e2, then we say that e2 happens after e1. Also, if e1 does not happen before e2 and does not happen after e2, then we say that e1 and e2 happen concurrently


-- Gotya's 

The exit of a goroutine is not guaranteed to happen before any event in the program. For example, in this program:

var a string

func hello() {
     go func() { a = "hello" }()
     print(a)
}


=====================
Resouces 
=====================
 play.golang.org
 tour.golang.org
 http://go-lang.cat-v.org/pure-go-libs
 
Most important: http://golang.org/ref/spec