Skip to content

Instantly share code, notes, and snippets.

@jtprogru
Last active June 22, 2023 20:35
Show Gist options
  • Save jtprogru/59e4a634725f68bda83c29ce677b73e0 to your computer and use it in GitHub Desktop.
Save jtprogru/59e4a634725f68bda83c29ce677b73e0 to your computer and use it in GitHub Desktop.
Simple task file for Golang project
# yaml-language-server: $schema=https://taskfile.dev/schema.json
---
version: "3"
set:
- pipefail
silent: false
tasks:
default:
silent: true
cmds:
- task --list --color
prec:
desc: Preconditions for project
preconditions:
- test -f init.sql
- test -f $(which docker)
- test -f .golangci.yaml
- test -f $(which golangci-lint)
- test -f $(which goimports)
- test -f $(which gofmt)
- test -f $(which go)
- test -f go.mod
- test -f go.sum
- test -d dist || mkdir dist
tidy:
desc: Install all dependencies
deps:
- prec
cmds:
- go mod tidy
runcmd:
desc: Run like go run main.go
deps:
- prec
cmds:
- go run ./cmd/gonewszer/main.go
fmt:
desc: Run go fmt
deps:
- prec
cmds:
- gofmt -s -w .
goimports:
desc: Run goimports
deps:
- prec
cmds:
- goimports -w -e -l -v .
vet:
desc: Run go vet
deps:
- prec
cmds:
- go vet ./...
test:
desc: Run tests without caching
deps:
- prec
preconditions:
- go clean -testcache
cmds:
- go test ./...
lint:
desc: Run golangci-lint
deps:
- prec
cmds:
- golangci-lint -v run --out-format=colored-line-number --fix --config .golangci.yaml ./...
rundc:
desc: Run docker compose
deps:
- prec
cmds:
- docker compose -f docker-compose.local.yaml up -d
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment