Download - Intro to GO (Bangkok Launchpad 2014)
![Page 1: Intro to GO (Bangkok Launchpad 2014)](https://reader034.vdocuments.us/reader034/viewer/2022051110/54b4ede84a7959244d8b46b0/html5/thumbnails/1.jpg)
Intro to GO
Bangkok GO Meetup 2014
![Page 2: Intro to GO (Bangkok Launchpad 2014)](https://reader034.vdocuments.us/reader034/viewer/2022051110/54b4ede84a7959244d8b46b0/html5/thumbnails/2.jpg)
Still learning thai
English>?
![Page 3: Intro to GO (Bangkok Launchpad 2014)](https://reader034.vdocuments.us/reader034/viewer/2022051110/54b4ede84a7959244d8b46b0/html5/thumbnails/3.jpg)
My Level of thai
![Page 4: Intro to GO (Bangkok Launchpad 2014)](https://reader034.vdocuments.us/reader034/viewer/2022051110/54b4ede84a7959244d8b46b0/html5/thumbnails/4.jpg)
● Who a hip language, Ruby / Javascript
● Who uses Java / C#
● Has anyone played with GO?
Survey the Audience
![Page 5: Intro to GO (Bangkok Launchpad 2014)](https://reader034.vdocuments.us/reader034/viewer/2022051110/54b4ede84a7959244d8b46b0/html5/thumbnails/5.jpg)
● Instant Messenger Server in GO
● Why we chose go
● Basics about go
● How to get started with GO
Whats this talk about
![Page 6: Intro to GO (Bangkok Launchpad 2014)](https://reader034.vdocuments.us/reader034/viewer/2022051110/54b4ede84a7959244d8b46b0/html5/thumbnails/6.jpg)
![Page 7: Intro to GO (Bangkok Launchpad 2014)](https://reader034.vdocuments.us/reader034/viewer/2022051110/54b4ede84a7959244d8b46b0/html5/thumbnails/7.jpg)
Small consulting firm Hyperworks*Built Bloomberg.com*Real time ad servers*Ecommerce sites (gucci,reebok etc)*Thomson Reuters Messenger Client/Server
Who am I ?
![Page 8: Intro to GO (Bangkok Launchpad 2014)](https://reader034.vdocuments.us/reader034/viewer/2022051110/54b4ede84a7959244d8b46b0/html5/thumbnails/8.jpg)
● Instant Messaging Server / Client
● Backend 100% GO
● 300k user base of financial traders!
● 20 Megabits of sustained traffic
What we’re we using
![Page 9: Intro to GO (Bangkok Launchpad 2014)](https://reader034.vdocuments.us/reader034/viewer/2022051110/54b4ede84a7959244d8b46b0/html5/thumbnails/9.jpg)
Why GO?
![Page 10: Intro to GO (Bangkok Launchpad 2014)](https://reader034.vdocuments.us/reader034/viewer/2022051110/54b4ede84a7959244d8b46b0/html5/thumbnails/10.jpg)
![Page 11: Intro to GO (Bangkok Launchpad 2014)](https://reader034.vdocuments.us/reader034/viewer/2022051110/54b4ede84a7959244d8b46b0/html5/thumbnails/11.jpg)
● Dying
● Hard to hire people
● Nothing new happening
● Not cool
C++
![Page 12: Intro to GO (Bangkok Launchpad 2014)](https://reader034.vdocuments.us/reader034/viewer/2022051110/54b4ede84a7959244d8b46b0/html5/thumbnails/12.jpg)
● Slow to code
● Very verbose
● Need a much larger team
Java
![Page 13: Intro to GO (Bangkok Launchpad 2014)](https://reader034.vdocuments.us/reader034/viewer/2022051110/54b4ede84a7959244d8b46b0/html5/thumbnails/13.jpg)
● Hate windows on a server
C#
![Page 14: Intro to GO (Bangkok Launchpad 2014)](https://reader034.vdocuments.us/reader034/viewer/2022051110/54b4ede84a7959244d8b46b0/html5/thumbnails/14.jpg)
● Lightweight concurrency
● Fast development cycle
● Hip with the kids
GO
![Page 15: Intro to GO (Bangkok Launchpad 2014)](https://reader034.vdocuments.us/reader034/viewer/2022051110/54b4ede84a7959244d8b46b0/html5/thumbnails/15.jpg)
● Google’s programming language● Garbage collected● Author is Rob Pike (Inventor of unix)● Fast Compilations● Fast Runtime● Easy to learn
About GO
![Page 16: Intro to GO (Bangkok Launchpad 2014)](https://reader034.vdocuments.us/reader034/viewer/2022051110/54b4ede84a7959244d8b46b0/html5/thumbnails/16.jpg)
Hello World (Aka a webserver)import (
"fmt""http"
)func handler(c *http.Conn, r *http.Request) {
fmt.Fprintf(c, "Hello, %s.\n", r.URL.Path[1:])}func main() {
http.ListenAndServe(":8080", http.HandlerFunc(handler))}
Go is like C/C#/Java
![Page 17: Intro to GO (Bangkok Launchpad 2014)](https://reader034.vdocuments.us/reader034/viewer/2022051110/54b4ede84a7959244d8b46b0/html5/thumbnails/17.jpg)
For javascript/ruby devs
valueToCloseOver := "My name is HAL."
anon := func(s string) string { return "Hiya, " + name + ". " + valueToCloseOver } anotherFunction(anon)
Lambdas
![Page 18: Intro to GO (Bangkok Launchpad 2014)](https://reader034.vdocuments.us/reader034/viewer/2022051110/54b4ede84a7959244d8b46b0/html5/thumbnails/18.jpg)
![Page 19: Intro to GO (Bangkok Launchpad 2014)](https://reader034.vdocuments.us/reader034/viewer/2022051110/54b4ede84a7959244d8b46b0/html5/thumbnails/19.jpg)
● Lightweight threads
● Easy concurrency
● Like Erlang, communicate instead of sharing memory
Go Routines
![Page 20: Intro to GO (Bangkok Launchpad 2014)](https://reader034.vdocuments.us/reader034/viewer/2022051110/54b4ede84a7959244d8b46b0/html5/thumbnails/20.jpg)
● Container for messages between go routines
● Concorrent safe
Channels
![Page 21: Intro to GO (Bangkok Launchpad 2014)](https://reader034.vdocuments.us/reader034/viewer/2022051110/54b4ede84a7959244d8b46b0/html5/thumbnails/21.jpg)
c := make(chan int) // Allocate a channel.// Start the sort in a goroutine; when it completes, signal on the channel.
go func() { list.Sort() c <- 1 // Send a signal; value does not matter.}()
doSomethingForAWhile()<-c // Wait for sort to finish; discard sent value.
Code samples
![Page 22: Intro to GO (Bangkok Launchpad 2014)](https://reader034.vdocuments.us/reader034/viewer/2022051110/54b4ede84a7959244d8b46b0/html5/thumbnails/22.jpg)
● Interfaces over inheritance
● Duck typing
● Composition
No inheritance
![Page 23: Intro to GO (Bangkok Launchpad 2014)](https://reader034.vdocuments.us/reader034/viewer/2022051110/54b4ede84a7959244d8b46b0/html5/thumbnails/23.jpg)
type Stringer interface { String() string}
var value interface{} // Value provided by caller.switch str := value.(type) {case string: return strcase Stringer: return str.String()}
Example interface code
![Page 24: Intro to GO (Bangkok Launchpad 2014)](https://reader034.vdocuments.us/reader034/viewer/2022051110/54b4ede84a7959244d8b46b0/html5/thumbnails/24.jpg)
![Page 25: Intro to GO (Bangkok Launchpad 2014)](https://reader034.vdocuments.us/reader034/viewer/2022051110/54b4ede84a7959244d8b46b0/html5/thumbnails/25.jpg)
● Windows support
● Small number of libraries
● Community still small but growing
Things not so good
![Page 26: Intro to GO (Bangkok Launchpad 2014)](https://reader034.vdocuments.us/reader034/viewer/2022051110/54b4ede84a7959244d8b46b0/html5/thumbnails/26.jpg)
● http://play.golang.org/
● http://golang.org/doc/
How to get started
![Page 27: Intro to GO (Bangkok Launchpad 2014)](https://reader034.vdocuments.us/reader034/viewer/2022051110/54b4ede84a7959244d8b46b0/html5/thumbnails/27.jpg)
Q/A
![Page 28: Intro to GO (Bangkok Launchpad 2014)](https://reader034.vdocuments.us/reader034/viewer/2022051110/54b4ede84a7959244d8b46b0/html5/thumbnails/28.jpg)
Btw We’re Hiring !
Thanks!