89 lines
2.8 KiB
Markdown
89 lines
2.8 KiB
Markdown
# Workshop golang HAN ESE jan '23
|
|
|
|
|
|
Tekst wat de workshop inhoud:
|
|
- Wat ga ik doen
|
|
- Verwachting als ze geweest zijn
|
|
- Wat moeten ze meenemen
|
|
|
|
Workshop inhoud:
|
|
|
|
```
|
|
"Writing a tcp server for embedded devices in Golang within hours"
|
|
|
|
Course time schedule (50 min)
|
|
|
|
- 10 min: About myself, the company I work for and Golang introduction
|
|
- 5 min: Exercise explanation
|
|
- 30 min: Golang hands-on with support from me (2 persons per exercise)
|
|
- 5 min: The outcome and questions
|
|
|
|
Bring a laptop with a browser and wifi. The Google Chrome browser is preferred.
|
|
```
|
|
|
|
|
|
## Slides
|
|
|
|
- https://pkg.go.dev/golang.org/x/tools/present
|
|
|
|
|
|
### Interesting packages
|
|
|
|
- buffer
|
|
- net
|
|
- io
|
|
|
|
### Golang online playground
|
|
|
|
- https://goplay.tools/ has working `net` (officieel https://go.dev/play>)
|
|
|
|
## Functional Options Pattern in Golang
|
|
|
|
<https://michalzalecki.com/golang-options-pattern/>
|
|
<https://petomalina.medium.com/dealing-with-optional-parameters-in-go-9780f9bfbd1d>
|
|
<https://www.sohamkamani.com/golang/options-pattern/>
|
|
|
|
Normaly you would fill in many parameters or pass a struct with many knobs to turn. The Optional Function Parameter Pattern in Golang deals in a unique way
|
|
with module parameters which can be added and removed without extending the type
|
|
with extra setter and getter functions. As options is a type they can be passed in as a slice.
|
|
|
|
### Excercise
|
|
|
|
### The net package
|
|
|
|
For cross platform TCP/UDP/UNIX network socket access. From the builtin
|
|
`net` package.
|
|
|
|
- <https://pkg.go.dev/net@go1.19.3>
|
|
|
|
### The show must go on ...
|
|
|
|
Good Golang content to keep the ball rolling
|
|
|
|
- [A Tour of go](https://go.dev/tour)
|
|
- [The Go Blog](https://go.dev/blog/)
|
|
- [Go talks (slides)](https://go.dev/talks/)
|
|
- [Go by Example](https://gobyexample.com/)
|
|
- [Yourbasic.com Golang](https://yourbasic.org/golang)
|
|
- [Golang Weekly Newsletter](https://golangweekly.com/issues)
|
|
- [Gopher Academy Youtube](https://www.youtube.com/c/GopherAcademy)
|
|
- [justforfunc: Programming in Go youtube](https://www.youtube.com/c/justforfunc) ([github](https://github.com/campoy/justforfunc))
|
|
|
|
## Opdracht
|
|
|
|
- Zorg dat het programma na 16 client handlings afsluit als alle processing klaar is
|
|
|
|
## TODO & Braindump
|
|
|
|
- Programming Golang since 2016
|
|
- Zet oefening met sharelink op <https://goplay.tools/snippet/XOM0c7Dp0YD>
|
|
- Running opensource project Syncthing macOS
|
|
- Check if firefox also works with https://go.dev/play/
|
|
- Golang uses composition for OO-like system instead of polymorphism which is easier to read and write
|
|
- GOlang has an interface type builtin to the language (e.g io.Reader)
|
|
- `cmd` package is special where executables are
|
|
- Multiple return values
|
|
- Variables are ALWAYS initialised (for safety)
|
|
- Slices to keep things together (len, cap, size)
|
|
- Public/private no keyword but by contract (highercase is public, lowercase private)
|