diff --git a/.github/workflows/test.yml b/.github/workflows/test.yml new file mode 100644 index 0000000..8e8ca86 --- /dev/null +++ b/.github/workflows/test.yml @@ -0,0 +1,26 @@ +name: Go +on: + push: + branches: ["master"] + pull_request: + branches: ["master"] + +jobs: + build: + runs-on: ubuntu-latest + + steps: + - uses: actions/checkout@v5 + + - name: Setup Go + uses: actions/setup-go@v5 + with: + go-version: '1.25.x' + + - name: Install golangci-lint + run: | + curl -sSfL https://raw.githubusercontent.com/golangci/golangci-lint/HEAD/install.sh \ + | sh -s -- -b $(go env GOPATH)/bin v2.5.0 + + - name: Test + run: make all diff --git a/.golangci.yml b/.golangci.yml new file mode 100644 index 0000000..184edbb --- /dev/null +++ b/.golangci.yml @@ -0,0 +1,43 @@ +version: "2" + +run: + timeout: 5m + allow-parallel-runners: true + relative-path-mode: cfg + +linters: + default: none + enable: + - dupl + - errcheck + - copyloopvar + - ginkgolinter + - goconst + - gocyclo + - govet + - ineffassign + - misspell + - nakedret + - unconvert + - unparam + - unused + - staticcheck + disable: + - prealloc + - revive + + settings: + revive: + rules: + - name: comment-spacings + +formatters: + enable: + - gofmt + - goimports + # example settings for formatters; remove if unused + settings: + gofmt: + simplify: true + +issues: {} \ No newline at end of file diff --git a/.tool-versions b/.tool-versions new file mode 100644 index 0000000..db88104 --- /dev/null +++ b/.tool-versions @@ -0,0 +1,2 @@ +golang 1.25.1 +golangci-lint 2.5.0 \ No newline at end of file diff --git a/Makefile b/Makefile new file mode 100644 index 0000000..3335754 --- /dev/null +++ b/Makefile @@ -0,0 +1,44 @@ +##@ General + +# The help target prints out all targets with their descriptions organized +# beneath their categories. The categories are represented by '##@' and the +# target descriptions by '##'. The awk command is responsible for reading the +# entire set of makefiles included in this invocation, looking for lines of the +# file as xyz: ## something, and then pretty-format the target and help. Then, +# if there's a line with ##@ something, that gets pretty-printed as a category. +# More info on the usage of ANSI control characters for terminal formatting: +# https://en.wikipedia.org/wiki/ANSI_escape_code#SGR_parameters +# More info on the awk command: +# http://linuxcommand.org/lc3_adv_awk.php + +.PHONY: help +help: ## Display this help. + @awk 'BEGIN {FS = ":.*##"; printf "\nUsage:\n make \033[36m\033[0m\n"} /^[a-zA-Z_0-9-]+:.*?##/ { printf " \033[36m%-15s\033[0m %s\n", $$1, $$2 } /^##@/ { printf "\n\033[1m%s\033[0m\n", substr($$0, 5) } ' $(MAKEFILE_LIST) + +.PHONY: all +all: fmt vet lint test + +##@ Development +.PHONY: fmt +fmt: ## Run go fmt against code. + go fmt ./... + +.PHONY: vet +vet: ## Run go vet against code. + go vet ./... + +.PHONY: lint +lint: ## Run linter + golangci-lint run + +.PHONY: lint-fix +lint-fix: ## Run linter and fix issues + golangci-lint run --fix + +.PHONY: test +test: ## Run project tests + go test ./... + +.PHONY: benchmark +benchmark: ## Run project benchmarks + go test -bench=. -benchtime=10000x -benchmem ./... \ No newline at end of file