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
77
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
データの民主化を支える、透明性のあるデータ利活用への挑戦 2025-06-25 Database Engineering Meetup#7
y_ken
0
330
WebViewの現在地 - SwiftUI時代のWebKit - / The Current State Of WebView
marcy731
0
100
WindowInsetsだってテストしたい
ryunen344
1
200
なんとなくわかった気になるブロックテーマ入門/contents.nagoya 2025 6.28
chiilog
1
240
Kotlin エンジニアへ送る:Swift 案件に参加させられる日に備えて~似てるけど色々違う Swift の仕様 / from Kotlin to Swift
lovee
1
260
LT 2025-06-30: プロダクトエンジニアの役割
yamamotok
0
580
GitHub Copilot and GitHub Codespaces Hands-on
ymd65536
1
130
iOSアプリ開発で 関数型プログラミングを実現する The Composable Architectureの紹介
yimajo
2
220
NPOでのDevinの活用
codeforeveryone
0
450
AIコーディング道場勉強会#2 君(エンジニア)たちはどう生きるか
misakiotb
1
260
Cursor AI Agentと伴走する アプリケーションの高速リプレイス
daisuketakeda
1
130
PHP 8.4の新機能「プロパティフック」から学ぶオブジェクト指向設計とリスコフの置換原則
kentaroutakeda
2
660
Featured
See All Featured
Optimizing for Happiness
mojombo
379
70k
Scaling GitHub
holman
459
140k
Visualization
eitanlees
146
16k
Balancing Empowerment & Direction
lara
1
380
ピンチをチャンスに:未来をつくるプロダクトロードマップ #pmconf2020
aki_iinuma
124
52k
Learning to Love Humans: Emotional Interface Design
aarron
273
40k
StorybookのUI Testing Handbookを読んだ
zakiyama
30
5.8k
RailsConf 2023
tenderlove
30
1.1k
GraphQLの誤解/rethinking-graphql
sonatard
71
11k
Large-scale JavaScript Application Architecture
addyosmani
512
110k
Documentation Writing (for coders)
carmenintech
72
4.9k
Building Flexible Design Systems
yeseniaperezcruz
328
39k
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?