diff --git a/.gitignore b/.gitignore index 66fd13c..c558527 100644 --- a/.gitignore +++ b/.gitignore @@ -13,3 +13,11 @@ # Dependency directories (remove the comment below to include it) # vendor/ + +# IDE +.idea +.vscode + +# coverage +coverage.txt +coverage.html \ No newline at end of file diff --git a/.golangci.yml b/.golangci.yml new file mode 100644 index 0000000..79702d9 --- /dev/null +++ b/.golangci.yml @@ -0,0 +1,59 @@ +# This file contains all available configuration options +# with their default values. + +# options for analysis running +run: + # timeout for analysis, e.g. 30s, 5m, default is 1m + timeout: 5m + + # include test files or not, default is true + tests: true + +# output configuration options +output: + # colored-line-number|line-number|json|tab|checkstyle|code-climate, default is "colored-line-number" + format: tab + +# all available settings of specific linters +linters-settings: + exhaustive: + # indicates that switch statements are to be considered exhaustive if a + # 'default' case is present, even if all enum members aren't listed in the + # switch + default-signifies-exhaustive: true + govet: + # report about shadowed variables + check-shadowing: false + +linters: + enable: + # mandatory linters + - govet + - golint + + # some default golangci-lint linters + - deadcode + - errcheck + - gosimple + - ineffassign + - staticcheck + - structcheck + - typecheck + - unused + - varcheck + + # extra linters + - exhaustive + - godot + - gofmt + - whitespace + - goimports + disable-all: true + fast: false + +issues: + include: + - EXC0002 # should have a comment + - EXC0003 # test/Test ... consider calling this + - EXC0004 # govet + - EXC0005 # C-style breaks diff --git a/Makefile b/Makefile new file mode 100644 index 0000000..61bdecf --- /dev/null +++ b/Makefile @@ -0,0 +1,40 @@ +#!/usr/bin/make -f + +# Run tests +test: + @go test ./... -cover + +# Pull go dependencies +dep: + @printf "⇒ Download requirements: " + @CGO_ENABLED=0 \ + go mod download && echo OK + @printf "⇒ Tidy requirements: " + @CGO_ENABLED=0 \ + go mod tidy -v && echo OK + +# Run linters +lint: + @golangci-lint --timeout=5m run + +# Run tests with race detection and produce coverage output +cover: + @go test -v -race ./... -coverprofile=coverage.txt -covermode=atomic + @go tool cover -html=coverage.txt -o coverage.html + +# Reformat code +format: + @echo "⇒ Processing gofmt check" + @gofmt -s -w ./ + @echo "⇒ Processing goimports check" + @goimports -w ./ + +# Show this help prompt +help: + @echo ' Usage:' + @echo '' + @echo ' make ' + @echo '' + @echo ' Targets:' + @echo '' + @awk '/^#/{ comment = substr($$0,3) } comment && /^[a-zA-Z][a-zA-Z0-9_-]+ ?:/{ print " ", $$1, comment }' $(MAKEFILE_LIST) | column -t -s ':' | grep -v 'IGNORE' | sort -u \ No newline at end of file diff --git a/go.mod b/go.mod new file mode 100644 index 0000000..bad5cc6 --- /dev/null +++ b/go.mod @@ -0,0 +1,9 @@ +module github.com/nspcc-dev/neofs-sdk-go + +go 1.16 + +require ( + github.com/alecthomas/participle v0.7.1 + github.com/nspcc-dev/neofs-api-go v1.26.1 + github.com/stretchr/testify v1.6.1 +) diff --git a/go.sum b/go.sum new file mode 100644 index 0000000..b81a708 Binary files /dev/null and b/go.sum differ