diff --git a/.github/workflows/go.yml b/.github/workflows/go.yml index 5388ad3..8a27209 100644 --- a/.github/workflows/go.yml +++ b/.github/workflows/go.yml @@ -1,6 +1,7 @@ name: Go permissions: contents: write + pull-requests: read on: push: @@ -11,26 +12,42 @@ on: branches: [ master,main ] jobs: - golangci: - name: lint + error-lint: + name: error-lint runs-on: ubuntu-latest steps: - - uses: actions/checkout@v3 - - uses: actions/setup-go@v4 + - uses: actions/checkout@v4 + - uses: actions/setup-go@v5 with: go-version-file: go.mod + cache: false - name: golangci-lint - uses: golangci/golangci-lint-action@v3 + uses: golangci/golangci-lint-action@v4 with: - # Required: the version of golangci-lint is required and must be specified without patch version: we always use the latest patch version. version: latest + args: --config=./.golangci-lint.yml + style-lint: + name: style-lint + runs-on: ubuntu-latest + steps: + - uses: actions/checkout@v4 + - uses: actions/setup-go@v5 + with: + go-version-file: go.mod + cache: false + - name: golangci-style-lint + uses: golangci/golangci-lint-action@v4 + with: + version: latest + args: --config=./.golangci-style.yml + test: runs-on: ubuntu-latest steps: - - uses: actions/checkout@v3 + - uses: actions/checkout@v4 - name: Set up Go from go.mod - uses: actions/setup-go@v4 + uses: actions/setup-go@v5 with: go-version-file: go.mod @@ -45,17 +62,17 @@ jobs: build-darwin-artifacts: if: startsWith(github.ref, 'refs/tags/v') - needs: [ golangci,test ] + needs: [ error-lint,style-lint,test ] runs-on: macos-latest steps: - - uses: actions/checkout@v3 + - uses: actions/checkout@v4 with: fetch-depth: 0 - run: git fetch --force --tags - - uses: actions/setup-go@v4 + - uses: actions/setup-go@v5 with: go-version-file: go.mod - - uses: goreleaser/goreleaser-action@v4 + - uses: goreleaser/goreleaser-action@v5 with: distribution: goreleaser version: latest @@ -63,7 +80,7 @@ jobs: env: GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} - name: Upload - uses: actions/upload-artifact@v3 + uses: actions/upload-artifact@v4 with: name: bin-darwin path: dist/${{ github.event.repository.name }}_*.tar.gz @@ -90,18 +107,18 @@ jobs: run: | echo "DOCKERHUB_OWNER=${{secrets.DOCKERHUB_USERNAME}}" >> $GITHUB_ENV - - uses: actions/checkout@v3 + - uses: actions/checkout@v4 with: fetch-depth: 0 - run: git fetch --force --tags - - uses: actions/setup-go@v4 + - uses: actions/setup-go@v5 with: go-version-file: go.mod - name: Make directory for darwin bin run: | mkdir -p ./release/artifacts/darwin - name: Download Darwin binaries - uses: actions/download-artifact@v3 + uses: actions/download-artifact@v4 with: name: bin-darwin path: ./release/artifacts/darwin @@ -109,9 +126,9 @@ jobs: # - name: Install cross-compiler for linux/arm64 # run: sudo apt-get -y install gcc-aarch64-linux-gnu - name: Set up QEMU - uses: docker/setup-qemu-action@v2 + uses: docker/setup-qemu-action@v3 - name: Login to Docker Hub - uses: docker/login-action@v2 + uses: docker/login-action@v3 with: username: ${{ secrets.DOCKERHUB_USERNAME }} password: ${{ secrets.DOCKERHUB_TOKEN }} @@ -119,7 +136,7 @@ jobs: run: | envsubst < ./release/README.DOCKER.md > ./release/artifacts/README.DOCKER.md - name: Go Release - uses: goreleaser/goreleaser-action@v4 + uses: goreleaser/goreleaser-action@v5 with: distribution: goreleaser version: latest @@ -130,7 +147,7 @@ jobs: DOCKERHUB_REPONAME: ${{ env.DOCKERHUB_REPO }} SOURCE_URL: ${{ github.event.repository.url }} - name: Docker Hub Description - uses: peter-evans/dockerhub-description@v3 + uses: peter-evans/dockerhub-description@v4 with: username: ${{ secrets.DOCKERHUB_USERNAME }} password: ${{ secrets.DOCKERHUB_TOKEN }} diff --git a/.golangci-lint.yml b/.golangci-lint.yml new file mode 100644 index 0000000..f48f20b --- /dev/null +++ b/.golangci-lint.yml @@ -0,0 +1,183 @@ +# This file contains all available configuration options +# with their default values. + +# options for analysis running +run: + # default concurrency is an available CPU number + concurrency: 4 + + # timeout for analysis, e.g. 30s, 5m, default is 1m + timeout: 5m + + # exit code when at least one issue was found, default is 1 + issues-exit-code: 1 + + # include test files or not, default is true + tests: true + + # list of build tags, all linters use it. Default is empty list. + build-tags: + - mytag + + + # default is true. Enables skipping of directories: + # vendor$, third_party$, testdata$, examples$, Godeps$, builtin$ + skip-dirs-use-default: true + + + # by default isn't set. If set we pass it to "go list -mod={option}". From "go help modules": + # If invoked with -mod=readonly, the go command is disallowed from the implicit + # automatic updating of go.mod described above. Instead, it fails when any changes + # to go.mod are needed. This setting is most useful to check that go.mod does + # not need updates, such as in a continuous integration and testing system. + # If invoked with -mod=vendor, the go command assumes that the vendor + # directory holds the correct copies of dependencies and ignores + # the dependency descriptions in go.mod. + # modules-download-mode: readonly|release|vendor + + # Allow multiple parallel golangci-lint instances running. + # If false (default) - golangci-lint acquires file lock on start. + allow-parallel-runners: false + + +# output configuration options +output: + # colored-line-number|line-number|json|tab|checkstyle|code-climate, default is "colored-line-number" + formats: colored-line-number + + # print lines of code with issue, default is true + print-issued-lines: true + + # print linter name in the end of issue text, default is true + print-linter-name: true + + # make issues output unique by line, default is true + uniq-by-line: true + + # add a prefix to the output file references; default is no prefix + path-prefix: "" + +linters: + # Disable all linters. + # Default: false + disable-all: true + # Enable specific linter + # https://golangci-lint.run/usage/linters/#enabled-by-default + enable: + - bodyclose + - exhaustive + - gosec + - prealloc + - govet + - unconvert + - ineffassign + - dogsled + - exportloopref + - sqlclosecheck + - errcheck + - gosimple + - staticcheck + - unused + #TODO: add revive like in other projects + +linters-settings: + #TODO: setup like in other projects + govet: + enable-all: true + disable: + - fieldalignment + + +issues: + # List of regexps of issue texts to exclude, empty list by default. + # 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` + exclude: + - Using the variable on range scope .* in function literal + - should have a package comment + + # 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: + - gocyclo + - errcheck + - gosec + + # Exclude known linters from partially "hard-vendored" code, + # which is impossible to exclude via "nolint" comments. + - path: internal/hmac/ + text: "weak cryptographic primitive" + linters: + - gosec + + # Exclude some "staticcheck" messages + - linters: + - staticcheck + text: "SA1019:" + + # Exclude lll issues for long lines with go:generate + - linters: + - lll + source: "^//go:generate " + + # 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 value for this option is true. + exclude-use-default: false + + # which files to skip: they will be analyzed, but issues from them + # won't be reported. Default value is empty list, but there is + # no need to include all autogenerated files, we confidently recognize + # autogenerated files. If it's not please let us know. + # "/" will be replaced by current OS file path separator to properly work + # on Windows. + exclude-files: + - ".*\\.my\\.go$" + - lib/bad.go + # which dirs to skip: issues from them won't be reported; + # can use regexp here: generated.*, regexp is applied on full path; + # default value is empty list, but default dirs are skipped independently + # of this option's value (see skip-dirs-use-default). + # "/" will be replaced by current OS file path separator to properly work + # on Windows. + exclude-dirs: + - .github + - .make + - dist + # Maximum issues count per one linter. Set to 0 to disable. Default is 50. + max-issues-per-linter: 0 + + # Maximum count of issues with the same text. Set to 0 to disable. Default is 3. + max-same-issues: 0 + + # Show only new issues created after git revision `REV` + new-from-rev: "" + +severity: + # Default value is empty string. + # 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-severity: error + + # The default value is false. + # If set to true severity-rules regular expressions become case-sensitive. + case-sensitive: false + + # Default value is empty list. + # 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. + rules: + - linters: + - dupl + severity: info diff --git a/.golangci-style.yml b/.golangci-style.yml new file mode 100644 index 0000000..124b715 --- /dev/null +++ b/.golangci-style.yml @@ -0,0 +1,139 @@ +# This file contains all available configuration options +# with their default values. + +# options for analysis running +run: + # default concurrency is an available CPU number + concurrency: 4 + + # timeout for analysis, e.g. 30s, 5m, default is 1m + timeout: 5m + + # exit code when at least one issue was found, default is 1 + issues-exit-code: 1 + + # include test files or not, default is true + tests: true + + # list of build tags, all linters use it. Default is empty list. + build-tags: + - mytag + + # default is true. Enables skipping of directories: + # vendor$, third_party$, testdata$, examples$, Godeps$, builtin$ + skip-dirs-use-default: true + + # by default isn't set. If set we pass it to "go list -mod={option}". From "go help modules": + # If invoked with -mod=readonly, the go command is disallowed from the implicit + # automatic updating of go.mod described above. Instead, it fails when any changes + # to go.mod are needed. This setting is most useful to check that go.mod does + # not need updates, such as in a continuous integration and testing system. + # If invoked with -mod=vendor, the go command assumes that the vendor + # directory holds the correct copies of dependencies and ignores + # the dependency descriptions in go.mod. + # modules-download-mode: readonly|release|vendor + + # Allow multiple parallel golangci-lint instances running. + # If false (default) - golangci-lint acquires file lock on start. + allow-parallel-runners: false + + +# output configuration options +output: + # colored-line-number|line-number|json|tab|checkstyle|code-climate, default is "colored-line-number" + formats: colored-line-number + + # print lines of code with issue, default is true + print-issued-lines: true + + # print linter name in the end of issue text, default is true + print-linter-name: true + + # make issues output unique by line, default is true + uniq-by-line: true + + # add a prefix to the output file references; default is no prefix + path-prefix: "" + +linters: + # Disable all linters. + # Default: false + disable-all: true + # Enable specific linter + # https://golangci-lint.run/usage/linters/#enabled-by-default + enable: + - gci + - misspell + + +linters-settings: + gci: + sections: + - standard # Standard section: captures all standard packages. + - default # Default section: contains all imports that could not be matched to another section type. + - prefix(bitcoin-sv/spv-wallet) # Custom section: groups all imports with the specified Prefix. + misspell: + # Correct spellings using locale preferences for US or UK. + # Default is to use a neutral variety of English. + # Setting locale to US will correct the British spelling of 'colour' to 'color'. + locale: US + ignore-words: + - bsv + - bitcoin + +issues: + # 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: false + # Maximum issues count per one linter. Set to 0 to disable. Default is 50. + max-issues-per-linter: 0 + # Maximum count of issues with the same text. Set to 0 to disable. Default is 3. + max-same-issues: 0 + # Show only new issues created after git revision `REV` + new-from-rev: "" + exclude-files: + # which files to skip: they will be analyzed, but issues from them + # won't be reported. Default value is empty list, but there is + # no need to include all autogenerated files, we confidently recognize + # autogenerated files. If it's not please let us know. + # "/" will be replaced by current OS file path separator to properly work + # on Windows. + - ".*\\.my\\.go$" + - lib/bad.go + # which dirs to skip: issues from them won't be reported; + # can use regexp here: generated.*, regexp is applied on full path; + # default value is empty list, but default dirs are skipped independently + # of this option's value (see skip-dirs-use-default). + # "/" will be replaced by current OS file path separator to properly work + # on Windows. + exclude-dirs: + - .github + - .make + - dist + +severity: + # Default value is empty string. + # 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-severity: error + + # The default value is false. + # If set to true severity-rules regular expressions become case-sensitive. + case-sensitive: false + + # Default value is empty list. + # 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. + rules: + - linters: + - dupl + severity: info diff --git a/.golangci.yml b/.golangci.yml deleted file mode 100644 index c4851e5..0000000 --- a/.golangci.yml +++ /dev/null @@ -1,468 +0,0 @@ -# This file contains all available configuration options -# with their default values. - -# options for analysis running -run: - # default concurrency is a available CPU number - concurrency: 4 - - # timeout for analysis, e.g. 30s, 5m, default is 1m - timeout: 3m - - # exit code when at least one issue was found, default is 1 - issues-exit-code: 1 - - # include test files or not, default is true - tests: true - - # list of build tags, all linters use it. Default is empty list. - build-tags: - - mytag - - # which dirs to skip: issues from them won't be reported; - # can use regexp here: generated.*, regexp is applied on full path; - # default value is empty list, but default dirs are skipped independently - # from this option's value (see skip-dirs-use-default). - # "/" will be replaced by current OS file path separator to properly work - # on Windows. - skip-dirs: - - .github - - .make - - dist - - # default is true. Enables skipping of directories: - # vendor$, third_party$, testdata$, examples$, Godeps$, builtin$ - skip-dirs-use-default: true - - # which files to skip: they will be analyzed, but issues from them - # won't be reported. Default value is empty list, but there is - # no need to include all autogenerated files, we confidently recognize - # autogenerated files. If it's not please let us know. - # "/" will be replaced by current OS file path separator to properly work - # on Windows. - skip-files: - - ".*\\.my\\.go$" - - lib/bad.go - - # by default isn't set. If set we pass it to "go list -mod={option}". From "go help modules": - # If invoked with -mod=readonly, the go command is disallowed from the implicit - # automatic updating of go.mod described above. Instead, it fails when any changes - # to go.mod are needed. This setting is most useful to check that go.mod does - # not need updates, such as in a continuous integration and testing system. - # If invoked with -mod=vendor, the go command assumes that the vendor - # directory holds the correct copies of dependencies and ignores - # the dependency descriptions in go.mod. - #modules-download-mode: readonly|release|vendor - - # Allow multiple parallel golangci-lint instances running. - # If false (default) - golangci-lint acquires file lock on start. - allow-parallel-runners: false - - -# output configuration options -output: - # colored-line-number|line-number|json|tab|checkstyle|code-climate, default is "colored-line-number" - format: colored-line-number - - # print lines of code with issue, default is true - print-issued-lines: true - - # print linter name in the end of issue text, default is true - print-linter-name: true - - # make issues output unique by line, default is true - uniq-by-line: true - - # add a prefix to the output file references; default is no prefix - path-prefix: "" - - -# all available settings of specific linters -linters-settings: - dogsled: - # checks assignments with too many blank identifiers; default is 2 - max-blank-identifiers: 2 - dupl: - # tokens count to trigger issue, 150 by default - threshold: 200 - errcheck: - # report about not checking of errors in type assertions: `a := b.(MyStruct)`; - # default is false: such cases aren't reported by default. - check-type-assertions: false - - # report about assignment of errors to blank identifier: `num, _ := strconv.Atoi(numStr)`; - # default is false: such cases aren't reported by default. - check-blank: false - - # [deprecated] comma-separated list of pairs of the form pkg:regex - # the regex is used to ignore names within pkg. (default "fmt:.*"). - # see https://github.com/kisielk/errcheck#the-deprecated-method for details - ignore: fmt:.*,io/ioutil:^Read.* - - # path to a file containing a list of functions to exclude from checking - # see https://github.com/kisielk/errcheck#excluding-functions for details - #exclude: /path/to/file.txt - 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: false - funlen: - lines: 60 - statements: 40 - gci: - # put imports beginning with prefix after 3rd-party packages; - # only support one prefix - # if not set, use goimports.local-prefixes - local-prefixes: github.com/org/project - gocognit: - # minimal code complexity to report, 30 by default (but we recommend 10-20) - min-complexity: 10 - nestif: - # minimal complexity of if statements to report, 5 by default - min-complexity: 4 - goconst: - # minimal length of string constant, 3 by default - min-len: 3 - # minimal occurrences count to trigger, 3 by default - min-occurrences: 3 - gocritic: - # Which checks should be enabled; can't be combined with 'disabled-checks'; - # See https://go-critic.github.io/overview#checks-overview - # To check which checks are enabled run `GL_DEBUG=gocritic golangci-lint run` - # By default list of stable checks is used. - #enabled-checks: - # - rangeValCopy - - # Which checks should be disabled; can't be combined with 'enabled-checks'; default is empty - disabled-checks: - - regexpMust - - # Enable multiple checks by tags, run `GL_DEBUG=gocritic golangci-lint run` to see all tags and checks. - # Empty list by default. See https://github.com/go-critic/go-critic#usage -> section "Tags". - enabled-tags: - - performance - disabled-tags: - - experimental - - settings: # settings passed to gocritic - captLocal: # must be valid enabled check name - paramsOnly: true - rangeValCopy: - sizeThreshold: 32 - gocyclo: - # minimal code complexity to report, 30 by default (but we recommend 10-20) - min-complexity: 10 - godot: - # check all top-level comments, not only declarations - check-all: false - godox: - # report any comments starting with keywords, this is useful for TODO or FIXME comments that - # might be left in the code accidentally and should be resolved before merging - keywords: # default keywords are TODO, BUG, and FIXME, these can be overwritten by this setting - - NOTE - - OPTIMIZE # marks code that should be optimized before merging - - HACK # marks hack-arounds that should be removed before merging - gofmt: - # simplify code: gofmt with `-s` option, true by default - simplify: true - goheader: - values: - const: - # define here const type values in format k:v, for example: - # YEAR: 2020 - # COMPANY: MY COMPANY - regexp: - # define here regexp type values, for example - # AUTHOR: .*@mycompany\.com - template: - # put here copyright header template for source code files, for example: - # {{ AUTHOR }} {{ COMPANY }} {{ YEAR }} - # SPDX-License-Identifier: Apache-2.0 - # - # Licensed under the Apache License, Version 2.0 (the "License"); - # you may not use this file except in compliance with the License. - # You may obtain a copy of the License at: - # - # http://www.apache.org/licenses/LICENSE-2.0 - # - # Unless required by applicable law or agreed to in writing, software - # distributed under the License is distributed on an "AS IS" BASIS, - # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - # See the License for the specific language governing permissions and - # limitations under the License. - template-path: - # also as alternative of directive 'template' you may put the path to file with the template source - goimports: - # put imports beginning with prefix after 3rd-party packages; - # it's a comma-separated list of prefixes - local-prefixes: github.com/org/project - golint: - # minimal confidence for issues, default is 0.8 - min-confidence: 1.0 - gomnd: - settings: - mnd: - # the list of enabled checks, see https://github.com/tommy-muehle/go-mnd/#checks for description. - checks: argument,case,condition,operation,return,assign - govet: - # report about shadowed variables - check-shadowing: true - - # settings per analyzer - settings: - printf: # analyzer name, run `go tool vet help` to see all analyzers - funcs: # run `go tool vet help printf` to see available settings for `printf` analyzer - - (github.com/golangci/golangci-lint/pkg/logutils.Log).Infof - - (github.com/golangci/golangci-lint/pkg/logutils.Log).Warnf - - (github.com/golangci/golangci-lint/pkg/logutils.Log).Errorf - - (github.com/golangci/golangci-lint/pkg/logutils.Log).Fatalf - - # enable or disable analyzers by name - enable: - - atomicalign - enable-all: false - disable: - #- shadow - disable-all: false - depguard: - list-type: blacklist - include-go-root: false - packages: - - github.com/sirupsen/logrus - packages-with-error-message: - # specify an error message to output when a blacklisted package is used - - github.com/sirupsen/logrus: "logging is allowed only by logutils.Log" - lll: - # max line length, lines longer will be reported. Default is 120. - # '\t' is counted as 1 character by default, and can be changed with the tab-width option - line-length: 120 - # tab width in spaces. Default to 1. - tab-width: 1 - misspell: - # Correct spellings using locale preferences for US or UK. - # Default is to use a neutral variety of English. - # Setting locale to US will correct the British spelling of 'colour' to 'color'. - locale: US - ignore-words: - - bsv - - bitcoin - - payd - nakedret: - # make an issue if func has more lines of code than this setting and it has naked returns; default is 30 - max-func-lines: 30 - prealloc: - # XXX: we don't recommend using this linter before doing performance profiling. - # For most programs usage of prealloc will be a premature optimization. - - # Report preallocation suggestions only on simple loops that have no returns/breaks/continues/gotos in them. - # True by default. - simple: true - range-loops: true # Report preallocation suggestions on range loops, true by default - for-loops: false # Report preallocation suggestions on for loops, false by default - nolintlint: - # Enable to ensure that nolint directives are all used. Default is true. - allow-unused: false - # Disable to ensure that nolint directives don't have a leading space. Default is true. - allow-leading-space: true - # Exclude following linters from requiring an explanation. Default is []. - allow-no-explanation: [] - # Enable to require an explanation of nonzero length after each nolint directive. Default is false. - require-explanation: true - # Enable to require nolint directives to mention the specific linter being suppressed. Default is false. - require-specific: true - rowserrcheck: - packages: - - github.com/jmoiron/sqlx - testpackage: - # regexp pattern to skip files - skip-regexp: (export|internal)_test\.go - unparam: - # Inspect exported functions, default is false. Set to true if no external program/library imports your code. - # XXX: if you enable this setting, unparam will report a lot of false-positives in text editors: - # if it's called for subdir of a project it can't find external interfaces. All text editor integrations - # with golangci-lint call it on a directory with the changed file. - check-exported: false - unused: - # treat code as a program (not a library) and report unused exported identifiers; default is false. - # XXX: if you enable this setting, unused will report a lot of false-positives in text editors: - # if it's called for subdir of a project it can't find funcs usages. All text editor integrations - # with golangci-lint call it on a directory with the changed file. - check-exported: false - whitespace: - multi-if: false # Enforces newlines (or comments) after every multi-line if statement - multi-func: false # Enforces newlines (or comments) after every multi-line function signature - wsl: - # If true append is only allowed to be cuddled if appending value is - # matching variables, fields or types on line above. Default is true. - strict-append: true - # Allow calls and assignments to be cuddled as long as the lines have any - # matching variables, fields or types. Default is true. - allow-assign-and-call: true - # Allow multiline assignments to be cuddled. Default is true. - allow-multiline-assign: true - # Allow declarations (var) to be cuddled. - allow-cuddle-declarations: true - # Allow trailing comments in ending of blocks - allow-trailing-comment: false - # Force newlines in end of case at this limit (0 = never). - force-case-trailing-whitespace: 0 - # Force cuddling of err checks with err var assignment - force-err-cuddling: false - # Allow leading comments to be separated with empty liens - allow-separated-leading-comment: false - gofumpt: - # Choose whether or not to use the extra rules that are disabled - # by default - extra-rules: false - - # The custom section can be used to define linter plugins to be loaded at runtime. See README doc - # for more info. - custom: - # Each custom linter should have a unique name. - #example: - # The path to the plugin *.so. Can be absolute or local. Required for each custom linter - #path: /path/to/example.so - # The description of the linter. Optional, just for documentation purposes. - #description: This is an example usage of a plugin linter. - # Intended to point to the repo location of the linter. Optional, just for documentation purposes. - #original-url: github.com/golangci/example-linter - -linters: - enable: - - megacheck - - govet - - gosec - - bodyclose - - golint - - unconvert - - dupl - - misspell - - dogsled - - prealloc - - exportloopref - - exhaustive - - sqlclosecheck - - goconst - - godot - disable: - - gocritic # use this for very opinionated linting - - whitespace - - wsl - - goerr113 - - testpackage - - nlreturn - - gci - - errorlint - - musttag - disable-all: false - presets: - - bugs - - unused - fast: false - - -issues: - # List of regexps of issue texts to exclude, empty list by default. - # But independently from 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` - exclude: - - Using the variable on range scope .* in function literal - - which can be annoying to use - - Error return value of `tx.Rollback` is not checked - - declaration of "err" shadows - # Excluding configuration per-path, per-linter, per-text and per-source - exclude-rules: - - linters: - - gosec - text: "G402:" - - linters: - - gosimple - text: "S1016:" - - # Exclude some linters from running on tests files. - - path: _test\.go - linters: - - gocyclo - - errcheck - - dupl - - gosec - - goconst - - lll - - # Exclude known linters from partially hard-vendored code, - # which is impossible to exclude via "nolint" comments. - - path: internal/hmac/ - text: "weak cryptographic primitive" - linters: - - gosec - - # Exclude some staticcheck messages - - linters: - - staticcheck - text: "SA1019:" - - # Exclude lll issues for long lines with go:generate - - linters: - - lll - source: "^//go:generate " - - # Independently from 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 value for this option is true. - exclude-use-default: false - - # The default value is false. If set to true exclude and exclude-rules - # regular expressions become case sensitive. - exclude-case-sensitive: false - - # The list of ids of default excludes to include or disable. By default it's empty. - include: - - EXC0002 # disable excluding of issues about comments from golint - - # Maximum issues count per one linter. Set to 0 to disable. Default is 50. - max-issues-per-linter: 0 - - # Maximum count of issues with the same text. Set to 0 to disable. Default is 3. - max-same-issues: 0 - - # 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 is false. - new: false - - # Show only new issues created after git revision `REV` - new-from-rev: "" - - # Show only new issues created in git patch with set file path. - #new-from-patch: path/to/patch/file - -severity: - # Default value is empty string. - # 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-severity: error - - # The default value is false. - # If set to true severity-rules regular expressions become case sensitive. - case-sensitive: false - - # Default value is empty list. - # 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. - rules: - - linters: - - dupl - severity: info diff --git a/cmd/main.go b/cmd/main.go index d001c44..9b29c9b 100644 --- a/cmd/main.go +++ b/cmd/main.go @@ -15,7 +15,7 @@ import ( "github.com/bitcoin-sv/spv-wallet-web-backend/transports/http/endpoints" httpserver "github.com/bitcoin-sv/spv-wallet-web-backend/transports/http/server" "github.com/bitcoin-sv/spv-wallet-web-backend/transports/websocket" - + "github.com/rs/zerolog/log" "github.com/spf13/viper" ) @@ -39,7 +39,7 @@ func main() { } db := databases.SetUpDatabase(log) - defer db.Close() // nolint: all + defer db.Close() //nolint: all repo := db_users.NewUsersRepository(db) @@ -64,12 +64,7 @@ func main() { server.ApplyConfiguration(endpoints.SetupWalletRoutes(s, db, log, ws)) server.ApplyConfiguration(ws.SetupEntrypoint) - go func() { - if err := server.Start(); err != nil && !errors.Is(err, http.ErrServerClosed) { - log.Error().Msgf("cannot start server because of an error: %v", err) - os.Exit(1) - } - }() + go startServer(server) quit := make(chan os.Signal, 1) signal.Notify(quit, syscall.SIGTERM, syscall.SIGINT) @@ -83,3 +78,10 @@ func main() { log.Error().Msgf("failed to stop websocket server: %v", err) } } + +func startServer(server *httpserver.HttpServer) { + if err := server.Start(); err != nil && !errors.Is(err, http.ErrServerClosed) { + log.Error().Msgf("cannot start server because of an error: %v", err) + os.Exit(1) + } +} diff --git a/config/config.go b/config/config.go index 59ec7f7..7596db8 100644 --- a/config/config.go +++ b/config/config.go @@ -33,7 +33,7 @@ const ( // EnvHttpServerCorsAllowedDomains http server cors origin allowed domains. EnvHttpServerCorsAllowedDomains = "http.server.cors.allowedDomains" // EnvHttpServerSessionSecret gin session store secret to encrypt session data in database. - EnvHttpServerSessionSecret = "http.server.session.secret" // nolint: gosec + EnvHttpServerSessionSecret = "http.server.session.secret" //nolint: gosec ) // Define basic spv-wallet config keys. diff --git a/config/databases/databases.go b/config/databases/databases.go index 4371ea6..fd10072 100644 --- a/config/databases/databases.go +++ b/config/databases/databases.go @@ -1,17 +1,15 @@ package databases import ( - "github.com/bitcoin-sv/spv-wallet-web-backend/config" - - "github.com/rs/zerolog" - "database/sql" "fmt" + "github.com/bitcoin-sv/spv-wallet-web-backend/config" "github.com/golang-migrate/migrate/v4" "github.com/golang-migrate/migrate/v4/database/postgres" - _ "github.com/golang-migrate/migrate/v4/source/file" // nolint: golint + _ "github.com/golang-migrate/migrate/v4/source/file" //nolint: golint _ "github.com/lib/pq" + "github.com/rs/zerolog" "github.com/spf13/viper" ) diff --git a/domain/services.go b/domain/services.go index 9538ab9..81516a6 100644 --- a/domain/services.go +++ b/domain/services.go @@ -7,7 +7,6 @@ import ( "github.com/bitcoin-sv/spv-wallet-web-backend/domain/transactions" "github.com/bitcoin-sv/spv-wallet-web-backend/domain/users" "github.com/bitcoin-sv/spv-wallet-web-backend/transports/spvwallet" - "github.com/rs/zerolog" ) diff --git a/domain/transactions/transactions_service.go b/domain/transactions/transactions_service.go index 4009419..9dbb10e 100644 --- a/domain/transactions/transactions_service.go +++ b/domain/transactions/transactions_service.go @@ -4,14 +4,12 @@ import ( "math" "time" - "github.com/bitcoin-sv/spv-wallet-web-backend/domain/users" - "github.com/bitcoin-sv/spv-wallet-web-backend/notification" - - "github.com/rs/zerolog" - "github.com/avast/retry-go/v4" "github.com/bitcoin-sv/spv-wallet-go-client/transports" + "github.com/bitcoin-sv/spv-wallet-web-backend/domain/users" + "github.com/bitcoin-sv/spv-wallet-web-backend/notification" "github.com/bitcoin-sv/spv-wallet/models" + "github.com/rs/zerolog" ) // TransactionService represents service whoch contains methods linked with transactions. diff --git a/domain/users/users_service.go b/domain/users/users_service.go index b708e41..3529864 100644 --- a/domain/users/users_service.go +++ b/domain/users/users_service.go @@ -13,15 +13,13 @@ import ( "strings" "time" - "github.com/rs/zerolog" - + "github.com/bitcoin-sv/spv-wallet-web-backend/config" + "github.com/bitcoin-sv/spv-wallet-web-backend/encryption" "github.com/libsv/go-bk/bip32" "github.com/libsv/go-bk/bip39" "github.com/libsv/go-bk/chaincfg" + "github.com/rs/zerolog" "github.com/spf13/viper" - - "github.com/bitcoin-sv/spv-wallet-web-backend/config" - "github.com/bitcoin-sv/spv-wallet-web-backend/encryption" ) // CredentialsError Generic error type / wrapper for Credentials errors. @@ -169,7 +167,7 @@ func (s *UserService) CreateNewUser(email, password string) (*CreatedUser, error CreatedAt: time.Now(), } - if err := s.InsertUser(user); err != nil { + if err = s.InsertUser(user); err != nil { e := &UserError{err.Error()} s.log.Error(). Str("newUserEmail", email). @@ -448,7 +446,7 @@ func calculateBalance(satoshis uint64) (*Balance, error) { if err != nil { return nil, fmt.Errorf("error during getting exchange rate: %w", err) } - defer res.Body.Close() // nolint: all + defer res.Body.Close() //nolint: all // Parse response body. var exchangeRate ExchangeRate diff --git a/encryption/hash.go b/encryption/hash.go index cbe17ff..e246a2b 100644 --- a/encryption/hash.go +++ b/encryption/hash.go @@ -5,7 +5,6 @@ import ( "fmt" "github.com/bitcoin-sv/spv-wallet-web-backend/config" - "github.com/spf13/viper" ) diff --git a/logging/logging.go b/logging/logging.go index 4113f01..5785e90 100644 --- a/logging/logging.go +++ b/logging/logging.go @@ -6,7 +6,6 @@ import ( "time" "github.com/bitcoin-sv/spv-wallet-web-backend/config" - "github.com/rs/zerolog" "github.com/spf13/viper" "go.elastic.co/ecszerolog" diff --git a/notification/notification.go b/notification/notification.go index d8b6321..88300bb 100644 --- a/notification/notification.go +++ b/notification/notification.go @@ -5,7 +5,6 @@ import ( "time" "github.com/bitcoin-sv/spv-wallet-web-backend/transports/spvwallet" - "github.com/bitcoin-sv/spv-wallet/models" ) diff --git a/tests/data/faker.go b/tests/data/faker.go index b29e64a..64cb02c 100644 --- a/tests/data/faker.go +++ b/tests/data/faker.go @@ -2,7 +2,6 @@ package data import ( "github.com/bitcoin-sv/spv-wallet-web-backend/transports/spvwallet" - "github.com/brianvoe/gofakeit/v6" ) diff --git a/tests/unit/domain/transactions/transactions_service_test.go b/tests/unit/domain/transactions/transactions_service_test.go index 794dd28..8f77e18 100644 --- a/tests/unit/domain/transactions/transactions_service_test.go +++ b/tests/unit/domain/transactions/transactions_service_test.go @@ -1,25 +1,21 @@ package transactions_test import ( - "github.com/bitcoin-sv/spv-wallet-web-backend/notification" - - "github.com/rs/zerolog" - "github.com/stretchr/testify/require" - "errors" "testing" + "github.com/bitcoin-sv/spv-wallet-web-backend/domain/transactions" + "github.com/bitcoin-sv/spv-wallet-web-backend/domain/users" + "github.com/bitcoin-sv/spv-wallet-web-backend/notification" "github.com/bitcoin-sv/spv-wallet-web-backend/tests/data" mock "github.com/bitcoin-sv/spv-wallet-web-backend/tests/mocks" "github.com/bitcoin-sv/spv-wallet-web-backend/tests/utils" - - "github.com/bitcoin-sv/spv-wallet-web-backend/domain/transactions" - "github.com/bitcoin-sv/spv-wallet-web-backend/domain/users" "github.com/bitcoin-sv/spv-wallet-web-backend/transports/spvwallet" - "github.com/brianvoe/gofakeit/v6" "github.com/golang/mock/gomock" + "github.com/rs/zerolog" "github.com/stretchr/testify/assert" + "github.com/stretchr/testify/require" ) func TestCreateTransaction(t *testing.T) { diff --git a/tests/unit/domain/users/user_service_test.go b/tests/unit/domain/users/user_service_test.go index 1a0db40..e4b73a9 100644 --- a/tests/unit/domain/users/user_service_test.go +++ b/tests/unit/domain/users/user_service_test.go @@ -5,14 +5,12 @@ import ( "errors" "testing" - "github.com/rs/zerolog" - + "github.com/bitcoin-sv/spv-wallet-web-backend/domain/users" + mock "github.com/bitcoin-sv/spv-wallet-web-backend/tests/mocks" "github.com/golang/mock/gomock" + "github.com/rs/zerolog" "github.com/stretchr/testify/assert" "github.com/stretchr/testify/require" - - "github.com/bitcoin-sv/spv-wallet-web-backend/domain/users" - mock "github.com/bitcoin-sv/spv-wallet-web-backend/tests/mocks" ) func TestCreateNewUser_ReturnsUser(t *testing.T) { diff --git a/tests/unit/encryption/encrypt_test.go b/tests/unit/encryption/encrypt_test.go index 116166b..efe2333 100644 --- a/tests/unit/encryption/encrypt_test.go +++ b/tests/unit/encryption/encrypt_test.go @@ -4,7 +4,6 @@ import ( "testing" "github.com/bitcoin-sv/spv-wallet-web-backend/encryption" - "github.com/stretchr/testify/assert" ) diff --git a/tests/unit/transports/http/auth/session_test.go b/tests/unit/transports/http/auth/session_test.go index b936a3f..fc6bb74 100644 --- a/tests/unit/transports/http/auth/session_test.go +++ b/tests/unit/transports/http/auth/session_test.go @@ -6,12 +6,10 @@ import ( "github.com/bitcoin-sv/spv-wallet-web-backend/domain/users" "github.com/bitcoin-sv/spv-wallet-web-backend/transports/http/auth" - + "github.com/brianvoe/gofakeit/v6" "github.com/gin-contrib/sessions" "github.com/gin-contrib/sessions/memstore" "github.com/gin-gonic/gin" - - "github.com/brianvoe/gofakeit/v6" "github.com/stretchr/testify/assert" ) diff --git a/transports/http/auth/auth_middleware.go b/transports/http/auth/auth_middleware.go index b65a790..c1016bc 100644 --- a/transports/http/auth/auth_middleware.go +++ b/transports/http/auth/auth_middleware.go @@ -7,7 +7,6 @@ import ( "github.com/bitcoin-sv/spv-wallet-web-backend/domain" "github.com/bitcoin-sv/spv-wallet-web-backend/domain/users" - "github.com/gin-contrib/sessions" "github.com/gin-gonic/gin" ) diff --git a/transports/http/auth/session.go b/transports/http/auth/session.go index 4ecd2ff..428ad11 100644 --- a/transports/http/auth/session.go +++ b/transports/http/auth/session.go @@ -2,7 +2,6 @@ package auth import ( "github.com/bitcoin-sv/spv-wallet-web-backend/domain/users" - "github.com/gin-contrib/sessions" "github.com/gin-gonic/gin" ) diff --git a/transports/http/auth/session_middleware.go b/transports/http/auth/session_middleware.go index c9d8f5d..f9a3b8d 100644 --- a/transports/http/auth/session_middleware.go +++ b/transports/http/auth/session_middleware.go @@ -6,7 +6,6 @@ import ( "github.com/bitcoin-sv/spv-wallet-web-backend/config" router "github.com/bitcoin-sv/spv-wallet-web-backend/transports/http/endpoints/routes" - "github.com/gin-contrib/sessions" "github.com/gin-contrib/sessions/postgres" "github.com/gin-gonic/gin" diff --git a/transports/http/auth/websocket_middleware.go b/transports/http/auth/websocket_middleware.go index a487ccc..65c7254 100644 --- a/transports/http/auth/websocket_middleware.go +++ b/transports/http/auth/websocket_middleware.go @@ -3,11 +3,12 @@ package auth import ( "context" "fmt" + "net/http" + "strconv" + "github.com/centrifugal/centrifuge" "github.com/gin-contrib/sessions" "github.com/gin-gonic/gin" - "net/http" - "strconv" ) type contextKey int diff --git a/transports/http/endpoints/api/access/endpoints.go b/transports/http/endpoints/api/access/endpoints.go index af4e33a..894ad88 100644 --- a/transports/http/endpoints/api/access/endpoints.go +++ b/transports/http/endpoints/api/access/endpoints.go @@ -6,13 +6,10 @@ import ( "github.com/bitcoin-sv/spv-wallet-web-backend/domain" "github.com/bitcoin-sv/spv-wallet-web-backend/domain/users" - - "github.com/rs/zerolog" - "github.com/bitcoin-sv/spv-wallet-web-backend/transports/http/auth" router "github.com/bitcoin-sv/spv-wallet-web-backend/transports/http/endpoints/routes" - "github.com/gin-gonic/gin" + "github.com/rs/zerolog" ) type handler struct { diff --git a/transports/http/endpoints/api/contacts/endpoints.go b/transports/http/endpoints/api/contacts/endpoints.go index 990c8e5..daf296c 100644 --- a/transports/http/endpoints/api/contacts/endpoints.go +++ b/transports/http/endpoints/api/contacts/endpoints.go @@ -5,14 +5,11 @@ import ( "github.com/bitcoin-sv/spv-wallet-web-backend/domain" "github.com/bitcoin-sv/spv-wallet-web-backend/domain/contacts" - "github.com/bitcoin-sv/spv-wallet/models" - - "github.com/rs/zerolog" - "github.com/bitcoin-sv/spv-wallet-web-backend/transports/http/auth" router "github.com/bitcoin-sv/spv-wallet-web-backend/transports/http/endpoints/routes" - + "github.com/bitcoin-sv/spv-wallet/models" "github.com/gin-gonic/gin" + "github.com/rs/zerolog" ) type handler struct { diff --git a/transports/http/endpoints/api/cors/cors_middleware.go b/transports/http/endpoints/api/cors/cors_middleware.go index e7a2440..c03d92f 100644 --- a/transports/http/endpoints/api/cors/cors_middleware.go +++ b/transports/http/endpoints/api/cors/cors_middleware.go @@ -4,7 +4,6 @@ import ( "net/http" "github.com/bitcoin-sv/spv-wallet-web-backend/config" - "github.com/gin-gonic/gin" "github.com/spf13/viper" ) diff --git a/transports/http/endpoints/api/transactions/endpoints.go b/transports/http/endpoints/api/transactions/endpoints.go index 60db108..15b1c79 100644 --- a/transports/http/endpoints/api/transactions/endpoints.go +++ b/transports/http/endpoints/api/transactions/endpoints.go @@ -4,19 +4,16 @@ import ( "net/http" "strconv" + "github.com/bitcoin-sv/spv-wallet-go-client/transports" "github.com/bitcoin-sv/spv-wallet-web-backend/domain" "github.com/bitcoin-sv/spv-wallet-web-backend/domain/transactions" "github.com/bitcoin-sv/spv-wallet-web-backend/domain/users" "github.com/bitcoin-sv/spv-wallet-web-backend/notification" - "github.com/bitcoin-sv/spv-wallet-web-backend/transports/websocket" - - "github.com/bitcoin-sv/spv-wallet-go-client/transports" - "github.com/rs/zerolog" - "github.com/bitcoin-sv/spv-wallet-web-backend/transports/http/auth" router "github.com/bitcoin-sv/spv-wallet-web-backend/transports/http/endpoints/routes" - + "github.com/bitcoin-sv/spv-wallet-web-backend/transports/websocket" "github.com/gin-gonic/gin" + "github.com/rs/zerolog" ) type handler struct { diff --git a/transports/http/endpoints/api/users/endpoints.go b/transports/http/endpoints/api/users/endpoints.go index 70f36a1..2717efc 100644 --- a/transports/http/endpoints/api/users/endpoints.go +++ b/transports/http/endpoints/api/users/endpoints.go @@ -4,14 +4,12 @@ import ( "fmt" "net/http" - "github.com/rs/zerolog" - - "github.com/gin-gonic/gin" - "github.com/bitcoin-sv/spv-wallet-web-backend/domain" "github.com/bitcoin-sv/spv-wallet-web-backend/domain/users" "github.com/bitcoin-sv/spv-wallet-web-backend/transports/http/auth" router "github.com/bitcoin-sv/spv-wallet-web-backend/transports/http/endpoints/routes" + "github.com/gin-gonic/gin" + "github.com/rs/zerolog" ) type handler struct { diff --git a/transports/http/endpoints/status/endpoints.go b/transports/http/endpoints/status/endpoints.go index 619b32d..bf5c7eb 100644 --- a/transports/http/endpoints/status/endpoints.go +++ b/transports/http/endpoints/status/endpoints.go @@ -2,7 +2,6 @@ package status import ( router "github.com/bitcoin-sv/spv-wallet-web-backend/transports/http/endpoints/routes" - "github.com/gin-gonic/gin" ) diff --git a/transports/http/endpoints/swagger/endpoints.go b/transports/http/endpoints/swagger/endpoints.go index 86e34d6..c42d00d 100644 --- a/transports/http/endpoints/swagger/endpoints.go +++ b/transports/http/endpoints/swagger/endpoints.go @@ -3,7 +3,6 @@ package swagger import ( _ "github.com/bitcoin-sv/spv-wallet-web-backend/docs" // docs package is generated by Swag CLI, we have to import it. router "github.com/bitcoin-sv/spv-wallet-web-backend/transports/http/endpoints/routes" - "github.com/gin-gonic/gin" swaggerfiles "github.com/swaggo/files" ginSwagger "github.com/swaggo/gin-swagger" diff --git a/transports/http/endpoints/wallet_endpoints.go b/transports/http/endpoints/wallet_endpoints.go index 58682bd..2a33c63 100644 --- a/transports/http/endpoints/wallet_endpoints.go +++ b/transports/http/endpoints/wallet_endpoints.go @@ -5,12 +5,6 @@ import ( "errors" "github.com/bitcoin-sv/spv-wallet-web-backend/domain" - "github.com/bitcoin-sv/spv-wallet-web-backend/transports/http/endpoints/status" - "github.com/bitcoin-sv/spv-wallet-web-backend/transports/http/endpoints/swagger" - "github.com/bitcoin-sv/spv-wallet-web-backend/transports/websocket" - - "github.com/rs/zerolog" - "github.com/bitcoin-sv/spv-wallet-web-backend/transports/http/auth" "github.com/bitcoin-sv/spv-wallet-web-backend/transports/http/endpoints/api/access" "github.com/bitcoin-sv/spv-wallet-web-backend/transports/http/endpoints/api/config" @@ -18,9 +12,12 @@ import ( "github.com/bitcoin-sv/spv-wallet-web-backend/transports/http/endpoints/api/transactions" "github.com/bitcoin-sv/spv-wallet-web-backend/transports/http/endpoints/api/users" router "github.com/bitcoin-sv/spv-wallet-web-backend/transports/http/endpoints/routes" + "github.com/bitcoin-sv/spv-wallet-web-backend/transports/http/endpoints/status" + "github.com/bitcoin-sv/spv-wallet-web-backend/transports/http/endpoints/swagger" httpserver "github.com/bitcoin-sv/spv-wallet-web-backend/transports/http/server" - + "github.com/bitcoin-sv/spv-wallet-web-backend/transports/websocket" "github.com/gin-gonic/gin" + "github.com/rs/zerolog" ) // SetupWalletRoutes main point where we're registering endpoints registrars (handlers that will register endpoints in gin engine) diff --git a/transports/http/server/http_server.go b/transports/http/server/http_server.go index ec83304..80ad377 100644 --- a/transports/http/server/http_server.go +++ b/transports/http/server/http_server.go @@ -7,13 +7,11 @@ import ( "net/http" "time" - "github.com/rs/zerolog" - "github.com/bitcoin-sv/spv-wallet-web-backend/config" "github.com/bitcoin-sv/spv-wallet-web-backend/transports/http/endpoints/api/cors" "github.com/bitcoin-sv/spv-wallet-web-backend/util" - "github.com/gin-gonic/gin" + "github.com/rs/zerolog" "github.com/spf13/viper" ) diff --git a/transports/http/server/http_server_test.go b/transports/http/server/http_server_test.go index 765dde2..c7b87bc 100644 --- a/transports/http/server/http_server_test.go +++ b/transports/http/server/http_server_test.go @@ -2,12 +2,12 @@ package httpserver import ( "context" - "github.com/rs/zerolog" "net/http" "net/http/httptest" "testing" "github.com/gin-gonic/gin" + "github.com/rs/zerolog" "github.com/stretchr/testify/require" ) diff --git a/transports/spvwallet/admin_client.go b/transports/spvwallet/admin_client.go index 746fbbf..ee59df6 100644 --- a/transports/spvwallet/admin_client.go +++ b/transports/spvwallet/admin_client.go @@ -4,14 +4,12 @@ import ( "context" "fmt" - "github.com/rs/zerolog" - walletclient "github.com/bitcoin-sv/spv-wallet-go-client" + "github.com/bitcoin-sv/spv-wallet-web-backend/config" "github.com/bitcoin-sv/spv-wallet/models" "github.com/libsv/go-bk/bip32" + "github.com/rs/zerolog" "github.com/spf13/viper" - - "github.com/bitcoin-sv/spv-wallet-web-backend/config" ) // AdminWalletClient is a wrapper for Admin SPV Wallet Client. diff --git a/transports/spvwallet/client.go b/transports/spvwallet/client.go index 7c7ca0d..a42d1eb 100644 --- a/transports/spvwallet/client.go +++ b/transports/spvwallet/client.go @@ -5,13 +5,11 @@ import ( "fmt" "math" - "github.com/rs/zerolog" - walletclient "github.com/bitcoin-sv/spv-wallet-go-client" "github.com/bitcoin-sv/spv-wallet-go-client/transports" - "github.com/bitcoin-sv/spv-wallet/models" - "github.com/bitcoin-sv/spv-wallet-web-backend/domain/users" + "github.com/bitcoin-sv/spv-wallet/models" + "github.com/rs/zerolog" ) // Client implements UserWalletClient interface which wraps the spv-wallet-go-client and provides methods for user. diff --git a/transports/spvwallet/client_factory_adapter.go b/transports/spvwallet/client_factory_adapter.go index 055645d..0c72c8c 100644 --- a/transports/spvwallet/client_factory_adapter.go +++ b/transports/spvwallet/client_factory_adapter.go @@ -1,12 +1,10 @@ package spvwallet import ( + walletclient "github.com/bitcoin-sv/spv-wallet-go-client" "github.com/bitcoin-sv/spv-wallet-web-backend/config" "github.com/bitcoin-sv/spv-wallet-web-backend/domain/users" - "github.com/rs/zerolog" - - walletclient "github.com/bitcoin-sv/spv-wallet-go-client" "github.com/spf13/viper" ) diff --git a/transports/websocket/log_handler.go b/transports/websocket/log_handler.go index 9f51fb6..e0df250 100644 --- a/transports/websocket/log_handler.go +++ b/transports/websocket/log_handler.go @@ -17,7 +17,7 @@ func newLogHandler(l *zerolog.Logger) *logHandler { } func (l *logHandler) Level() (level centrifuge.LogLevel) { - // nolint:exhaustive // we don't need to handle all cases + //nolint:exhaustive // we don't need to handle all cases switch l.logger.GetLevel() { case zerolog.TraceLevel: level = centrifuge.LogLevelTrace diff --git a/transports/websocket/notification.go b/transports/websocket/notification.go index 1bc745d..ee52f7d 100644 --- a/transports/websocket/notification.go +++ b/transports/websocket/notification.go @@ -3,12 +3,10 @@ package websocket import ( "encoding/json" - "github.com/rs/zerolog" - "github.com/bitcoin-sv/spv-wallet-web-backend/notification" - "github.com/bitcoin-sv/spv-wallet/models" "github.com/centrifugal/centrifuge" + "github.com/rs/zerolog" ) // Socket represents websocket server entrypoint used to publish messages via websocket communication. diff --git a/transports/websocket/websocket_server.go b/transports/websocket/websocket_server.go index 09f646c..10662be 100644 --- a/transports/websocket/websocket_server.go +++ b/transports/websocket/websocket_server.go @@ -8,14 +8,12 @@ import ( "net/http" "time" - "github.com/rs/zerolog" - "github.com/bitcoin-sv/spv-wallet-web-backend/domain" "github.com/bitcoin-sv/spv-wallet-web-backend/transports/http/auth" router "github.com/bitcoin-sv/spv-wallet-web-backend/transports/http/endpoints/routes" - "github.com/centrifugal/centrifuge" "github.com/gin-gonic/gin" + "github.com/rs/zerolog" ) // Server websocket server controller.