diff --git a/Makefile b/Makefile index 72ba4cc..7785a3e 100644 --- a/Makefile +++ b/Makefile @@ -1,9 +1,9 @@ .PHONY: * -help: ## This help dialog. +help: @awk 'BEGIN {FS = ":.*?## "} /^[a-zA-Z_-]+:.*?## / {printf "\033[36m%-30s\033[0m %s\n", $$1, $$2 | "sort -u"}' $(MAKEFILE_LIST) -check-docker: ## Verify Docker CLI is available +check-docker: ## Verify Docker CLI available @command -v docker >/dev/null 2>&1 || { \ echo "Error: docker not found."; \ echo "Install Docker Desktop: https://docs.docker.com/desktop/setup/install/mac-install/"; \ @@ -17,20 +17,20 @@ run: check-docker ## Start the application with Docker Compose run-local: ## Start the application locally (without Docker) go run ./cmd/app -down: check-docker ## Stop the application +down: check-docker docker compose down --remove-orphans setup-local: copy-config install-dependencies ## Install config and Go dependencies setup-docker: setup-local run ## Install dependencies and start with Docker Compose -install-lint: ## Install Go lint +install-lint: go install github.com/golangci/golangci-lint/cmd/golangci-lint@latest install-dependencies: ## Install Go project dependencies go mod download -copy-config: ## Copy config file if missing +copy-config: @test -f .env || cp .env.dist .env lint: install-lint ## Run lint diff --git a/bin/server b/bin/server index 4583cc6..7ab2646 100755 Binary files a/bin/server and b/bin/server differ diff --git a/cmd/app/handler/httpjson/handler.go b/cmd/app/handler/handler.go similarity index 98% rename from cmd/app/handler/httpjson/handler.go rename to cmd/app/handler/handler.go index 0581787..c8a491f 100644 --- a/cmd/app/handler/httpjson/handler.go +++ b/cmd/app/handler/handler.go @@ -1,4 +1,4 @@ -package httpjson +package handler import ( "context" diff --git a/cmd/app/handler/httpjson/handler_test.go b/cmd/app/handler/handler_test.go similarity index 99% rename from cmd/app/handler/httpjson/handler_test.go rename to cmd/app/handler/handler_test.go index 3bbd906..6a68858 100644 --- a/cmd/app/handler/httpjson/handler_test.go +++ b/cmd/app/handler/handler_test.go @@ -1,4 +1,4 @@ -package httpjson +package handler import ( "context" diff --git a/cmd/app/handler/httpjson/health.go b/cmd/app/handler/health.go similarity index 93% rename from cmd/app/handler/httpjson/health.go rename to cmd/app/handler/health.go index e5593fb..64ed48d 100644 --- a/cmd/app/handler/httpjson/health.go +++ b/cmd/app/handler/health.go @@ -1,4 +1,4 @@ -package httpjson +package handler import ( "net/http" diff --git a/cmd/app/handler/httpjson/health_test.go b/cmd/app/handler/health_test.go similarity index 97% rename from cmd/app/handler/httpjson/health_test.go rename to cmd/app/handler/health_test.go index 0f30cfc..c7417bf 100644 --- a/cmd/app/handler/httpjson/health_test.go +++ b/cmd/app/handler/health_test.go @@ -1,4 +1,4 @@ -package httpjson +package handler import ( "io" diff --git a/cmd/app/service.go b/cmd/app/service.go index 51850cc..7fcee9e 100644 --- a/cmd/app/service.go +++ b/cmd/app/service.go @@ -3,7 +3,7 @@ package main import ( "context" - "github.com/kjannette/go_http_server/cmd/app/handler/httpjson" + "github.com/kjannette/go_http_server/cmd/app/handler" "github.com/kjannette/go_http_server/internal/config" "go.uber.org/zap" @@ -14,7 +14,7 @@ func run(ctx context.Context, cfg *config.Config) error { lg := zap.L().With(zap.String("app_name", appName), zap.String("app_version", appVersion)) eg, ctx := errgroup.WithContext(ctx) - app, h := httpjson.New(lg) + app, h := handler.New(lg) serverLog := lg.Named("run_server") eg.Go(func() error { diff --git a/internal/config/config.go b/internal/config/config.go index d689e21..b3c5f53 100644 --- a/internal/config/config.go +++ b/internal/config/config.go @@ -5,7 +5,6 @@ import ( "github.com/pkg/errors" ) -// Config represents the application configuration. type Config struct { API struct { Port int `envconfig:"API_PORT" default:"3000"` @@ -16,7 +15,6 @@ type Config struct { } } -// NewConfig creates a new initialised application Config. func NewConfig() (*Config, error) { var config Config diff --git a/pkg/logger/logger.go b/pkg/logger/logger.go index 1b765f3..54fb723 100644 --- a/pkg/logger/logger.go +++ b/pkg/logger/logger.go @@ -8,7 +8,6 @@ import ( "go.uber.org/zap/zapcore" ) -// init initializes zap's global loggers (i.e. zap.L() and zap.S()). // Log level is retrieved from environment variable LOG_LEVEL, defaulting to "info" otherwise. // To activate this facility, add a blank import to this package. func init() {