Upgrade to Pro
— share decks privately, control downloads, hide ads and more …
Speaker Deck
Features
Speaker Deck
PRO
Sign in
Sign up for free
Search
Search
Einführung in Go
Search
Mario Behrendt
January 14, 2014
Programming
0
68
Einführung in Go
Eine kurze Einführung in die Programmiersprache Go und dessen Konzepte.
Mario Behrendt
January 14, 2014
Tweet
Share
Other Decks in Programming
See All in Programming
FigmaとPHPで作る1ミリたりとも表示崩れしない最強の帳票印刷ソリューション
ttskch
43
19k
Elm 0.19.0 Changes
bkuhlmann
0
510
Scalable Customer Journey Orchestration (CJO)
lewuathe
0
420
Ruby Pattern Matching
bkuhlmann
0
930
Ruby GitHub Packages
bkuhlmann
0
640
Implementing Design Systems in Swift
seyfoyun
2
480
大規模UIKitベースアプリへのTCAの段階的導入/gradual-adoption-of-tca-in-a-large-scale-uikit-based-app
takehilo
2
210
スキーマ駆動開発による品質とスピードの両立 - 私達は何故、スキーマを書くのか
kentaroutakeda
0
180
Build Apps for iOS, Android & Desktop in 100% Kotlin With Compose Multiplatform (mDevCamp 2024)
zsmb
0
460
Milestoner
bkuhlmann
1
410
GraphQLサーバの構成要素を整理する #ハッカー鮨 #tsukijigraphql / graphql server technology selection
izumin5210
4
910
Komplexe Oberflächen mit SVG und der Web Animation API
joergneumann
0
680
Featured
See All Featured
Statistics for Hackers
jakevdp
790
220k
Dealing with People You Can't Stand - Big Design 2015
cassininazir
358
22k
Distributed Sagas: A Protocol for Coordinating Microservices
caitiem20
323
20k
How to Ace a Technical Interview
jacobian
273
22k
Optimizing for Happiness
mojombo
370
69k
Designing Experiences People Love
moore
136
23k
10 Git Anti Patterns You Should be Aware of
lemiorhan
649
58k
A better future with KSS
kneath
231
16k
Git: the NoSQL Database
bkeepers
PRO
423
63k
What's new in Ruby 2.0
geeforr
337
31k
Thoughts on Productivity
jonyablonski
60
3.9k
Embracing the Ebb and Flow
colly
80
4.2k
Transcript
Go
Was ist Go?
Was ist Go? • Stark, statisch typisiert
Was ist Go? • Stark, statisch typisiert • Kompiliert (schnell!)
zu Maschinencode
Was ist Go? • Stark, statisch typisiert • Kompiliert (schnell!)
zu Maschinencode • Garbage collected
Was ist Go? • Stark, statisch typisiert • Kompiliert (schnell!)
zu Maschinencode • Garbage collected • Concurrency: Goroutinen & Channels
Was ist Go? • Stark, statisch typisiert • Kompiliert (schnell!)
zu Maschinencode • Garbage collected • Concurrency: Goroutinen & Channels • Simple Sprache, riesige Standard-Lib (Flags, Img)
Was ist Go? • Stark, statisch typisiert • Kompiliert (schnell!)
zu Maschinencode • Garbage collected • Concurrency: Goroutinen & Channels • Simple Sprache, riesige Standard-Lib (Flags, Img) • OOP
Quick look
Quick look package main ! import "fmt" ! func main()
{ fmt.Println("Works") }
OOP in Go
package main ! import "fmt" ! type Printable interface {
PrintName() } ! type A struct { Name string } ! func (a A) PrintName() { fmt.Println("A has name: " + a.Name) } ! type B struct { Name string } ! func (b B) PrintName() { fmt.Println("B has name: " + b.Name) } ! func printSomethingsName(p Printable) { p.PrintName() } ! func main() { A{"John"}.PrintName() printSomethingsName(B{"James"}) }
package main ! import "fmt" ! type A struct {
! } ! type B struct { A } ! func (a A) Foo() { fmt.Println("Foo") } ! func main() { B{}.Foo() }
Concurrency in Go
Concurrency in Go package main ! import ( "fmt" "time"
"strconv" ) ! func printSeconds(i int) { time.Sleep(1 * time.Second) fmt.Println(strconv.Itoa(i) + " seconds") } ! func main() { for i:=1; i < 6; i++ { printSeconds(i) } }
Concurrency in Go package main ! import ( "fmt" "time"
"strconv" ) ! func printSeconds(i int) { time.Sleep(1 * time.Second) fmt.Println(strconv.Itoa(i) + " seconds") } ! func main() { for i:=1; i < 6; i++ { printSeconds(i) } } package main ! import ( "fmt" "time" "strconv" ) ! func printSeconds(i int) { time.Sleep(1 * time.Second) fmt.Println(strconv.Itoa(i) + " seconds") } ! func main() { for i:=1; i < 6; i++ { go printSeconds(i) } time.Sleep(2 * time.Second) }
Concurrency in Go package main ! import ( "fmt" "time"
"strconv" ) ! func printSeconds(i int) { time.Sleep(1 * time.Second) fmt.Println(strconv.Itoa(i) + " seconds") } ! func main() { for i:=1; i < 6; i++ { go printSeconds(i) } time.Sleep(2 * time.Second) }
Concurrency in Go package main ! import ( "fmt" "time"
"strconv" ) ! func printSeconds(i int) { time.Sleep(1 * time.Second) fmt.Println(strconv.Itoa(i) + " seconds") } ! func main() { for i:=1; i < 6; i++ { go printSeconds(i) } time.Sleep(2 * time.Second) } package main ! import ( "fmt" "time" "strconv" ) ! func printSeconds(c chan int, i int) { time.Sleep(1 * time.Second) fmt.Println(strconv.Itoa(i) + " seconds") c <- 1 } ! func main() { c := make(chan int) ! for i:=1; i < 6; i++ { go printSeconds(c, i) } ! <- c }
Sonstiges
package main ! import ( "fmt" "log" "time" e "errors"
"math/rand" "net/http" ) ! func multipleReturns() (error, bool) { rand.Seed(time.Now().UTC().UnixNano()) ! if rand.Intn(10) % 2 == 0 { return nil, true } else { return e.New("Failed"), false } } ! func main() { err, _ := multipleReturns() ! if err != nil { log.Fatal(err) } ! fmt.Println("Random number was even! Starting web server...") ! http.HandleFunc("/", func(w http.ResponseWriter, r *http.Request) { fmt.Fprint(w, "Hello!") }) ! http.ListenAndServe(":4000", nil) }
Go tool chain
Go tool chain • go build & go run
Go tool chain • go build & go run •
go get
Go tool chain • go build & go run •
go get • go fmt
Go tool chain • go build & go run •
go get • go fmt • go test
Go tool chain • go build & go run •
go get • go fmt • go test • go tool
Go tool chain • go build & go run •
go get • go fmt • go test • go tool
Go tool chain • go build & go run •
go get • go fmt • go test • go tool • go doc
Negative Seiten
Negative Seiten • go get unterstützt im Moment keine Versionen
Negative Seiten • go get unterstützt im Moment keine Versionen
• Memory-leaks
Negative Seiten • go get unterstützt im Moment keine Versionen
• Memory-leaks • Community-Libs leiden unter Node.JS-Effekt
Negative Seiten • go get unterstützt im Moment keine Versionen
• Memory-leaks • Community-Libs leiden unter Node.JS-Effekt • Keine Generics - bis jetzt
Negative Seiten • go get unterstützt im Moment keine Versionen
• Memory-leaks • Community-Libs leiden unter Node.JS-Effekt • Keine Generics - bis jetzt • Error-Handling äußerst verbose
Negative Seiten • go get unterstützt im Moment keine Versionen
• Memory-leaks • Community-Libs leiden unter Node.JS-Effekt • Keine Generics - bis jetzt • Error-Handling äußerst verbose • (Keine Vererbung)
Wer nutzt Go?
Wer nutzt Go? • Google :)
Wer nutzt Go? • Google :) • Shopify
Wer nutzt Go? • Google :) • Shopify • Heroku
Wer nutzt Go? • Google :) • Shopify • Heroku
• Soundcloud
Wer nutzt Go? • Google :) • Shopify • Heroku
• Soundcloud • Bitly
Wer nutzt Go? • Google :) • Shopify • Heroku
• Soundcloud • Bitly • Canonical
Weitere Informationen
Weitere Informationen • http://golang.org
Weitere Informationen • http://golang.org • https://groups.google.com/d/forum/golang-nuts
Weitere Informationen • http://golang.org • https://groups.google.com/d/forum/golang-nuts • https://github.com/robfig/revel
Weitere Informationen • http://golang.org • https://groups.google.com/d/forum/golang-nuts • https://github.com/robfig/revel • https://github.com/limetext/lime
Weitere Informationen • http://golang.org • https://groups.google.com/d/forum/golang-nuts • https://github.com/robfig/revel • https://github.com/limetext/lime
• https://github.com/dotcloud/docker
Weitere Informationen • http://golang.org • https://groups.google.com/d/forum/golang-nuts • https://github.com/robfig/revel • https://github.com/limetext/lime
• https://github.com/dotcloud/docker • https://github.com/mitchellh/packer
Danke für’s Zuhören. Fragen?