Fundamentals training in Golang
- Parse csv dataset into predefined structs/maps:
go run parseCsv.go
- Parse nginx access log from K8S pod as unformatted csv:
cd parsing-plain-text-example && go run parseNginx.go
topics:
- get log as file from pod logs stdout
- get rid of infra nginx logs and provide only clear access log using
os
for file ops andbufio
Scanner to get rid of non-access log lines (using IP regex match) - parse as csv with whitespace delimeter
- map it into struct with time.Time and int formats for response codes/timelogs
-
Go to
unit-test-example
-
Run unit testing:
go test -v
- Check testing coverage:
go test -v -coverprofile=test-coverage.txt
- Prettify coverage profile in html:
go tool cover -html=test-coverage.txt -o test-coverage.html
-
Go to
sorting-example/merge-sort
-
Run unit testing:
go test -bench=.
Go to sorting-example/merge-sort
, topics:
- merge sort for customized struct objects
- single thread sorting
- multithread sorting (goroutine and waitgroups)
- threads management (semaphore pattern as buffered channel for driving amount of goroutines and switch to single thread in case of limit exceeded)
- Go to
map-merge-reduce-example
- Run app:
go run mmr.go
topics:
- get CSV data re: Covid cases from open sources
- Define desired date to monitor cases in all countries (MAP training)
- Define amount of critical deaths border (REDUCE training)
- Sort values using merge sort alghoritm
- MAP + multithread = creating struct objects from csv plain text
- REDUCE + multithread = filter them by critical deaths border
- Sort + multithread = sort by amount of death
- Pretty print