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
Spring gRPC で始める gRPC 入門 / Introduction to gRPC with Spring gRPC
mackey0225
2
520
Using AI Tools Around Software Development
inouehi
0
1.2k
エンジニア向け採用ピッチ資料
inusan
0
140
deno-redisの紹介とJSRパッケージの運用について (toranoana.deno #21)
uki00a
0
120
プロダクト開発でも使おう 関数のオーバーロード
yoiwamoto
0
160
生成AIコーディングとの向き合い方、AIと共創するという考え方 / How to deal with generative AI coding and the concept of co-creating with AI
seike460
PRO
1
320
データベースコネクションプール(DBCP)の変遷と理解
fujikawa8
1
270
つよそうにふるまい、つよい成果を出すのなら、つよいのかもしれない
irof
1
290
Cursor Meetup Tokyo ゲノミクスとCursor: 進化と制約のあいだ
koido
2
1k
今ならAmazon ECSのサービス間通信をどう選ぶか / Selection of ECS Interservice Communication 2025
tkikuc
11
2.6k
関数型まつりレポート for JuliaTokai #22
antimon2
0
130
WindowInsetsだってテストしたい
ryunen344
1
190
Featured
See All Featured
How to Create Impact in a Changing Tech Landscape [PerfNow 2023]
tammyeverts
53
2.8k
Embracing the Ebb and Flow
colly
86
4.7k
Site-Speed That Sticks
csswizardry
10
650
Code Reviewing Like a Champion
maltzj
524
40k
Templates, Plugins, & Blocks: Oh My! Creating the theme that thinks of everything
marktimemedia
31
2.4k
Evolution of real-time – Irina Nazarova, EuRuKo, 2024
irinanazarova
8
790
XXLCSS - How to scale CSS and keep your sanity
sugarenia
248
1.3M
We Have a Design System, Now What?
morganepeng
52
7.6k
Raft: Consensus for Rubyists
vanstee
140
7k
Stop Working from a Prison Cell
hatefulcrawdad
270
20k
Let's Do A Bunch of Simple Stuff to Make Websites Faster
chriscoyier
507
140k
How GitHub (no longer) Works
holman
314
140k
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?