From a95a5ca5211fc8d1a306260d65bb90688b492438 Mon Sep 17 00:00:00 2001 From: ericprd Date: Sun, 23 Feb 2025 13:04:30 +0800 Subject: [PATCH] fix: cannot run main app --- .gitignore | 1 + cmd/legalgo/main.go | 7 +++++-- go.mod | 1 + go.sum | 2 ++ makefile | 18 ++++++++++++++++-- 5 files changed, 25 insertions(+), 4 deletions(-) create mode 100644 .gitignore diff --git a/.gitignore b/.gitignore new file mode 100644 index 0000000..ba077a4 --- /dev/null +++ b/.gitignore @@ -0,0 +1 @@ +bin diff --git a/cmd/legalgo/main.go b/cmd/legalgo/main.go index ce4e38e..b659595 100644 --- a/cmd/legalgo/main.go +++ b/cmd/legalgo/main.go @@ -3,12 +3,15 @@ package main import ( internalhttp "github.com/ardeman/project-legalgo-go/internal/api/http" pkgconfig "github.com/ardeman/project-legalgo-go/internal/config" + "github.com/go-chi/chi/v5" "go.uber.org/fx" ) func main() { fx.New( - fx.Provide(internalhttp.Module), - fx.Invoke(pkgconfig.Router), + internalhttp.Module, + fx.Invoke(func(apiRouter chi.Router) { + pkgconfig.Router(apiRouter) + }), ) } diff --git a/go.mod b/go.mod index adeacf5..b8d367d 100644 --- a/go.mod +++ b/go.mod @@ -10,6 +10,7 @@ require ( require ( github.com/cespare/xxhash/v2 v2.3.0 // indirect github.com/dgryski/go-rendezvous v0.0.0-20200823014737-9f7001d12a5f // indirect + github.com/go-chi/chi v1.5.5 github.com/go-chi/chi/v5 v5.2.1 // indirect github.com/go-chi/cors v1.2.1 github.com/redis/go-redis/v9 v9.7.1 // indirect diff --git a/go.sum b/go.sum index 9856691..dc119d8 100644 --- a/go.sum +++ b/go.sum @@ -5,6 +5,8 @@ github.com/davecgh/go-spew v1.1.1 h1:vj9j/u1bqnvCEfJOwUhtlOARqs3+rkHYY13jYWTU97c github.com/davecgh/go-spew v1.1.1/go.mod h1:J7Y8YcW2NihsgmVo/mv3lAwl/skON4iLHjSsI+c5H38= github.com/dgryski/go-rendezvous v0.0.0-20200823014737-9f7001d12a5f h1:lO4WD4F/rVNCu3HqELle0jiPLLBs70cWOduZpkS1E78= github.com/dgryski/go-rendezvous v0.0.0-20200823014737-9f7001d12a5f/go.mod h1:cuUVRXasLTGF7a8hSLbxyZXjz+1KgoB3wDUb6vlszIc= +github.com/go-chi/chi v1.5.5 h1:vOB/HbEMt9QqBqErz07QehcOKHaWFtuj87tTDVz2qXE= +github.com/go-chi/chi v1.5.5/go.mod h1:C9JqLr3tIYjDOZpzn+BCuxY8z8vmca43EeMgyZt7irw= github.com/go-chi/chi/v5 v5.2.1 h1:KOIHODQj58PmL80G2Eak4WdvUzjSJSm0vG72crDCqb8= github.com/go-chi/chi/v5 v5.2.1/go.mod h1:L2yAIGWB3H+phAw1NxKwWM+7eUH/lU8pOMm5hHcoops= github.com/go-chi/cors v1.2.1 h1:xEC8UT3Rlp2QuWNEr4Fs/c2EAGVKBwy/1vHx3bppil4= diff --git a/makefile b/makefile index 6acd759..cad3fa8 100644 --- a/makefile +++ b/makefile @@ -1,2 +1,16 @@ -test: - echo "Hello world" \ No newline at end of file +BINARY_NAME=./cmd/legalgo/main.go +OUTPUT_DIR=./bin/legalgo + +all: build + +build: + @echo "Building the Go project..." + go build -o $(OUTPUT_DIR) $(BINARY_NAME) + +run: build + @echo "Building and running..." + $(OUTPUT_DIR) + +clean: + @echo "Cleaning the build..." + rm -f $(OUTPUT_DIR)