-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathws1.slide
More file actions
121 lines (79 loc) · 2.52 KB
/
ws1.slide
File metadata and controls
121 lines (79 loc) · 2.52 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
Go workshop
En introduksjon
28 Aug 2015
Thomas Siegfried Krampl
@thokra
* Go is an open source programming language that makes it easy to build simple, reliable, and efficient software.
* Historietime
- Startet sent 2007
- Prototype i 2008
- Lansert OS i 2009
- Go 1.0 lansert 28. mars 2012
- Go 1.5 lansert 19. august 2015 (No more C)
.image assets/logo.png
* Hvorfor ett nytt språk?
- Stor frustrasjon med gjeldende miljøer
- Kompilering var treigt
- 10+ år siden siste systemspråk
- Multicore/system fokus
* Hva er Go?
- En spesifikasjon
- Verktøypakke
- Ett nøkkelord
* Hello World
.play code/hello_world.go
* Syntax
*Package*
Alle Go filer må starte med package name.
*Variabler*
.play -edit code/vars.go /START OMIT/,/END OMIT/
De tre siste gjør det samme, men den siste kan kun brukes inne i funksjoner.
* Syntax
*Funksjoner*
.play -edit code/funcs.go /START OMIT/,/END OMIT/
Starter alltid med func og kan returnere flere variabler.
* Syntax
*Slice/arrays*
.play -edit code/loops.go /START SLICE OMIT/,/END SLICE OMIT/
* Syntax
*Løkker*
.play -edit code/loops.go /START OMIT/,/END OMIT/
* Syntax
*Maps*
.play -edit code/maps.go
* Hello World 2
.play code/hello_server.go
[[http://localhost:3030][Open]]
* Structs
.play code/struct.go /START OMIT/,/END OMIT/
* Structs
.play code/struct.go /START FUNC OMIT/,/END FUNC OMIT/
* Interfaces
type Stringer interface {
String() string
}
Go benytter interfaces. _Alle_ typer som implementerer *String()* *string* støtter implisitt *Stringer* interfacet.
* Concurrency
.play code/concurrency.go /START OMIT/,/END OMIT/
Nøkkelordet *go* kjører funksjonen i egen goroutine.
En goroutine er en lett tråd.
* Verktøy
- go fmt - Formattering av Go kode. Det er EN måte å skrive Go på!
- go vet - finn problemer med koden
- golint - Lint koden, finn deler av koden du kan forbedre.
- godoc - Les dokumentasjonen til alle pakker du har i GOPATH
godoc -http=:6060
Felles for de fleste Go kommandoer er: output kun ved feil
* Miljø
Mitt favorittmiljø: Sublime Text 3 med [[https://github.com/DisposaBoy/GoSublime][GoSublime]]. Bruker [[https://github.com/bradfitz/goimports][goimports]] istedetfor go fmt
Atom med [[https://github.com/joefitzgerald/go-plus][go-plus]]
Vim med [[https://github.com/fatih/vim-go][vim-go]]
[[https://github.com/visualfc/liteide][CodeLite]] IDE laget for Go
* Gopher
.image assets/gopher.png
.caption _Gopher_ by [[http://www.reneefrench.com][Renée French]]
* Get ready, set, Go!
La oss skrive Go
Forslag:
- JSON API server
- Web Crawler