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

+56
View File
@@ -0,0 +1,56 @@
IMAGE ?= go-learning:latest
ENGINE ?= podman
GO_CACHE ?= go-learning-mod-cache
PKG ?=
RUN_CONTAINER = $(ENGINE) run --rm \
-v "$(CURDIR):/workspace:Z" \
-v "$(GO_CACHE):/go/pkg/mod" \
-w /workspace \
$(IMAGE)
.PHONY: help image check lint test test-all fmt fmt-check shell
help:
@echo "Dostępne komendy:"
@echo " make image - Zbuduj obraz kontenera Go (jednorazowo)"
@echo " make check - Sprawdź kompilację i go vet"
@echo " make lint - Uruchom staticcheck"
@echo " make test PKG=./exercises/01-core/01-basics - Uruchom testy wybranego rozdziału (-race)"
@echo " make test - Uruchom testy 01-core + 02-engineering-2026"
@echo " make test-all - Uruchom testy całego repozytorium"
@echo " make fmt - Sformatuj kod (gofmt)"
@echo " make fmt-check - Sprawdź formatowanie kodu"
@echo " make shell - Otwórz powłokę bash wewnątrz kontenera"
image:
$(ENGINE) build -t $(IMAGE) -f Containerfile .
check:
$(RUN_CONTAINER) go vet ./...
lint:
$(RUN_CONTAINER) staticcheck ./...
test:
ifdef PKG
$(RUN_CONTAINER) go test -race -v $(PKG)
else
$(RUN_CONTAINER) go test -race -v ./exercises/01-core/... ./exercises/02-engineering-2026/...
endif
test-all:
$(RUN_CONTAINER) go test -race -v ./...
fmt:
$(RUN_CONTAINER) gofmt -w exercises
fmt-check:
$(RUN_CONTAINER) sh -c 'out=$$(gofmt -l exercises); test -z "$$out" || (echo "Unformatted files:"; echo "$$out"; exit 1)'
shell:
$(ENGINE) run --rm -it \
-v "$(CURDIR):/workspace:Z" \
-v "$(GO_CACHE):/go/pkg/mod" \
-w /workspace \
$(IMAGE) bash