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
78
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
#QiitaBash TDDで(自分の)開発がどう変わったか
ryosukedtomita
1
360
JetBrainsのAI機能の紹介 #jjug
yusuke
0
200
Flutterと Vibe Coding で個人開発!
hyshu
1
250
0から始めるモジュラーモノリス-クリーンなモノリスを目指して
sushi0120
0
280
実践!App Intents対応
yuukiw00w
1
250
書き捨てではなく継続開発可能なコードをAIコーディングエージェントで書くために意識していること
shuyakinjo
1
270
AHC051解法紹介
eijirou
0
470
『リコリス・リコイル』に学ぶ!! 〜キャリア戦略における計画的偶発性理論と変わる勇気の重要性〜
wanko_it
1
500
Constant integer division faster than compiler-generated code
herumi
2
600
なぜ今、Terraformの本を書いたのか? - 著者陣に聞く!『Terraformではじめる実践IaC』登壇資料
fufuhu
4
580
Google I/O Extended Incheon 2025 ~ What's new in Android development tools
pluu
1
270
それ CLI フレームワークがなくてもできるよ / Building CLI Tools Without Frameworks
orgachem
PRO
17
3.8k
Featured
See All Featured
The Invisible Side of Design
smashingmag
301
51k
The Pragmatic Product Professional
lauravandoore
36
6.8k
Automating Front-end Workflow
addyosmani
1370
200k
Fight the Zombie Pattern Library - RWD Summit 2016
marcelosomers
234
17k
Bash Introduction
62gerente
614
210k
A better future with KSS
kneath
239
17k
Stop Working from a Prison Cell
hatefulcrawdad
271
21k
How to train your dragon (web standard)
notwaldorf
96
6.2k
Principles of Awesome APIs and How to Build Them.
keavy
126
17k
CSS Pre-Processors: Stylus, Less & Sass
bermonpainter
358
30k
Speed Design
sergeychernyshev
32
1.1k
Docker and Python
trallard
45
3.5k
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?