chore: initialize containerized Go learning workbook (2026 DevOps/SRE)

This commit is contained in:
soda64 committed 2026-11-30 23:03:31 +01:00
commit 84be3e5d77
64 files changed
+1382

No files matched your search

@@ -0,0 +1,11 @@
# 02 — Slices, Mapy i Stringi (`rune` vs `byte`)
## Zadania (`collections.go`)
1. `UniqueInts(nums []int) []int` — usuń duplikaty, zachowując kolejność pierwszego wystąpienia.
2. `WordCounts(text string) map[string]int` — policz słowa (lowercase, `strings.Fields`).
3. `ReverseRunes(s string) string` — odwróć napis poprawnie dla UTF-8 (polskie znaki/emoji -> użyj `[]rune`).
## Uruchomienie testów
```bash
make test PKG=./exercises/01-core/02-slices-maps-strings
```
@@ -0,0 +1,13 @@
package collections
func UniqueInts(nums []int) []int {
panic("TODO: usuń duplikaty zachowując kolejność")
}
func WordCounts(text string) map[string]int {
panic("TODO: policz słowa (strings.Fields + strings.ToLower)")
}
func ReverseRunes(s string) string {
panic("TODO: odwróć napis jako []rune")
}
@@ -0,0 +1,27 @@
package collections
import (
"reflect"
"testing"
)
func TestUniqueInts(t *testing.T) {
got := UniqueInts([]int{3, 1, 2, 3, 1, 4})
want := []int{3, 1, 2, 4}
if !reflect.DeepEqual(got, want) {
t.Fatalf("got %v, want %v", got, want)
}
}
func TestWordCounts(t *testing.T) {
got := WordCounts("Go go is fast and GO works")
if got["go"] != 3 || got["fast"] != 1 {
t.Fatalf("unexpected counts: %v", got)
}
}
func TestReverseRunes(t *testing.T) {
if got := ReverseRunes("zażółć"); got != "ćłóżaz" {
t.Fatalf("got %q, want %q", got, "ćłóżaz")
}
}