Skip to content

Instantly share code, notes, and snippets.

@daniellowtw
Last active October 30, 2015 12:58
Show Gist options
  • Save daniellowtw/fa819a93c4eb288fb3cd to your computer and use it in GitHub Desktop.
Save daniellowtw/fa819a93c4eb288fb3cd to your computer and use it in GitHub Desktop.
Golang good and bad parts
// Cannot use short assignments when dealing with structs
package main
type foo struct {
stuff int
}
func main() {
foo.stuff, a := 1,2
println(a)
}
// Go is not an OOP language!
// Making both static functions and methods
package main
type foo struct {
stuff int
}
func (f foo) Bar () {
println(f.stuff)
}
func Bar(){
var f foo // <== this allocates memory for foo and "label" it as that?
f.Bar() // which allows us to call this
}
func main() {
myFoo := foo{42}
myFoo.Bar() // 42
Bar() // 0
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment