From 6ed00b545fd1c390ee2503f1b3b9c11e956006fe Mon Sep 17 00:00:00 2001 From: Fernandez Ludovic Date: Thu, 7 Sep 2023 22:05:16 +0200 Subject: [PATCH] chore: update Go, CI, and linter --- .github/workflows/go-cross.yml | 29 ++++++----------------------- .github/workflows/main.yml | 23 +++++++---------------- .golangci.yml | 12 +++++++----- contact.go | 2 +- domain.go | 2 +- nameserver.go | 6 +++--- 6 files changed, 25 insertions(+), 49 deletions(-) diff --git a/.github/workflows/go-cross.yml b/.github/workflows/go-cross.yml index 617df8f..5bce89e 100644 --- a/.github/workflows/go-cross.yml +++ b/.github/workflows/go-cross.yml @@ -11,37 +11,20 @@ jobs: strategy: matrix: - go-version: [ 1.19, 1.x ] + go-version: [ stable, oldstable ] os: [ubuntu-latest, macos-latest, windows-latest] steps: - # https://github.com/marketplace/actions/setup-go-environment - - name: Set up Go ${{ matrix.go-version }} - uses: actions/setup-go@v3 - with: - go-version: ${{ matrix.go-version }} # https://github.com/marketplace/actions/checkout - name: Checkout code - uses: actions/checkout@v3 + uses: actions/checkout@v4 - # https://github.com/marketplace/actions/cache - - name: Cache Go modules - uses: actions/cache@v3 + # https://github.com/marketplace/actions/setup-go-environment + - name: Set up Go ${{ matrix.go-version }} + uses: actions/setup-go@v4 with: - # In order: - # * Module download cache - # * Build cache (Linux) - # * Build cache (Mac) - # * Build cache (Windows) - path: | - ~/go/pkg/mod - ~/.cache/go-build - ~/Library/Caches/go-build - %LocalAppData%\go-build - key: ${{ runner.os }}-${{ matrix.go-version }}-go-${{ hashFiles('**/go.sum') }} - restore-keys: | - ${{ runner.os }}-${{ matrix.go-version }}-go- + go-version: ${{ matrix.go-version }} - name: Test run: go test -v -cover ./... diff --git a/.github/workflows/main.yml b/.github/workflows/main.yml index e3fb8df..3c4dbf0 100644 --- a/.github/workflows/main.yml +++ b/.github/workflows/main.yml @@ -14,32 +14,23 @@ jobs: name: Main Process runs-on: ubuntu-latest env: - GO_VERSION: 1.19 - GOLANGCI_LINT_VERSION: v1.50.1 + GO_VERSION: stable + GOLANGCI_LINT_VERSION: v1.54.2 CGO_ENABLED: 0 steps: - # https://github.com/marketplace/actions/setup-go-environment - - name: Set up Go ${{ env.GO_VERSION }} - uses: actions/setup-go@v3 - with: - go-version: ${{ env.GO_VERSION }} - # https://github.com/marketplace/actions/checkout - name: Check out code - uses: actions/checkout@v3 + uses: actions/checkout@v4 with: fetch-depth: 0 - # https://github.com/marketplace/actions/cache - - name: Cache Go modules - uses: actions/cache@v3 + # https://github.com/marketplace/actions/setup-go-environment + - name: Set up Go ${{ env.GO_VERSION }} + uses: actions/setup-go@v4 with: - path: ~/go/pkg/mod - key: ${{ runner.os }}-go-${{ hashFiles('**/go.sum') }} - restore-keys: | - ${{ runner.os }}-go- + go-version: ${{ env.GO_VERSION }} - name: Check and get dependencies run: | diff --git a/.golangci.yml b/.golangci.yml index 3bd8e16..47b311d 100644 --- a/.golangci.yml +++ b/.golangci.yml @@ -26,11 +26,13 @@ linters-settings: gofumpt: extra-rules: true depguard: - list-type: blacklist - include-go-root: false - packages: - - github.com/sirupsen/logrus - - github.com/pkg/errors + rules: + main: + deny: + - pkg: "github.com/instana/testify" + desc: not allowed + - pkg: "github.com/pkg/errors" + desc: Should be replaced by standard lib errors package gocritic: enabled-tags: - diagnostic diff --git a/contact.go b/contact.go index 65aeaa2..32cabf2 100644 --- a/contact.go +++ b/contact.go @@ -144,6 +144,6 @@ type ContactInfoResponse struct { // ContactListResponse API model. type ContactListResponse struct { - Count int + Count int `mapstructure:"count"` Contacts []Contact `mapstructure:"contact"` } diff --git a/domain.go b/domain.go index 8fc1ca8..8e768d4 100644 --- a/domain.go +++ b/domain.go @@ -332,7 +332,7 @@ type DomainListRequest struct { // DomainList API model. type DomainList struct { - Count int + Count int `mapstructure:"count"` Domains []DomainInfoResponse `mapstructure:"domain"` } diff --git a/nameserver.go b/nameserver.go index 0592c38..2bf1e60 100644 --- a/nameserver.go +++ b/nameserver.go @@ -184,8 +184,8 @@ func (s *NameserverService) FindRecordByID(recID int) (*NameserverRecord, *Names // NameserverCheckResponse API model. type NameserverCheckResponse struct { - Details []string - Status string + Details []string `mapstructure:"details"` + Status string `mapstructure:"status"` } // NameserverRecordRequest API model. @@ -269,7 +269,7 @@ type NameserverRecord struct { // NamserverListResponse API model. type NamserverListResponse struct { - Count int + Count int `mapstructure:"count"` Domains []NameserverDomain `mapstructure:"domains"` }