diff --git a/.github/workflows/codeql.yml b/.github/workflows/codeql.yml index 5c29437..4726fe2 100644 --- a/.github/workflows/codeql.yml +++ b/.github/workflows/codeql.yml @@ -29,7 +29,7 @@ jobs: security-events: write steps: - - name: Checkout the repository + name: Code Checkout uses: actions/checkout@v4 with: fetch-depth: 0 @@ -38,9 +38,6 @@ jobs: uses: github/codeql-action/init@v3 with: languages: ${{ matrix.language }} - - - name: Autobuild - uses: github/codeql-action/autobuild@v3 - - + - name: Perform CodeQL Analysis uses: github/codeql-action/analyze@v3 \ No newline at end of file diff --git a/.github/workflows/lint.yml b/.github/workflows/lint.yml index 34d36e6..a7a8ecb 100644 --- a/.github/workflows/lint.yml +++ b/.github/workflows/lint.yml @@ -30,14 +30,14 @@ jobs: go-version: '>=1.23' cache: false - - name: Checkout the repository + name: Code Checkout uses: actions/checkout@v4 with: fetch-depth: 0 - - name: Run golangci-lint + name: golangci-lint uses: golangci/golangci-lint-action@v6 with: - version: v1.61.0 + version: v1.62.2 args: --timeout 5m working-directory: . \ No newline at end of file diff --git a/.github/workflows/test.yml b/.github/workflows/test.yml index 34235c0..8c3e94c 100644 --- a/.github/workflows/test.yml +++ b/.github/workflows/test.yml @@ -20,7 +20,7 @@ jobs: name: Test strategy: matrix: - os: [ubuntu-latest, windows-latest, macOS-12] + os: [ubuntu-latest, windows-latest, macos-latest] runs-on: ${{ matrix.os }} steps: - @@ -29,15 +29,15 @@ jobs: with: go-version: '>=1.23' - - name: Checkout the repository + name: Code Checkout uses: actions/checkout@v4 with: fetch-depth: 0 - - - name: Go modules hygine + - + name: Go Module Management run: | - go clean -modcache - go mod tidy + make go-mod-clean + make go-mod-tidy working-directory: . - name: Go test diff --git a/Makefile b/Makefile index a23a955..dece6fa 100644 --- a/Makefile +++ b/Makefile @@ -1,57 +1,44 @@ -# Set the default shell to `/bin/sh` for executing commands in the Makefile. -# `/bin/sh` is used as it is lightweight and widely available across UNIX systems. SHELL = /bin/sh -# Define the project name for easy reference throughout the Makefile. -# This helps in maintaining a consistent project name and avoiding hardcoding it in multiple places. PROJECT = "hq-go-http" -# --- Prepare | Setup ------------------------------------------------------------------------------- +# ------------------------------------------------------------------------------------------------------------------------------ +# --- Prepare | Setup ---------------------------------------------------------------------------------------------------------- +# ------------------------------------------------------------------------------------------------------------------------------ .PHONY: prepare prepare: @# Install the latest version of Lefthook (a Git hooks manager) and set it up. go install github.com/evilmartians/lefthook@latest && lefthook install -# --- Go(Golang) ------------------------------------------------------------------------------------ +# ------------------------------------------------------------------------------------------------------------------------------ +# --- Go (Golang) -------------------------------------------------------------------------------------------------------------- +# ------------------------------------------------------------------------------------------------------------------------------ -# Define common Go commands with variables for reusability and easier updates. GOCMD=go +GOCLEAN=$(GOCMD) clean GOMOD=$(GOCMD) mod GOGET=$(GOCMD) get GOFMT=$(GOCMD) fmt GOTEST=$(GOCMD) test -# Define Go build flags for verbosity and linking. -# Verbose flag for Go commands, helpful for debugging and understanding output. GOFLAGS := -v -# Linker flags: -# - `-s` removes the symbol table for a smaller binary size. -# - `-w` removes DWARF debugging information. LDFLAGS := -s -w - -# Enable static linking on non-macOS platforms. -# This embeds all dependencies directly into the binary, making it more portable. ifneq ($(shell go env GOOS),darwin) LDFLAGS := -extldflags "-static" endif -# Define Golangci-lint command for linting Go code. GOLANGCILINTCMD=golangci-lint GOLANGCILINTRUN=$(GOLANGCILINTCMD) run -# --- Go Module Management +.PHONY: go-mod-clean +go-mod-clean: + $(GOCLEAN) -modcache -# Tidy Go modules -# This cleans up `go.mod` and `go.sum` by removing unused dependencies -# and ensuring that only the required packages are listed. .PHONY: go-mod-tidy go-mod-tidy: $(GOMOD) tidy -# Update Go modules -# Updates all Go dependencies to their latest versions, including both direct and indirect dependencies. -# Useful for staying up-to-date with upstream changes and bug fixes. .PHONY: go-mod-update go-mod-update: @# Update test dependencies. @@ -59,35 +46,22 @@ go-mod-update: @# Update all other dependencies. $(GOGET) -f -u ./... -# --- Go Code Quality and Testing - -# Format Go code -# Formats all Go source files in the current module according to Go's standard rules. -# Consistent formatting is crucial for code readability and collaboration. .PHONY: go-fmt go-fmt: $(GOFMT) ./... -# Lint Go code -# Runs static analysis checks on the Go code using Golangci-lint. -# Ensures the code adheres to best practices and is free from common issues. -# This target also runs `go-fmt` beforehand to ensure the code is formatted. .PHONY: go-lint go-lint: go-fmt $(GOLANGCILINTRUN) $(GOLANGCILINT) ./... -# Run Go tests -# Executes all unit tests in the module with detailed output. -# The `GOFLAGS` variable is used to enable verbosity, making it easier to debug test results. .PHONY: go-test go-test: $(GOTEST) $(GOFLAGS) ./... -# --- Help ----------------------------------------------------------------------------------------- +# ------------------------------------------------------------------------------------------------------------------------------ +# --- Help --------------------------------------------------------------------------------------------------------------------- +# ------------------------------------------------------------------------------------------------------------------------------ -# Display help information -# This target prints out a detailed list of all available Makefile commands for ease of use. -# It's a helpful reference for developers using the Makefile. .PHONY: help help: @echo "" @@ -103,6 +77,7 @@ help: @echo " prepare .................. prepare repository." @echo "" @echo " Go Commands:" + @echo " go-mod-clean ............. Clean Go module cache." @echo " go-mod-tidy .............. Tidy Go modules." @echo " go-mod-update ............ Update Go modules." @echo " go-fmt ................... Format Go code." @@ -113,6 +88,4 @@ help: @echo " help ..................... Display this help information" @echo "" -# Set the default goal to `help`. -# This ensures that running `make` without arguments will display the help information. .DEFAULT_GOAL = help \ No newline at end of file diff --git a/go.mod b/go.mod index 27be8f9..873e026 100644 --- a/go.mod +++ b/go.mod @@ -3,9 +3,9 @@ module github.com/hueristiq/hq-go-http go 1.23.3 require ( - github.com/hueristiq/hq-go-retrier v0.0.0-20241130122723-f060264d9262 + github.com/hueristiq/hq-go-retrier v0.0.0-20241212101846-4c0fbd2c56da github.com/hueristiq/hqgoutils v0.0.0-20231024005153-bd2c47932440 - golang.org/x/net v0.31.0 + golang.org/x/net v0.32.0 ) -require golang.org/x/text v0.20.0 // indirect +require golang.org/x/text v0.21.0 // indirect diff --git a/go.sum b/go.sum index ac07d6e..cc0bc5f 100644 --- a/go.sum +++ b/go.sum @@ -1,9 +1,7 @@ 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/hueristiq/hq-go-retrier v0.0.0-20241124123316-75e4987d3cb6 h1:MrT8DTES74Y5l79N6PPPg3q/GbHQWQcats76FBs6Er0= -github.com/hueristiq/hq-go-retrier v0.0.0-20241124123316-75e4987d3cb6/go.mod h1:1SITeMGkM7cJh41P9zMoXqbp5h8fxlF9nuPdynkwjjI= -github.com/hueristiq/hq-go-retrier v0.0.0-20241130122723-f060264d9262 h1:mEJOmRcl2l0mDrk6pwLSYTrcLXWlAGsGMEQGMtcc/C8= -github.com/hueristiq/hq-go-retrier v0.0.0-20241130122723-f060264d9262/go.mod h1:0gJoaPQEgXzuXWxqGS8eMQarow9FFjRuL/zyeTZPyuw= +github.com/hueristiq/hq-go-retrier v0.0.0-20241212101846-4c0fbd2c56da h1:9HW9SELNqQiGHyqZ7XeFoyKVRVMSoosxVNlBqc6AsRk= +github.com/hueristiq/hq-go-retrier v0.0.0-20241212101846-4c0fbd2c56da/go.mod h1:0gJoaPQEgXzuXWxqGS8eMQarow9FFjRuL/zyeTZPyuw= github.com/hueristiq/hqgoutils v0.0.0-20231024005153-bd2c47932440 h1:dpHAa9c74HgAXkZ2WPd84q2cCiF76eluuSGRw7bk7To= github.com/hueristiq/hqgoutils v0.0.0-20231024005153-bd2c47932440/go.mod h1:NlZ117o///yWDbRAbgYD7/Y44qce8z1Dj4caUsjunSY= github.com/pmezard/go-difflib v1.0.0 h1:4DBwDE0NGyQoBHbLQYPwSUPoCMWR5BEzIk/f1lZbAQM= @@ -12,9 +10,9 @@ github.com/stretchr/objx v0.5.2 h1:xuMeJ0Sdp5ZMRXx/aWO6RZxdr3beISkG5/G/aIRr3pY= github.com/stretchr/objx v0.5.2/go.mod h1:FRsXN1f5AsAjCGJKqEizvkpNtU+EGNCLh3NxZ/8L+MA= github.com/stretchr/testify v1.10.0 h1:Xv5erBjTwe/5IxqUQTdXv5kgmIvbHo3QQyRwhJsOfJA= github.com/stretchr/testify v1.10.0/go.mod h1:r2ic/lqez/lEtzL7wO/rwa5dbSLXVDPFyf8C91i36aY= -golang.org/x/net v0.31.0 h1:68CPQngjLL0r2AlUKiSxtQFKvzRVbnzLwMUn5SzcLHo= -golang.org/x/net v0.31.0/go.mod h1:P4fl1q7dY2hnZFxEk4pPSkDHF+QqjitcnDjUQyMM+pM= -golang.org/x/text v0.20.0 h1:gK/Kv2otX8gz+wn7Rmb3vT96ZwuoxnQlY+HlJVj7Qug= -golang.org/x/text v0.20.0/go.mod h1:D4IsuqiFMhST5bX19pQ9ikHC2GsaKyk/oF+pn3ducp4= +golang.org/x/net v0.32.0 h1:ZqPmj8Kzc+Y6e0+skZsuACbx+wzMgo5MQsJh9Qd6aYI= +golang.org/x/net v0.32.0/go.mod h1:CwU0IoeOlnQQWJ6ioyFrfRuomB8GKF6KbYXZVyeXNfs= +golang.org/x/text v0.21.0 h1:zyQAAkrwaneQ066sspRyJaG9VNi/YJ1NfzcGB3hZ/qo= +golang.org/x/text v0.21.0/go.mod h1:4IBbMaMmOPCJ8SecivzSH54+73PCFmPWxNTLm+vZkEQ= gopkg.in/yaml.v3 v3.0.1 h1:fxVm/GzAzEWqLHuvctI91KS9hhNmmWOoWu0XTYJS7CA= gopkg.in/yaml.v3 v3.0.1/go.mod h1:K4uyk7z7BCEPqu6E+C64Yfv1cQ7kz7rIZviUmN+EgEM=