diff --git a/.gitignore b/.gitignore index af54975..080767e 100644 --- a/.gitignore +++ b/.gitignore @@ -1,2 +1,4 @@ +bin/ +vendor/ .envrc .tool-versions diff --git a/.rules/.golangci.yml b/.rules/.golangci.yml new file mode 100644 index 0000000..0597b06 --- /dev/null +++ b/.rules/.golangci.yml @@ -0,0 +1,509 @@ +# This file contains all available configuration options +# with their default values (in comments). + +# Options for analysis running. +run: + timeout: 5m + skip-files: + - ".*\\.gen\\.go$" + modules-download-mode: readonly + +# output configuration options +output: + sort-results: true + +linters: + # Enable all available linters. + # Default: false + enable-all: true + # Disable specific linter + # https://golangci-lint.run/usage/linters/#disabled-by-default-linters--e--enable + disable: + # deprecated + - deadcode + - exhaustivestruct + - golint + - ifshort + - interfacer + - maligned + - scopelint + - varcheck + # unused + # TBD + +linters-settings: + decorder: + disable-init-func-first-check: false + errcheck: + check-type-assertions: true + check-blank: true + disable-default-exclusions: false + exclude-functions: [] + errchkjson: + check-error-free-encoding: false + report-no-exported: true + exhaustive: + check-generated: true + default-signifies-exhaustive: true + godot: + scope: all + exclude: + - "^fixme:" + - "^todo:" + capital: true + period: true + gofumpt: + lang-version: "1.19" + extra-rules: true + goimports: + local-prefixes: github.com/omissis + govet: + check-shadowing: true + grouper: + const-require-single-const: true + const-require-grouping: false + import-require-single-import: true + import-require-grouping: false + var-require-single-var: true + var-require-grouping: false + nolintlint: + require-explanation: true + require-specific: true + revive: + enable-all-rules: true + rules: + # https://github.com/mgechev/revive/blob/master/RULES_DESCRIPTIONS.md#add-constant + - name: add-constant + severity: warning + disabled: false + arguments: + - maxLitCount: "3" + allowStrs: '""' + allowInts: "0,1,2" + allowFloats: "0.0,0.,1.0,1.,2.0,2." + # https://github.com/mgechev/revive/blob/master/RULES_DESCRIPTIONS.md#argument-limit + - name: argument-limit + severity: warning + disabled: false + arguments: [4] + # https://github.com/mgechev/revive/blob/master/RULES_DESCRIPTIONS.md#atomic + - name: atomic + severity: warning + disabled: false + # https://github.com/mgechev/revive/blob/master/RULES_DESCRIPTIONS.md#banned-characters + - name: banned-characters + severity: warning + disabled: false + arguments: ["Ω", "Σ", "σ", "7"] + # https://github.com/mgechev/revive/blob/master/RULES_DESCRIPTIONS.md#bare-return + - name: bare-return + severity: warning + disabled: false + # https://github.com/mgechev/revive/blob/master/RULES_DESCRIPTIONS.md#blank-imports + - name: blank-imports + severity: warning + disabled: false + # https://github.com/mgechev/revive/blob/master/RULES_DESCRIPTIONS.md#bool-literal-in-expr + - name: bool-literal-in-expr + severity: warning + disabled: false + # https://github.com/mgechev/revive/blob/master/RULES_DESCRIPTIONS.md#call-to-gc + - name: call-to-gc + severity: warning + disabled: false + # https://github.com/mgechev/revive/blob/master/RULES_DESCRIPTIONS.md#cognitive-complexity + - name: cognitive-complexity + severity: warning + disabled: false + arguments: [7] + # https://github.com/mgechev/revive/blob/master/RULES_DESCRIPTIONS.md#confusing-naming + - name: confusing-naming + severity: warning + disabled: false + # https://github.com/mgechev/revive/blob/master/RULES_DESCRIPTIONS.md#confusing-results + - name: confusing-results + severity: warning + disabled: false + # https://github.com/mgechev/revive/blob/master/RULES_DESCRIPTIONS.md#constant-logical-expr + - name: constant-logical-expr + severity: warning + disabled: false + # https://github.com/mgechev/revive/blob/master/RULES_DESCRIPTIONS.md#context-as-argument + - name: context-as-argument + severity: warning + disabled: false + # https://github.com/mgechev/revive/blob/master/RULES_DESCRIPTIONS.md#context-keys-type + - name: context-keys-type + severity: warning + disabled: false + # https://github.com/mgechev/revive/blob/master/RULES_DESCRIPTIONS.md#cyclomatic + - name: cyclomatic + severity: warning + disabled: false + arguments: [3] + # https://github.com/mgechev/revive/blob/master/RULES_DESCRIPTIONS.md#datarace + - name: datarace + severity: warning + disabled: false + # https://github.com/mgechev/revive/blob/master/RULES_DESCRIPTIONS.md#deep-exit + - name: deep-exit + severity: warning + disabled: false + # https://github.com/mgechev/revive/blob/master/RULES_DESCRIPTIONS.md#defer + - name: defer + severity: warning + disabled: false + arguments: + - ["call-chain", "loop"] + # https://github.com/mgechev/revive/blob/master/RULES_DESCRIPTIONS.md#dot-imports + - name: dot-imports + severity: warning + disabled: false + # https://github.com/mgechev/revive/blob/master/RULES_DESCRIPTIONS.md#duplicated-imports + - name: duplicated-imports + severity: warning + disabled: false + # https://github.com/mgechev/revive/blob/master/RULES_DESCRIPTIONS.md#early-return + - name: early-return + severity: warning + disabled: false + # https://github.com/mgechev/revive/blob/master/RULES_DESCRIPTIONS.md#empty-block + - name: empty-block + severity: warning + disabled: false + # https://github.com/mgechev/revive/blob/master/RULES_DESCRIPTIONS.md#empty-lines + - name: empty-lines + severity: warning + disabled: false + # https://github.com/mgechev/revive/blob/master/RULES_DESCRIPTIONS.md#error-naming + - name: error-naming + severity: warning + disabled: false + # https://github.com/mgechev/revive/blob/master/RULES_DESCRIPTIONS.md#error-return + - name: error-return + severity: warning + disabled: false + # https://github.com/mgechev/revive/blob/master/RULES_DESCRIPTIONS.md#error-strings + - name: error-strings + severity: warning + disabled: false + # https://github.com/mgechev/revive/blob/master/RULES_DESCRIPTIONS.md#errorf + - name: errorf + severity: warning + disabled: false + # https://github.com/mgechev/revive/blob/master/RULES_DESCRIPTIONS.md#exported + - name: exported + severity: warning + disabled: false + arguments: + - "checkPrivateReceivers" + - "sayRepetitiveInsteadOfStutters" + # https://github.com/mgechev/revive/blob/master/RULES_DESCRIPTIONS.md#file-header + - name: file-header + severity: warning + disabled: false + arguments: + - This is the text that must appear at the top of source files. + # https://github.com/mgechev/revive/blob/master/RULES_DESCRIPTIONS.md#flag-parameter + - name: flag-parameter + severity: warning + disabled: false + # https://github.com/mgechev/revive/blob/master/RULES_DESCRIPTIONS.md#function-result-limit + - name: function-result-limit + severity: warning + disabled: false + arguments: [2] + # https://github.com/mgechev/revive/blob/master/RULES_DESCRIPTIONS.md#function-length + - name: function-length + severity: warning + disabled: false + arguments: [10, 0] + # https://github.com/mgechev/revive/blob/master/RULES_DESCRIPTIONS.md#get-return + - name: get-return + severity: warning + disabled: false + # https://github.com/mgechev/revive/blob/master/RULES_DESCRIPTIONS.md#identical-branches + - name: identical-branches + severity: warning + disabled: false + # https://github.com/mgechev/revive/blob/master/RULES_DESCRIPTIONS.md#if-return + - name: if-return + severity: warning + disabled: false + # https://github.com/mgechev/revive/blob/master/RULES_DESCRIPTIONS.md#increment-decrement + - name: increment-decrement + severity: warning + disabled: false + # https://github.com/mgechev/revive/blob/master/RULES_DESCRIPTIONS.md#indent-error-flow + - name: indent-error-flow + severity: warning + disabled: false + # https://github.com/mgechev/revive/blob/master/RULES_DESCRIPTIONS.md#imports-blacklist + - name: imports-blacklist + severity: warning + disabled: false + arguments: + - "crypto/md5" + - "crypto/sha1" + # https://github.com/mgechev/revive/blob/master/RULES_DESCRIPTIONS.md#import-shadowing + - name: import-shadowing + severity: warning + disabled: false + # https://github.com/mgechev/revive/blob/master/RULES_DESCRIPTIONS.md#line-length-limit + - name: line-length-limit + severity: warning + disabled: false + arguments: [80] + # https://github.com/mgechev/revive/blob/master/RULES_DESCRIPTIONS.md#max-public-structs + - name: max-public-structs + severity: warning + disabled: false + arguments: [3] + # https://github.com/mgechev/revive/blob/master/RULES_DESCRIPTIONS.md#modifies-parameter + - name: modifies-parameter + severity: warning + disabled: false + # https://github.com/mgechev/revive/blob/master/RULES_DESCRIPTIONS.md#modifies-value-receiver + - name: modifies-value-receiver + severity: warning + disabled: false + # https://github.com/mgechev/revive/blob/master/RULES_DESCRIPTIONS.md#nested-structs + - name: nested-structs + severity: warning + disabled: false + # https://github.com/mgechev/revive/blob/master/RULES_DESCRIPTIONS.md#optimize-operands-order + - name: optimize-operands-order + severity: warning + disabled: false + # https://github.com/mgechev/revive/blob/master/RULES_DESCRIPTIONS.md#package-comments + - name: package-comments + severity: warning + disabled: false + # https://github.com/mgechev/revive/blob/master/RULES_DESCRIPTIONS.md#range + - name: range + severity: warning + disabled: false + # https://github.com/mgechev/revive/blob/master/RULES_DESCRIPTIONS.md#range-val-in-closure + - name: range-val-in-closure + severity: warning + disabled: false + # https://github.com/mgechev/revive/blob/master/RULES_DESCRIPTIONS.md#range-val-address + - name: range-val-address + severity: warning + disabled: false + # https://github.com/mgechev/revive/blob/master/RULES_DESCRIPTIONS.md#receiver-naming + - name: receiver-naming + severity: warning + disabled: false + # https://github.com/mgechev/revive/blob/master/RULES_DESCRIPTIONS.md#redefines-builtin-id + - name: redefines-builtin-id + severity: warning + disabled: false + # https://github.com/mgechev/revive/blob/master/RULES_DESCRIPTIONS.md#string-of-int + - name: string-of-int + severity: warning + disabled: false + # https://github.com/mgechev/revive/blob/master/RULES_DESCRIPTIONS.md#string-format + - name: string-format + severity: warning + disabled: false + arguments: + - - 'core.WriteError[1].Message' + - '/^([^A-Z]|$)/' + - must not start with a capital letter + - - 'fmt.Errorf[0]' + - '/(^|[^\.!?])$/' + - must not end in punctuation + - - panic + - '/^[^\n]*$/' + - must not contain line breaks + # https://github.com/mgechev/revive/blob/master/RULES_DESCRIPTIONS.md#struct-tag + - name: struct-tag + severity: warning + disabled: false + # https://github.com/mgechev/revive/blob/master/RULES_DESCRIPTIONS.md#superfluous-else + - name: superfluous-else + severity: warning + disabled: false + # https://github.com/mgechev/revive/blob/master/RULES_DESCRIPTIONS.md#time-equal + - name: time-equal + severity: warning + disabled: false + # https://github.com/mgechev/revive/blob/master/RULES_DESCRIPTIONS.md#time-naming + - name: time-naming + severity: warning + disabled: false + # https://github.com/mgechev/revive/blob/master/RULES_DESCRIPTIONS.md#var-naming + - name: var-naming + severity: warning + disabled: false + arguments: + - ["ID"] # AllowList + - ["VM"] # DenyList + # https://github.com/mgechev/revive/blob/master/RULES_DESCRIPTIONS.md#var-declaration + - name: var-declaration + severity: warning + disabled: false + # https://github.com/mgechev/revive/blob/master/RULES_DESCRIPTIONS.md#unconditional-recursion + - name: unconditional-recursion + severity: warning + disabled: false + # https://github.com/mgechev/revive/blob/master/RULES_DESCRIPTIONS.md#unexported-naming + - name: unexported-naming + severity: warning + disabled: false + # https://github.com/mgechev/revive/blob/master/RULES_DESCRIPTIONS.md#unexported-return + - name: unexported-return + severity: warning + disabled: false + # https://github.com/mgechev/revive/blob/master/RULES_DESCRIPTIONS.md#unhandled-error + - name: unhandled-error + severity: warning + disabled: false + arguments: + - "fmt.Printf" + - "myFunction" + # https://github.com/mgechev/revive/blob/master/RULES_DESCRIPTIONS.md#unnecessary-stmt + - name: unnecessary-stmt + severity: warning + disabled: false + # https://github.com/mgechev/revive/blob/master/RULES_DESCRIPTIONS.md#unreachable-code + - name: unreachable-code + severity: warning + disabled: false + # https://github.com/mgechev/revive/blob/master/RULES_DESCRIPTIONS.md#unused-parameter + - name: unused-parameter + severity: warning + disabled: false + # https://github.com/mgechev/revive/blob/master/RULES_DESCRIPTIONS.md#unused-receiver + - name: unused-receiver + severity: warning + disabled: false + # https://github.com/mgechev/revive/blob/master/RULES_DESCRIPTIONS.md#useless-break + - name: useless-break + severity: warning + disabled: false + # https://github.com/mgechev/revive/blob/master/RULES_DESCRIPTIONS.md#waitgroup-by-value + - name: waitgroup-by-value + severity: warning + disabled: false + varcheck: + exported-fields: true + varnamelen: + check-receiver: true + check-return: true + check-type-param: true + ignore-type-assert-ok: true + ignore-map-index-ok: true + ignore-chan-recv-ok: true + ignore-names: + - err + ignore-decls: + - c echo.Context + - t testing.T + - e error + - i int + - const C + - T any + - m map[string]int + wsl: + allow-cuddle-declarations: false + allow-multiline-assign: true + allow-separated-leading-comment: false + force-case-trailing-whitespace: 1 + force-err-cuddling: true +issues: + # List of regexps of issue texts to exclude. + # + # But independently of this option we use default exclude patterns, + # it can be disabled by `exclude-use-default: false`. + # To list all excluded by default patterns execute `golangci-lint run --help` + # + # Default: [] + exclude: [] + + # Excluding configuration per-path, per-linter, per-text and per-source + exclude-rules: + # Exclude some linters from running on tests files. + - path: _test\.go + linters: + - gochecknoglobals + - cyclop + - dupl + - errcheck + - forcetypeassert + - gocyclo + - goerr113 + - gosec + - lll + - maintidx + + # Independently of option `exclude` we use default exclude patterns, + # it can be disabled by this option. + # To list all excluded by default patterns execute `golangci-lint run --help`. + # Default: true. + exclude-use-default: true + + # If set to true exclude and exclude-rules regular expressions become case-sensitive. + # Default: false + exclude-case-sensitive: false + + # The list of ids of default excludes to include or disable. + # Default: [] + include: [] + + # Maximum issues count per one linter. + # Set to 0 to disable. + # Default: 50 + max-issues-per-linter: 50 + + # Maximum count of issues with the same text. + # Set to 0 to disable. + # Default: 3 + max-same-issues: 3 + + # Show only new issues: if there are unstaged changes or untracked files, + # only those changes are analyzed, else only changes in HEAD~ are analyzed. + # It's a super-useful option for integration of golangci-lint into existing large codebase. + # It's not practical to fix all existing issues at the moment of integration: + # much better don't allow issues in new code. + # + # Default: false. + new: false + + # Show only new issues created after git revision `REV`. + # new-from-rev: HEAD + + # Show only new issues created in git patch with set file path. + # new-from-patch: path/to/patch/file + + # Fix found issues (if it's supported by the linter). + fix: false + +severity: + # Set the default severity for issues. + # + # If severity rules are defined and the issues do not match or no severity is provided to the rule + # this will be the default severity applied. + # Severities should match the supported severity names of the selected out format. + # - Code climate: https://docs.codeclimate.com/docs/issues#issue-severity + # - Checkstyle: https://checkstyle.sourceforge.io/property_types.html#severity + # - GitHub: https://help.github.com/en/actions/reference/workflow-commands-for-github-actions#setting-an-error-message + # + # Default value is an empty string. + default-severity: error + + # If set to true `severity-rules` regular expressions become case-sensitive. + # Default: false + case-sensitive: true + + # When a list of severity rules are provided, severity information will be added to lint issues. + # Severity rules have the same filtering capability as exclude rules + # except you are allowed to specify one matcher per severity rule. + # Only affects out formats that support setting severity information. + # + # Default: [] + rules: + - linters: + - dupl + severity: info diff --git a/.tool-versions.dist b/.tool-versions.dist index 0e32bb7..b5ce668 100644 --- a/.tool-versions.dist +++ b/.tool-versions.dist @@ -1 +1,2 @@ -golang 1.18.1 +golang 1.19 +golangci-lint 1.49.0 diff --git a/Makefile b/Makefile new file mode 100644 index 0000000..3562447 --- /dev/null +++ b/Makefile @@ -0,0 +1,104 @@ +_PROJECT_DIRECTORY = $(dir $(realpath $(firstword $(MAKEFILE_LIST)))) +_GOLANG_IMAGE = golang:1.19.0 +_PROJECTNAME = goarkitect +_GOARCH = "amd64" + +NETRC_FILE ?= ~/.netrc + +ifeq ("$(shell uname -m)", "arm64") + _GOARCH = "arm64" +endif + +_GOARK_GIT_COMMIT = $(shell git rev-list -1 HEAD) +_GOARK_BUILD_TIME = $(shell date) +_GOARK_GO_VERSION = $(shell go version | cut -d ' ' -f 3) +_GOARK_OS_ARCH = $(shell go version | cut -d ' ' -f 4) + +#1: docker image +#2: make target +define run-docker + @docker run --rm \ + -e CGO_ENABLED=0 \ + -e GOARCH=${_GOARCH} \ + -e GOOS=linux \ + -w /app \ + -v ${NETRC_FILE}:/root/.netrc \ + -v ${_PROJECT_DIRECTORY}:/app \ + $(1) $(2) +endef + +.PHONY: env + +env: + @echo 'export CGO_ENABLED=0' + @echo 'export GOARCH=${_GOARCH}' + +.PHONY: mod-download mod-tidy mod-verify + +mod-download: + @go mod download + +mod-tidy: + @go mod tidy + +mod-verify: + @go mod verify + +.PHONY: mod-check-upgrades mod-upgrade + +mod-check-upgrades: + @go list -mod=readonly -u -f "{{if (and (not (or .Main .Indirect)) .Update)}}{{.Path}}: {{.Version}} -> {{.Update.Version}}{{end}}" -m all + +mod-upgrade: + @go get -u ./... && go mod tidy + +.PHONY: fmt fumpt imports + +fmt: + @find . -name "*.go" -type f -not -path '*/vendor/*' \ + | sed 's/^\.\///g' \ + | xargs -I {} sh -c 'echo "formatting {}.." && gofmt -w -s {}' + +fumpt: + @find . -name "*.go" -type f -not -path '*/vendor/*' \ + | sed 's/^\.\///g' \ + | xargs -I {} sh -c 'echo "formatting {}.." && gofumpt -w -extra {}' + +imports: + @goimports -w -e -local github.com/omissis main.go + @goimports -w -e -local github.com/omissis cmd/ + @goimports -w -e -local github.com/omissis internal/ + +.PHONY: lint lint-go + +lint: lint-go + +lint-go: + @golangci-lint -v run --color=always --config=${_PROJECT_DIRECTORY}/.rules/.golangci.yml ./... + +.PHONY: test + +test: + @go test ./... + +.PHONY: build + +build: check-variable-GOARK_VERSION + go build \ + -ldflags "\ + -X 'main.Version=$${GOARK_VERSION}' \ + -X 'main.GitCommit=$$(git rev-list -1 HEAD)' \ + -X 'main.BuildTime=$$(date)' \ + -X 'main.GoVersion=$$(go version | cut -d ' ' -f 3)' \ + -X 'main.OsArch=$$(go version | cut -d ' ' -f 4)' \ + " \ + -o ${_PROJECT_DIRECTORY}/bin/${_PROJECTNAME} \ + main.go + +# Helpers + +%-docker: + $(call run-docker,${_GOLANG_IMAGE},make $*) + +check-variable-%: # detection of undefined variables. + @[[ "${${*}}" ]] || (echo '*** Please define variable `${*}` ***' && exit 1) diff --git a/cmd/common.go b/cmd/common.go index 75e66d0..9cee92e 100644 --- a/cmd/common.go +++ b/cmd/common.go @@ -5,13 +5,16 @@ import ( "os" "path/filepath" - "github.com/omissis/goarkitect/internal/logx" "golang.org/x/exp/slices" "gopkg.in/yaml.v3" + + "github.com/omissis/goarkitect/internal/logx" ) -var ErrNoOutputFormat = errors.New("output cannot be nil") -var ErrNoConfigFileFound = errors.New("no config files found") +var ( + ErrNoOutputFormat = errors.New("output cannot be nil") + ErrNoConfigFileFound = errors.New("no config files found") +) func getWd() string { cwd, err := os.Getwd() diff --git a/cmd/root.go b/cmd/root.go index 10fb1ec..2176bbe 100644 --- a/cmd/root.go +++ b/cmd/root.go @@ -1,8 +1,9 @@ package cmd import ( - "github.com/omissis/goarkitect/internal/cobrax" "github.com/spf13/cobra" + + "github.com/omissis/goarkitect/internal/cobrax" ) type rootConfig struct { diff --git a/cmd/validate.go b/cmd/validate.go index 6b8c597..8032ab9 100644 --- a/cmd/validate.go +++ b/cmd/validate.go @@ -3,9 +3,10 @@ package cmd import ( "path/filepath" + "github.com/spf13/cobra" + "github.com/omissis/goarkitect/cmd/validate" "github.com/omissis/goarkitect/internal/schema/santhosh" - "github.com/spf13/cobra" ) func NewValidateCommand(output *string) *cobra.Command { diff --git a/cmd/verify.go b/cmd/verify.go index e8df05e..be68169 100644 --- a/cmd/verify.go +++ b/cmd/verify.go @@ -3,9 +3,10 @@ package cmd import ( "path/filepath" + "github.com/spf13/cobra" + "github.com/omissis/goarkitect/cmd/verify" "github.com/omissis/goarkitect/internal/config" - "github.com/spf13/cobra" ) func NewVerifyCommand(output *string) *cobra.Command { diff --git a/cmd/verify/utils.go b/cmd/verify/utils.go index 860970b..b9055e2 100644 --- a/cmd/verify/utils.go +++ b/cmd/verify/utils.go @@ -12,7 +12,7 @@ import ( var ErrProjectDoesNotRespectRules = errors.New("project does not respect defined rules") -func PrintResults(output string, configFile string, results []config.RuleExecutionResult) { +func PrintResults(output, configFile string, results []config.RuleExecutionResult) { switch output { case "text": // TODO: improve formatting diff --git a/cmd/version.go b/cmd/version.go index 7f16288..08a9960 100644 --- a/cmd/version.go +++ b/cmd/version.go @@ -4,9 +4,10 @@ import ( "fmt" "strings" + "github.com/spf13/cobra" + "github.com/omissis/goarkitect/internal/jsonx" "github.com/omissis/goarkitect/internal/logx" - "github.com/spf13/cobra" ) func NewVersionCommand(output *string, versions map[string]string) *cobra.Command { diff --git a/go.mod b/go.mod index 19da77f..445f5a7 100644 --- a/go.mod +++ b/go.mod @@ -1,6 +1,6 @@ module github.com/omissis/goarkitect -go 1.18 +go 1.19 require ( github.com/google/go-cmp v0.5.8 diff --git a/goarkitect b/goarkitect new file mode 100755 index 0000000..5a411c4 Binary files /dev/null and b/goarkitect differ diff --git a/internal/arch/file/expect/match_glob.go b/internal/arch/file/expect/match_glob.go index 8742104..b7d99b7 100644 --- a/internal/arch/file/expect/match_glob.go +++ b/internal/arch/file/expect/match_glob.go @@ -7,7 +7,7 @@ import ( "github.com/omissis/goarkitect/internal/arch/rule" ) -func MatchGlob(glob string, basePath string, opts ...Option) *matchGlobExpression { +func MatchGlob(glob, basePath string, opts ...Option) *matchGlobExpression { expr := &matchGlobExpression{ basePath: basePath, glob: glob, diff --git a/internal/cli/app.go b/internal/cli/app.go index c00bcb4..dc9f205 100644 --- a/internal/cli/app.go +++ b/internal/cli/app.go @@ -7,9 +7,11 @@ import ( flag "github.com/spf13/pflag" ) -var ErrEmptyAppName = errors.New("app name cannot be empty") -var ErrEmptyCommands = errors.New("app must have at least one command") -var ErrNoCommandSpecified = errors.New("app command was not specified") +var ( + ErrEmptyAppName = errors.New("app name cannot be empty") + ErrEmptyCommands = errors.New("app must have at least one command") + ErrNoCommandSpecified = errors.New("app command was not specified") +) func NewApp( name string, diff --git a/internal/cli/app_test.go b/internal/cli/app_test.go index 157dd00..6b1be76 100644 --- a/internal/cli/app_test.go +++ b/internal/cli/app_test.go @@ -4,9 +4,10 @@ import ( "os" "testing" - "github.com/omissis/goarkitect/internal/cli" flag "github.com/spf13/pflag" "golang.org/x/exp/slices" + + "github.com/omissis/goarkitect/internal/cli" ) func Test_NewApp_Fail(t *testing.T) { diff --git a/internal/jsonx/encode.go b/internal/jsonx/encode.go index 275f073..9fd4ac7 100644 --- a/internal/jsonx/encode.go +++ b/internal/jsonx/encode.go @@ -15,7 +15,6 @@ func Marshal(v ...any) string { } ret[i] = string(b) - } return strings.Join(ret, " ")