際際滷

際際滷Share a Scribd company logo
Golang
Getting started
Not a talk  reference deck
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
The Mandatory
 http://play.golang.org/p/OccSs5jC9Y
package main
import "fmt
func main() {
fmt.Println("Hello World!")
}
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
}
Concurrency
Green Threading like python  goroutines
no Gil like limitations
https://gobyexample.com/goroutines
Utilize multiple cores
goroutines can be run on multiple threads
External pacakges
go get <package_name>
e.g. go get github.com/goibibo/gorpc
Installs to your specified path
easily install forks
Also checkout godep, https://github.com/tools/godep for better
managing dependencies of your project
Builtins
Just checkout https://golang.org/pkg/
You can see the source at https://golang.org/src/
Start- tour
 Take the tour, complete it tour.golang.org
 Check http://openmymind.net/The-
Little-Go-Book/ for a light introduction
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/
Start  more stuff
 How to write Go code
 Effective Go
 http://golang.org/doc/effective_go.html
 Best Practices
 https://talks.golang.org/2013/bestpractic
es.slide#1
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.
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
Dev Environment  tools
 go fmt
 golint
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

More Related Content

Golang getting started

  • 1. Golang Getting started Not a talk reference deck
  • 2. 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
  • 3. The Mandatory http://play.golang.org/p/OccSs5jC9Y package main import "fmt func main() { fmt.Println("Hello World!") }
  • 4. 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 }
  • 5. Concurrency Green Threading like python goroutines no Gil like limitations https://gobyexample.com/goroutines Utilize multiple cores goroutines can be run on multiple threads
  • 6. External pacakges go get <package_name> e.g. go get github.com/goibibo/gorpc Installs to your specified path easily install forks Also checkout godep, https://github.com/tools/godep for better managing dependencies of your project
  • 7. Builtins Just checkout https://golang.org/pkg/ You can see the source at https://golang.org/src/
  • 8. Start- tour Take the tour, complete it tour.golang.org Check http://openmymind.net/The- Little-Go-Book/ for a light introduction
  • 9. 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/
  • 10. Start more stuff How to write Go code Effective Go http://golang.org/doc/effective_go.html Best Practices https://talks.golang.org/2013/bestpractic es.slide#1
  • 11. 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.
  • 12. 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
  • 13. Dev Environment tools go fmt golint
  • 14. 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