From bfa9f9dd79b45e9ef3a8150f167a74d272470af8 Mon Sep 17 00:00:00 2001 From: "Urko." Date: Thu, 22 Feb 2024 18:59:28 +0100 Subject: [PATCH] feat: add makefile --- .gitignore | 3 ++- Makefile | 59 ++++++++++++++++++++++++++++++++++++++++++++++++ cmd/http/main.go | 4 +++- go.mod | 2 +- 4 files changed, 65 insertions(+), 3 deletions(-) create mode 100644 Makefile diff --git a/.gitignore b/.gitignore index 627e865..297bf68 100644 --- a/.gitignore +++ b/.gitignore @@ -2,4 +2,5 @@ .vscode coverage .notes -uploads \ No newline at end of file +uploads +bin \ No newline at end of file diff --git a/Makefile b/Makefile new file mode 100644 index 0000000..dcc3c5a --- /dev/null +++ b/Makefile @@ -0,0 +1,59 @@ +COVERAGE_DIR := coverage +BIN_DIR := ./bin +MAIN := ./cmd/http/main.go +APP_NAME := prosody_password + +lint: + golangci-lint run ./... +goreportcard: + goreportcard-cli -v +test: + go test ./... +test-coverage: + rm -rf ${COVERAGE_DIR} + mkdir ${COVERAGE_DIR} + go test -v -coverprofile ${COVERAGE_DIR}/cover.out ./... + go tool cover -html ${COVERAGE_DIR}/cover.out -o ${COVERAGE_DIR}/cover.html + + +.PHONY: local_run +local_run: + go run ./cmd/main.go --dir "$(DIR)" --bucket "$(BUCKET)" + +.PHONY: build_linux_amd64 +build_linux_amd64: + @mkdir -p $(BIN_DIR) + GOOS=linux GOARCH=amd64 go build -o $(BIN_DIR)/$(APP_NAME)_linux_amd64 $(MAIN) + +.PHONY: build_linux_arm64 +build_linux_arm64: + @mkdir -p $(BIN_DIR) + GOOS=linux GOARCH=arm64 go build -o $(BIN_DIR)/$(APP_NAME)_linux_arm64 $(MAIN) + +.PHONY: build_windows_amd64 +build_windows_amd64: + @mkdir -p $(BIN_DIR) + GOOS=windows GOARCH=amd64 go build -o $(BIN_DIR)/$(APP_NAME)_windows_amd64.exe $(MAIN) + +.PHONY: build_windows_386 +build_windows_386: + @mkdir -p $(BIN_DIR) + GOOS=windows GOARCH=386 go build -o $(BIN_DIR)/$(APP_NAME)_windows_386.exe $(MAIN) + +.PHONY: build_mac_amd64 +build_mac_amd64: + @mkdir -p $(BIN_DIR) + GOOS=darwin GOARCH=amd64 go build -o $(BIN_DIR)/$(APP_NAME)_mac_amd64 $(MAIN) + +.PHONY: build_mac_arm64 +build_mac_arm64: + @mkdir -p $(BIN_DIR) + GOOS=darwin GOARCH=arm64 go build -o $(BIN_DIR)/$(APP_NAME)_mac_arm64 $(MAIN) + +.PHONY: clean +clean: + rm -rf $(BIN_DIR) + +.PHONY: rebuild +#rebuild: clean build_linux_amd64 build_linux_arm64 build_windows_amd64 build_windows_386 build_mac_amd64 build_mac_arm64 +rebuild: clean build_linux_amd64 build_windows_amd64 build_windows_386 build_mac_amd64 diff --git a/cmd/http/main.go b/cmd/http/main.go index 1d651c2..e6cff82 100644 --- a/cmd/http/main.go +++ b/cmd/http/main.go @@ -36,7 +36,9 @@ func main() { log.Println("on shutdown") if restServer != nil { - restServer.Shutdown() + if err := restServer.Shutdown(); err != nil { + panic(err) + } } log.Println("gracefully shutdown") diff --git a/go.mod b/go.mod index 2b3576f..36361b5 100644 --- a/go.mod +++ b/go.mod @@ -1,6 +1,6 @@ module gitea.urkob.com/urko/prosody-password -go 1.20 +go 1.22 require ( gitea.urkob.com/urko/go-root-dir v0.0.0-20230311113851-2f6d4355888a