Skip to content

Commit

Permalink
chore(*): -
Browse files Browse the repository at this point in the history
  • Loading branch information
enenumxela committed Dec 12, 2024
1 parent 8f3fcd1 commit 445872d
Show file tree
Hide file tree
Showing 6 changed files with 28 additions and 67 deletions.
7 changes: 2 additions & 5 deletions .github/workflows/codeql.yml
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@ jobs:
security-events: write
steps:
-
name: Checkout the repository
name: Code Checkout
uses: actions/checkout@v4
with:
fetch-depth: 0
Expand All @@ -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
6 changes: 3 additions & 3 deletions .github/workflows/lint.yml
Original file line number Diff line number Diff line change
Expand Up @@ -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: .
12 changes: 6 additions & 6 deletions .github/workflows/test.yml
Original file line number Diff line number Diff line change
Expand Up @@ -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:
-
Expand All @@ -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
Expand Down
60 changes: 14 additions & 46 deletions Makefile
Original file line number Diff line number Diff line change
@@ -1,102 +1,71 @@
# 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-url"

# --- 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.
$(GOGET) -f -t -u ./...
@# Update all other dependencies.
$(GOGET) -f -u ./...

# --- Go Code Generation

# Run Go generate
# This target runs go generate ./..., which will process any //go:generate directives found in your Go source files.
# The ./... pattern ensures that the command is run on all packages within the module.
.PHONY: go-generate
go-generate:
$(GOCMD) generate ./...

# --- 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 ""
Expand All @@ -112,6 +81,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-generate .............. Run Go generate."
Expand All @@ -123,6 +93,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
2 changes: 2 additions & 0 deletions schemes/schemes_official.go
Original file line number Diff line number Diff line change
Expand Up @@ -342,6 +342,8 @@ var Official = []string{
"tag",
"taler",
"teamspeak",
"teapot",
"teapots",
"tel",
"teliaeid",
"telnet",
Expand Down
8 changes: 1 addition & 7 deletions tlds/tlds_official.go
Original file line number Diff line number Diff line change
Expand Up @@ -499,7 +499,6 @@ var Official = []string{
"beer",
"beiarn.no",
"bel.tr",
"belau.pw",
"belem.br",
"belluno.it",
"benevento.it",
Expand Down Expand Up @@ -974,7 +973,6 @@ var Official = []string{
"co.nz",
"co.om",
"co.pn",
"co.pw",
"co.rs",
"co.rw",
"co.ss",
Expand Down Expand Up @@ -1358,7 +1356,6 @@ var Official = []string{
"ed.ci",
"ed.cr",
"ed.jp",
"ed.pw",
"edeka",
"edogawa.tokyo.jp",
"edu",
Expand Down Expand Up @@ -1596,7 +1593,6 @@ var Official = []string{
"fauske.no",
"fc.it",
"fe.it",
"fed.us",
"federation.aero",
"fedex",
"fedje.no",
Expand Down Expand Up @@ -1890,7 +1886,6 @@ var Official = []string{
"go.jp",
"go.ke",
"go.kr",
"go.pw",
"go.th",
"go.tj",
"go.tz",
Expand Down Expand Up @@ -2042,6 +2037,7 @@ var Official = []string{
"gov.pr",
"gov.ps",
"gov.pt",
"gov.pw",
"gov.py",
"gov.qa",
"gov.rs",
Expand Down Expand Up @@ -2958,7 +2954,6 @@ var Official = []string{
"kia",
"kibichuo.okayama.jp",
"kids",
"kids.us",
"kiengiang.vn",
"kiev.ua",
"kiho.mie.jp",
Expand Down Expand Up @@ -4469,7 +4464,6 @@ var Official = []string{
"or.ke",
"or.kr",
"or.mu",
"or.pw",
"or.th",
"or.tz",
"or.ug",
Expand Down

0 comments on commit 445872d

Please sign in to comment.