golang getting started
TRANSCRIPT
![Page 1: Golang getting started](https://reader037.vdocuments.site/reader037/viewer/2022091121/58a56bf81a28ab20528b6a19/html5/thumbnails/1.jpg)
GolangGetting started
Not a talk – reference deck
![Page 2: Golang getting started](https://reader037.vdocuments.site/reader037/viewer/2022091121/58a56bf81a28ab20528b6a19/html5/thumbnails/2.jpg)
What is go?• Statically-typed language //resembles C• Concurrency• Garbage collection• Type safety – with some dynamic typing• Fast compilation • Remote package management • Great builtins
… C + some Awesome stuff
![Page 3: Golang getting started](https://reader037.vdocuments.site/reader037/viewer/2022091121/58a56bf81a28ab20528b6a19/html5/thumbnails/3.jpg)
The Mandatory
• http://play.golang.org/p/OccSs5jC9Y
package main
import "fmt”
func main() {fmt.Println("Hello World!")
}
![Page 4: Golang getting started](https://reader037.vdocuments.site/reader037/viewer/2022091121/58a56bf81a28ab20528b6a19/html5/thumbnails/4.jpg)
Built for networks
• A simple server
package main
import "fmt” Import "net/http”
func hello(w http.ResponseWriter, r *http.Request) {fmt.Fprint(w, "Hello Client") //write response
}func main() {
http.HandleFunc("/", hello //attach handler http.ListenAndServe(":8080”, nil) //start server}
![Page 5: Golang getting started](https://reader037.vdocuments.site/reader037/viewer/2022091121/58a56bf81a28ab20528b6a19/html5/thumbnails/5.jpg)
ConcurrencyGreen Threading like python – goroutines
no Gil like limitationshttps://gobyexample.com/goroutines
Utilize multiple coresgoroutines can be run on multiple threads
![Page 6: Golang getting started](https://reader037.vdocuments.site/reader037/viewer/2022091121/58a56bf81a28ab20528b6a19/html5/thumbnails/6.jpg)
External pacakgesgo get <package_name>e.g. go get github.com/goibibo/gorpc
Installs to your specified patheasily install forks
Also checkout godep, https://github.com/tools/godep for better managing dependencies of your project
![Page 7: Golang getting started](https://reader037.vdocuments.site/reader037/viewer/2022091121/58a56bf81a28ab20528b6a19/html5/thumbnails/7.jpg)
Builtins
Just checkout https://golang.org/pkg/
You can see the source at https://golang.org/src/
![Page 8: Golang getting started](https://reader037.vdocuments.site/reader037/viewer/2022091121/58a56bf81a28ab20528b6a19/html5/thumbnails/8.jpg)
Start- tour• Take the tour, complete it tour.golang.org• Check http://openmymind.net/The-Little-Go-Book/ for a light introduction
![Page 9: Golang getting started](https://reader037.vdocuments.site/reader037/viewer/2022091121/58a56bf81a28ab20528b6a19/html5/thumbnails/9.jpg)
Start- install
• Install locally (1.4 for now)• http://golang.org/doc/install• Or the docker image if you prefer https://hub.docker.com/r/google/golang/
![Page 10: Golang getting started](https://reader037.vdocuments.site/reader037/viewer/2022091121/58a56bf81a28ab20528b6a19/html5/thumbnails/10.jpg)
Start – more stuff
• How to write Go code• Effective Go• http://golang.org/doc/effective_go.html
• Best Practices• https://talks.golang.org/2013/bestpractices.slide#1
![Page 11: Golang getting started](https://reader037.vdocuments.site/reader037/viewer/2022091121/58a56bf81a28ab20528b6a19/html5/thumbnails/11.jpg)
Start – some more stuff
• Organising Go code by David Crawshaw, presented at Google I/O 2014.• Contributing to Open Source Git Repositories in Go by Katrina Owen.
![Page 12: Golang getting started](https://reader037.vdocuments.site/reader037/viewer/2022091121/58a56bf81a28ab20528b6a19/html5/thumbnails/12.jpg)
Dev Environment - editors• Sublime Text 3
http://eefret.me/making-sublime-your-golang-ide/
• LiteIde http://
www.i-programmer.info/programming/other-languages/6600-a-programmers-guide-to-go-with-liteide-part-1.html
![Page 13: Golang getting started](https://reader037.vdocuments.site/reader037/viewer/2022091121/58a56bf81a28ab20528b6a19/html5/thumbnails/13.jpg)
Dev Environment – tools• go fmt• golint
![Page 14: Golang getting started](https://reader037.vdocuments.site/reader037/viewer/2022091121/58a56bf81a28ab20528b6a19/html5/thumbnails/14.jpg)
Right tool for the right problem…• Good for
Backend APIs Process Heavy stuff Non blocking IO, service calls
• Not so great Templating ORMs
… But still growing