This commit is contained in:
Dawid Wysokiński 2023-04-07 06:29:37 +02:00
commit 4aec517c74
Signed by: Kichiyaki
GPG Key ID: B5445E357FB8B892
8 changed files with 230 additions and 0 deletions

2
.envrc Normal file
View File

@ -0,0 +1,2 @@
PATH_add bin
export GOBIN=$PWD/bin

25
.gitignore vendored Normal file
View File

@ -0,0 +1,25 @@
# ---> Go
# If you prefer the allow list template instead of the deny list, see community template:
# https://github.com/github/gitignore/blob/main/community/Golang/Go.AllowList.gitignore
#
# Binaries for programs and plugins
*.exe
*.exe~
*.dll
*.so
*.dylib
# Test binary, built with `go test -c`
*.test
# Output of the go coverage tool, specifically when used with LiteIDE
*.out
# Dependency directories (remove the comment below to include it)
# vendor/
# Go workspace file
go.work
.idea
bin

119
.golangci.yml Normal file
View File

@ -0,0 +1,119 @@
run:
tests: true
timeout: 5m
linters:
disable-all: true
enable:
- asasalint
- asciicheck
- bodyclose
- bidichk
- exportloopref
- depguard
- errcheck
- gocritic
- gosec
- gofmt
- goimports
- gosimple
- govet
- ineffassign
- misspell
- nakedret
- prealloc
- staticcheck
- typecheck
- unconvert
- unused
- lll
- nestif
- thelper
- nonamedreturns
- gocyclo
- gomnd
- tenv
- testpackage
- noctx
- tparallel
- usestdlibvars
- unconvert
- makezero
- grouper
- errname
- exhaustive
- tagliatelle
- contextcheck
- gocheckcompilerdirectives
- errname
- forcetypeassert
- durationcheck
- predeclared
- promlinter
- unparam
- wastedassign
- revive
linters-settings:
tagliatelle:
case:
rules:
json: camel
lll:
line-length: 150
gocyclo:
min-complexity: 10
govet:
enable:
- asmdecl
- assign
- atomic
- atomicalign
- bools
- buildtag
- cgocall
- composites
- copylocks
- deepequalerrors
- errorsas
- findcall
- framepointer
- httpresponse
- ifaceassert
- loopclosure
- lostcancel
- nilfunc
- nilness
- printf
- reflectvaluecompare
- shadow
- shift
- sigchanyzer
- sortslice
- stdmethods
- stringintconv
- structtag
- testinggoroutine
- tests
- unmarshal
- unreachable
- unsafeptr
- unusedresult
- unusedwrite
gomnd:
ignored-functions:
- strconv.FormatInt
- strconv.ParseInt
nakedret:
max-func-lines: 1
issues:
exclude-rules:
# Exclude some linters from running on tests files.
- path: _test\.go
linters:
- dupl
- gocyclo
- linters:
- lll
source: "^//go:generate "

11
.pre-commit-config.yaml Normal file
View File

@ -0,0 +1,11 @@
repos:
- repo: https://github.com/alessandrojcm/commitlint-pre-commit-hook
rev: v8.0.0
hooks:
- id: commitlint
stages: [commit-msg]
additional_dependencies: ['@commitlint/config-conventional']
- repo: https://github.com/golangci/golangci-lint
rev: v1.52.2
hooks:
- id: golangci-lint

30
Makefile Normal file
View File

@ -0,0 +1,30 @@
GOOS=$(shell go env GOOS)
GOARCH=$(shell go env GOARCH)
GOBIN=$(shell go env GOBIN)
ifeq ($(GOBIN),)
GOBIN := $(shell go env GOPATH)/bin
endif
OSARCH=$(shell uname -m)
GOLANGCI_LINT_PATH=$(GOBIN)/golangci-lint
.PHONY: install-git-hooks
install-git-hooks:
@echo "Installing git hooks..."
@pre-commit install --hook-type pre-commit
@pre-commit install --hook-type commit-msg
.PHONY: install-golangci-lint
install-golangci-lint:
@echo "Installing github.com/golangci/golangci-lint..."
@test -f $(GOLANGCI_LINT_PATH) || curl -sSfL https://raw.githubusercontent.com/golangci/golangci-lint/master/install.sh | sh -s -- -b $(GOBIN) v1.52.2
.PHONY: install-tools
install-tools: install-golangci-lint
.PHONY: install
install: install-tools install-git-hooks
.PHONY: generate
generate:
@echo "Running go generate..."
@go generate ./...

24
cmd/infakt-cli/main.go Normal file
View File

@ -0,0 +1,24 @@
package main
import (
"log"
"os"
"github.com/urfave/cli/v2"
)
const (
appName = "infakt-cli"
)
func main() {
app := cli.NewApp()
app.Name = appName
app.Usage = "CLI tool for interacting with the InFakt API"
app.HelpName = appName
app.EnableBashCompletion = true
if err := app.Run(os.Args); err != nil {
log.Fatal(err)
}
}

11
go.mod Normal file
View File

@ -0,0 +1,11 @@
module gitea.dwysokinski.me/Kichiyaki/infakt-cli
go 1.20
require github.com/urfave/cli/v2 v2.25.1
require (
github.com/cpuguy83/go-md2man/v2 v2.0.2 // indirect
github.com/russross/blackfriday/v2 v2.1.0 // indirect
github.com/xrash/smetrics v0.0.0-20201216005158-039620a65673 // indirect
)

8
go.sum Normal file
View File

@ -0,0 +1,8 @@
github.com/cpuguy83/go-md2man/v2 v2.0.2 h1:p1EgwI/C7NhT0JmVkwCD2ZBK8j4aeHQX2pMHHBfMQ6w=
github.com/cpuguy83/go-md2man/v2 v2.0.2/go.mod h1:tgQtvFlXSQOSOSIRvRPT7W67SCa46tRHOmNcaadrF8o=
github.com/russross/blackfriday/v2 v2.1.0 h1:JIOH55/0cWyOuilr9/qlrm0BSXldqnqwMsf35Ld67mk=
github.com/russross/blackfriday/v2 v2.1.0/go.mod h1:+Rmxgy9KzJVeS9/2gXHxylqXiyQDYRxCVz55jmeOWTM=
github.com/urfave/cli/v2 v2.25.1 h1:zw8dSP7ghX0Gmm8vugrs6q9Ku0wzweqPyshy+syu9Gw=
github.com/urfave/cli/v2 v2.25.1/go.mod h1:GHupkWPMM0M/sj1a2b4wUrWBPzazNrIjouW6fmdJLxc=
github.com/xrash/smetrics v0.0.0-20201216005158-039620a65673 h1:bAn7/zixMGCfxrRTfdpNzjtPYqr8smhKouy9mxVdGPU=
github.com/xrash/smetrics v0.0.0-20201216005158-039620a65673/go.mod h1:N3UwUGtsrSj3ccvlPHLoLsHnpR27oXr4ZE984MbSER8=