mirror of
https://github.com/umputun/reproxy.git
synced 2025-11-23 22:04:57 +02:00
build: migrate to golangci-lint v2 and Go 1.24
- Update golangci-lint configuration to v2 format - Upgrade golangci-lint action to v7 with v2.1.1 - Update Go version from 1.23 to 1.24 - Fix linting issues with strings.ReplaceAll - Use switch case in place of if-else chains
This commit is contained in:
12
.github/workflows/ci.yml
vendored
12
.github/workflows/ci.yml
vendored
@@ -11,10 +11,10 @@ jobs:
|
||||
runs-on: ubuntu-latest
|
||||
|
||||
steps:
|
||||
- name: set up go 1.23
|
||||
- name: set up go 1.24
|
||||
uses: actions/setup-go@v5
|
||||
with:
|
||||
go-version: "1.23"
|
||||
go-version: "1.24"
|
||||
id: go
|
||||
|
||||
- name: checkout
|
||||
@@ -38,14 +38,14 @@ jobs:
|
||||
TZ: "America/Chicago"
|
||||
|
||||
- name: golangci-lint
|
||||
uses: golangci/golangci-lint-action@v6
|
||||
uses: golangci/golangci-lint-action@v7
|
||||
with:
|
||||
version: v1.61
|
||||
version: v2.1.1
|
||||
|
||||
- name: golangci-lint on example directory
|
||||
uses: golangci/golangci-lint-action@v6
|
||||
uses: golangci/golangci-lint-action@v7
|
||||
with:
|
||||
version: v1.61
|
||||
version: v2.1.1
|
||||
args: --config ../../.golangci.yml
|
||||
working-directory: examples/plugin
|
||||
|
||||
|
||||
128
.golangci.yml
128
.golangci.yml
@@ -1,70 +1,72 @@
|
||||
run:
|
||||
timeout: 5m
|
||||
|
||||
linters-settings:
|
||||
govet:
|
||||
enable:
|
||||
- shadow
|
||||
goconst:
|
||||
min-len: 2
|
||||
min-occurrences: 2
|
||||
misspell:
|
||||
locale: US
|
||||
lll:
|
||||
line-length: 140
|
||||
gocritic:
|
||||
enabled-tags:
|
||||
- performance
|
||||
- style
|
||||
- experimental
|
||||
disabled-checks:
|
||||
- wrapperFunc
|
||||
- hugeParam
|
||||
- rangeValCopy
|
||||
- singleCaseSwitch
|
||||
- ifElseChain
|
||||
|
||||
version: "2"
|
||||
linters:
|
||||
default: none
|
||||
enable:
|
||||
- staticcheck
|
||||
- revive
|
||||
- govet
|
||||
- unconvert
|
||||
- unused
|
||||
- gosec
|
||||
- gocyclo
|
||||
- dupl
|
||||
- misspell
|
||||
- unparam
|
||||
- typecheck
|
||||
- ineffassign
|
||||
- stylecheck
|
||||
- gochecknoinits
|
||||
- gocritic
|
||||
- gocyclo
|
||||
- gosec
|
||||
- govet
|
||||
- ineffassign
|
||||
- misspell
|
||||
- nakedret
|
||||
- gosimple
|
||||
- prealloc
|
||||
fast: false
|
||||
disable-all: true
|
||||
|
||||
issues:
|
||||
exclude-dirs:
|
||||
- vendor
|
||||
exclude-rules:
|
||||
- text: "at least one file in a package should have a package comment"
|
||||
linters:
|
||||
- stylecheck
|
||||
- text: "should have a package comment"
|
||||
linters:
|
||||
- revive
|
||||
- path: _test\.go
|
||||
linters:
|
||||
- gosec
|
||||
- dupl
|
||||
- linters:
|
||||
- unparam
|
||||
- unused
|
||||
- revive
|
||||
path: _test\.go$
|
||||
text: "unused-parameter"
|
||||
exclude-use-default: false
|
||||
- revive
|
||||
- staticcheck
|
||||
- unconvert
|
||||
- unparam
|
||||
- unused
|
||||
settings:
|
||||
goconst:
|
||||
min-len: 2
|
||||
min-occurrences: 2
|
||||
gocritic:
|
||||
disabled-checks:
|
||||
- wrapperFunc
|
||||
- hugeParam
|
||||
- rangeValCopy
|
||||
- singleCaseSwitch
|
||||
- ifElseChain
|
||||
enabled-tags:
|
||||
- performance
|
||||
- style
|
||||
- experimental
|
||||
govet:
|
||||
enable:
|
||||
- shadow
|
||||
lll:
|
||||
line-length: 140
|
||||
misspell:
|
||||
locale: US
|
||||
exclusions:
|
||||
generated: lax
|
||||
rules:
|
||||
- linters:
|
||||
- staticcheck
|
||||
text: at least one file in a package should have a package comment
|
||||
- linters:
|
||||
- revive
|
||||
text: should have a package comment
|
||||
- linters:
|
||||
- dupl
|
||||
- gosec
|
||||
path: _test\.go
|
||||
- linters:
|
||||
- revive
|
||||
- unparam
|
||||
- unused
|
||||
path: _test\.go$
|
||||
text: unused-parameter
|
||||
paths:
|
||||
- vendor
|
||||
- third_party$
|
||||
- builtin$
|
||||
- examples$
|
||||
formatters:
|
||||
exclusions:
|
||||
generated: lax
|
||||
paths:
|
||||
- third_party$
|
||||
- builtin$
|
||||
- examples$
|
||||
|
||||
@@ -539,7 +539,7 @@ func (m URLMapper) ping() (string, error) {
|
||||
|
||||
resp, err := client.Get(m.PingURL)
|
||||
if err != nil {
|
||||
errMsg := strings.Replace(err.Error(), "\"", "", -1)
|
||||
errMsg := strings.ReplaceAll(err.Error(), "\"", "")
|
||||
errMsg = fmt.Sprintf("failed to ping for health %s, %s", m.PingURL, errMsg)
|
||||
return errMsg, fmt.Errorf("%s %s: %s, %v", m.Server, m.SrcMatch.String(), m.PingURL, errMsg)
|
||||
}
|
||||
|
||||
@@ -173,13 +173,14 @@ func (cc *ConsulCatalog) List() ([]discovery.URLMapper, error) {
|
||||
|
||||
if v, ok := c.Labels["reproxy.keep-host"]; ok {
|
||||
enabled = true
|
||||
if v == "true" || v == "yes" || v == "1" {
|
||||
switch v {
|
||||
case "true", "yes", "1":
|
||||
t := true
|
||||
keepHost = &t
|
||||
} else if v == "false" || v == "no" || v == "0" {
|
||||
case "false", "no", "0":
|
||||
f := false
|
||||
keepHost = &f
|
||||
} else {
|
||||
default:
|
||||
log.Printf("[WARN] invalid value for reproxy.keep-host: %s", v)
|
||||
}
|
||||
}
|
||||
|
||||
@@ -299,7 +299,7 @@ func makeBasicAuth(htpasswdFile string) ([]string, error) {
|
||||
basicAuthAllowed = strings.Split(string(data), "\n")
|
||||
for i, v := range basicAuthAllowed {
|
||||
basicAuthAllowed[i] = strings.TrimSpace(v)
|
||||
basicAuthAllowed[i] = strings.Replace(basicAuthAllowed[i], "\t", "", -1)
|
||||
basicAuthAllowed[i] = strings.ReplaceAll(basicAuthAllowed[i], "\t", "")
|
||||
}
|
||||
}
|
||||
return basicAuthAllowed, nil
|
||||
|
||||
Reference in New Issue
Block a user