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
74
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
技術選定を未来に繋いで活用していく
sakito
3
100
地域ITコミュニティの活性化とAWSに移行してみた話
yuukis
0
220
小田原でみんなで一句詠みたいな #phpcon_odawara
stefafafan
0
310
Java 24まとめ / Java 24 summary
kishida
3
440
AWSで雰囲気でつくる! VRChatの写真変換ピタゴラスイッチ
anatofuz
0
140
Firebase Dynamic Linksの代替手段を自作する / Create your own Firebase Dynamic Links alternative
kubode
0
230
リアクティブシステムの変遷から理解するalien-signals / Learning alien-signals from the evolution of reactive systems
yamanoku
3
1.2k
State of Namespace
tagomoris
3
300
Code smarter, not harder - How AI Coding Tools Boost Your Productivity | Webinar 2025
danielsogl
0
110
小さく段階的リリースすることで深夜メンテを回避する
mkmk884
2
160
複数ドメインに散らばってしまった画像…! 運用中のPHPアプリに後からCDNを導入する…!
suguruooki
0
460
Kamal 2 – Get Out of the Cloud
aleksandrov
1
170
Featured
See All Featured
Speed Design
sergeychernyshev
28
880
Designing Dashboards & Data Visualisations in Web Apps
destraynor
231
53k
Being A Developer After 40
akosma
90
590k
Helping Users Find Their Own Way: Creating Modern Search Experiences
danielanewman
29
2.5k
We Have a Design System, Now What?
morganepeng
52
7.5k
ピンチをチャンスに:未来をつくるプロダクトロードマップ #pmconf2020
aki_iinuma
118
51k
Creating an realtime collaboration tool: Agile Flush - .NET Oxford
marcduiker
29
2k
VelocityConf: Rendering Performance Case Studies
addyosmani
328
24k
The MySQL Ecosystem @ GitHub 2015
samlambert
251
12k
Fantastic passwords and where to find them - at NoRuKo
philnash
51
3.1k
The Invisible Side of Design
smashingmag
299
50k
10 Git Anti Patterns You Should be Aware of
lemiorhan
PRO
656
60k
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?