# https://taskfile.dev version: "3" vars: COV_DATA: coverage.out tasks: default: desc: List all available tasks silent: true cmds: - task --list tidy: desc: Tidy dependencies in go.mod and go.sum sources: - "**/*.go" - go.mod - go.sum cmds: - go mod tidy fmt: desc: Run go fmt on all source files sources: - "**/*.go" preconditions: - sh: command -v golines msg: golines not installed, run `go install github.com/segmentio/golines@latest` - sh: command -v gofumpt msg: requires gofumpt, run `go install mvdan.cc/gofumpt@latest` cmds: - gofumpt -w -extra . - golines . --ignore-generated --write-output test: desc: Run the test suite sources: - "**/*.go" cmds: - go test -race -cover ./... {{ .CLI_ARGS }} bench: desc: Run all project benchmarks sources: - "**/*.go" cmds: - go test ./... -run None -benchmem -bench . {{ .CLI_ARGS }} lint: desc: Run the linters and auto-fix if possible sources: - "**/*.go" - .golangci.yml deps: - fmt preconditions: - sh: command -v golangci-lint msg: golangci-lint not installed, see https://golangci-lint.run/usage/install/#local-installation - sh: command -v betteralign msg: requires betteralign, run `go install github.com/dkorunic/betteralign/cmd/betteralign@latest` - sh: command -v typos msg: requires typos-cli, run `brew install typos-cli` cmds: - betteralign -test_files -apply ./... - golangci-lint run --fix - typos doc: desc: Render the pkg docs locally cmds: - pkgsite -open preconditions: - sh: command -v pkgsite msg: pkgsite not installed, run `go install golang.org/x/pkgsite/cmd/pkgsite@latest` cov: desc: Calculate test coverage and render the html generates: - "{{ .COV_DATA }}" cmds: - go test -race -cover -covermode atomic -coverprofile {{ .COV_DATA }} ./... - go tool cover -html {{ .COV_DATA }} check: desc: Run tests and linting in one cmds: - task: test - task: lint sloc: desc: Print lines of code cmds: - fd . -e go | xargs wc -l | sort -nr | head clean: desc: Remove build artifacts and other clutter cmds: - go clean ./... - rm -rf {{ .COV_DATA }} update: desc: Updates dependencies in go.mod and go.sum cmds: - go get -u ./... - go mody tidy