From af0383108b93b1d79d9eeaf016ab626f384359d1 Mon Sep 17 00:00:00 2001 From: MermaidMan Date: Fri, 22 May 2026 23:56:56 +0000 Subject: [PATCH 1/2] Add check-go guard with friendly message for missing Go toolchain --- Makefile | 60 +++++++++++++++++++++++++++++++++++++++++--------------- 1 file changed, 44 insertions(+), 16 deletions(-) diff --git a/Makefile b/Makefile index bfe215d..6fa8494 100644 --- a/Makefile +++ b/Makefile @@ -20,32 +20,60 @@ GOVET := $(GOCMD) vet # Cross-compilation targets TARGETS := linux-amd64 linux-arm64 darwin-arm64 windows-amd64 windows-arm64 -# Platform detection -GOOS := $(shell go env GOOS) -GOARCH := $(shell go env GOARCH) +# Platform detection (noiseless fallback — true check happens in check-go target) +GOOS := $(shell go env GOOS 2>/dev/null || echo "unknown") +GOARCH := $(shell go env GOARCH 2>/dev/null || echo "unknown") + +# ────────────────────────────────────────────── +# Friendly Go-not-found guard +check-go: + @if ! command -v go >/dev/null 2>&1; then \ + echo ""; \ + echo " ╭──────────────────────────────────────────────╮"; \ + echo " │ ⚠ Go is not installed on this machine │"; \ + echo " ├──────────────────────────────────────────────┤"; \ + echo " │ │"; \ + echo " │ obm is a Go project. You need the Go │"; \ + echo " │ toolchain to build from source. │"; \ + echo " │ │"; \ + echo " │ Install Go: │"; \ + echo " │ Linux: your package manager │"; \ + echo " │ or https://go.dev/dl/ │"; \ + echo " │ │"; \ + echo " │ macOS: brew install go │"; \ + echo " │ │"; \ + echo " │ Windows: https://go.dev/dl/ │"; \ + echo " │ │"; \ + echo " │ Or use the all-in-one script: │"; \ + echo " │ ./scripts/install.sh │"; \ + echo " │ │"; \ + echo " ╰──────────────────────────────────────────────╯"; \ + echo ""; \ + exit 1; \ + fi all: lint test build -build: +build: check-go @echo "Building $(BINARY) v$(VERSION) for $(GOOS)/$(GOARCH)..." $(GOBUILD) $(LDFLAGS) -o $(BINARY) ./cmd/obm -test: +test: check-go @echo "Running tests..." $(GOTEST) -v -race -coverprofile=coverage.out ./... lint: vet fmt @echo "✓ Lint pass" -vet: +vet: check-go @echo "Running go vet..." $(GOVET) ./... -fmt: +fmt: check-go @echo "Formatting code..." gofmt -l -s -w . -clean: +clean: check-go @echo "Cleaning..." rm -f $(BINARY) rm -f coverage.out @@ -67,7 +95,7 @@ version: @echo "$(VERSION)" # Cross-compilation -cross-compile: +cross-compile: check-go @echo "Cross-compiling for all platforms..." @mkdir -p bin @for target in $(TARGETS); do \ @@ -84,23 +112,23 @@ cross-compile: @echo "✓ Cross-compilation complete" # Build specific platform -build-linux-amd64: +build-linux-amd64: check-go @mkdir -p bin GOOS=linux GOARCH=amd64 CGO_ENABLED=0 $(GOBUILD) $(LDFLAGS) -o bin/linux-amd64/$(BINARY) ./cmd/obm -build-linux-arm64: +build-linux-arm64: check-go @mkdir -p bin GOOS=linux GOARCH=arm64 CGO_ENABLED=0 $(GOBUILD) $(LDFLAGS) -o bin/linux-arm64/$(BINARY) ./cmd/obm -build-darwin-arm64: +build-darwin-arm64: check-go @mkdir -p bin GOOS=darwin GOARCH=arm64 CGO_ENABLED=0 $(GOBUILD) $(LDFLAGS) -o bin/darwin-arm64/$(BINARY) ./cmd/obm -build-windows-amd64: +build-windows-amd64: check-go @mkdir -p bin GOOS=windows GOARCH=amd64 CGO_ENABLED=0 $(GOBUILD) $(LDFLAGS) -o bin/windows-amd64/$(BINARY).exe ./cmd/obm -build-windows-arm64: +build-windows-arm64: check-go @mkdir -p bin GOOS=windows GOARCH=arm64 CGO_ENABLED=0 $(GOBUILD) $(LDFLAGS) -o bin/windows-arm64/$(BINARY).exe ./cmd/obm @@ -140,10 +168,10 @@ dev: build test @echo "✓ Development build complete" # Quick test during development -quick-test: +quick-test: check-go $(GOTEST) -race ./... # Coverage report -coverage: test +coverage: check-go test $(GOCMD) tool cover -html=coverage.out -o coverage.html @echo "Coverage report: coverage.html" \ No newline at end of file From 119dbe14c489eb43a4bf72d906e1c449af01daf7 Mon Sep 17 00:00:00 2001 From: Jezza Hehn Date: Fri, 22 May 2026 20:51:28 -0400 Subject: [PATCH 2/2] Tweaking golang warning text --- Makefile | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/Makefile b/Makefile index 6fa8494..f817798 100644 --- a/Makefile +++ b/Makefile @@ -30,11 +30,11 @@ check-go: @if ! command -v go >/dev/null 2>&1; then \ echo ""; \ echo " ╭──────────────────────────────────────────────╮"; \ - echo " │ ⚠ Go is not installed on this machine │"; \ + echo " │ ⚠ Go is not installed on this machine! │"; \ echo " ├──────────────────────────────────────────────┤"; \ echo " │ │"; \ - echo " │ obm is a Go project. You need the Go │"; \ - echo " │ toolchain to build from source. │"; \ + echo " │ This is a Go project. You need the │"; \ + echo " │ Go language toolchain to build from source. │"; \ echo " │ │"; \ echo " │ Install Go: │"; \ echo " │ Linux: your package manager │"; \ @@ -44,7 +44,7 @@ check-go: echo " │ │"; \ echo " │ Windows: https://go.dev/dl/ │"; \ echo " │ │"; \ - echo " │ Or use the all-in-one script: │"; \ + echo " │ Or use the obm full install script: │"; \ echo " │ ./scripts/install.sh │"; \ echo " │ │"; \ echo " ╰──────────────────────────────────────────────╯"; \