chore: update Go, and linter

This commit is contained in:
Fernandez Ludovic
2023-07-08 15:47:33 +02:00
parent 09b74d7912
commit eeea0e75c9
6 changed files with 29 additions and 52 deletions

View File

@ -12,32 +12,23 @@ jobs:
name: Main Process name: Main Process
runs-on: ubuntu-latest runs-on: ubuntu-latest
env: env:
GO_VERSION: 1.19 GO_VERSION: '1.20'
GOLANGCI_LINT_VERSION: v1.50.0 GOLANGCI_LINT_VERSION: v1.53.3
CGO_ENABLED: 0 CGO_ENABLED: 0
steps: steps:
# https://github.com/marketplace/actions/setup-go-environment
- name: Set up Go ${{ env.GO_VERSION }}
uses: actions/setup-go@v2
with:
go-version: ${{ env.GO_VERSION }}
# https://github.com/marketplace/actions/checkout # https://github.com/marketplace/actions/checkout
- name: Check out code - name: Check out code
uses: actions/checkout@v2 uses: actions/checkout@v3
with: with:
fetch-depth: 0 fetch-depth: 0
# https://github.com/marketplace/actions/cache # https://github.com/marketplace/actions/setup-go-environment
- name: Cache Go modules - name: Set up Go ${{ env.GO_VERSION }}
uses: actions/cache@v3 uses: actions/setup-go@v4
with: with:
path: ~/go/pkg/mod go-version: ${{ env.GO_VERSION }}
key: ${{ runner.os }}-go-${{ hashFiles('**/go.sum') }}
restore-keys: |
${{ runner.os }}-go-
- name: Check and get dependencies - name: Check and get dependencies
run: | run: |

View File

@ -19,33 +19,15 @@ jobs:
os: [ubuntu-latest, macos-latest, windows-latest] os: [ubuntu-latest, macos-latest, windows-latest]
steps: steps:
# https://github.com/marketplace/actions/setup-go-environment
- name: Set up Go ${{ matrix.go-version }}
uses: actions/setup-go@v2
with:
go-version: ${{ matrix.go-version }}
# https://github.com/marketplace/actions/checkout # https://github.com/marketplace/actions/checkout
- name: Checkout code - name: Checkout code
uses: actions/checkout@v2 uses: actions/checkout@v3
# https://github.com/marketplace/actions/cache # https://github.com/marketplace/actions/setup-go-environment
- name: Cache Go modules - name: Set up Go ${{ matrix.go-version }}
uses: actions/cache@v3 uses: actions/setup-go@v4
with: with:
# In order: go-version: ${{ matrix.go-version }}
# * 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-
- name: Test - name: Test
run: go test -v -cover ./... run: go test -v -cover ./...

View File

@ -9,23 +9,23 @@ jobs:
name: Release Process name: Release Process
runs-on: ubuntu-latest runs-on: ubuntu-latest
env: env:
GO_VERSION: 1.19 GO_VERSION: '1.20'
CGO_ENABLED: 0 CGO_ENABLED: 0
steps: steps:
# https://github.com/marketplace/actions/setup-go-environment
- name: Set up Go ${{ env.GO_VERSION }}
uses: actions/setup-go@v2
with:
go-version: ${{ env.GO_VERSION }}
# https://github.com/marketplace/actions/checkout # https://github.com/marketplace/actions/checkout
- name: Check out code - name: Check out code
uses: actions/checkout@v2 uses: actions/checkout@v3
with: with:
fetch-depth: 0 fetch-depth: 0
# https://github.com/marketplace/actions/setup-go-environment
- name: Set up Go ${{ env.GO_VERSION }}
uses: actions/setup-go@v4
with:
go-version: ${{ env.GO_VERSION }}
- name: dockerhub-login - name: dockerhub-login
uses: docker/login-action@v1 uses: docker/login-action@v1
with: with:

View File

@ -20,10 +20,13 @@ linters-settings:
gofumpt: gofumpt:
extra-rules: true extra-rules: true
depguard: depguard:
list-type: blacklist rules:
include-go-root: false main:
packages: deny:
- github.com/pkg/errors - pkg: "github.com/instana/testify"
desc: not allowed
- pkg: "github.com/pkg/errors"
desc: Should be replaced by standard lib errors package
godox: godox:
keywords: keywords:
- FIXME - FIXME

1
app.go
View File

@ -54,6 +54,7 @@ func init() {
flag.StringVar(&name, "name", os.Getenv("WHOAMI_NAME"), "give me a name") flag.StringVar(&name, "name", os.Getenv("WHOAMI_NAME"), "give me a name")
} }
// Data whoami information.
type Data struct { type Data struct {
Hostname string `json:"hostname,omitempty"` Hostname string `json:"hostname,omitempty"`
IP []string `json:"ip,omitempty"` IP []string `json:"ip,omitempty"`

2
go.mod
View File

@ -1,5 +1,5 @@
module github.com/traefik/whoami module github.com/traefik/whoami
go 1.19 go 1.20
require github.com/gorilla/websocket v1.4.2 require github.com/gorilla/websocket v1.4.2