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
|
runs-on: ubuntu-latest
|
||||||
|
|
||||||
steps:
|
steps:
|
||||||
- name: set up go 1.23
|
- name: set up go 1.24
|
||||||
uses: actions/setup-go@v5
|
uses: actions/setup-go@v5
|
||||||
with:
|
with:
|
||||||
go-version: "1.23"
|
go-version: "1.24"
|
||||||
id: go
|
id: go
|
||||||
|
|
||||||
- name: checkout
|
- name: checkout
|
||||||
@@ -38,14 +38,14 @@ jobs:
|
|||||||
TZ: "America/Chicago"
|
TZ: "America/Chicago"
|
||||||
|
|
||||||
- name: golangci-lint
|
- name: golangci-lint
|
||||||
uses: golangci/golangci-lint-action@v6
|
uses: golangci/golangci-lint-action@v7
|
||||||
with:
|
with:
|
||||||
version: v1.61
|
version: v2.1.1
|
||||||
|
|
||||||
- name: golangci-lint on example directory
|
- name: golangci-lint on example directory
|
||||||
uses: golangci/golangci-lint-action@v6
|
uses: golangci/golangci-lint-action@v7
|
||||||
with:
|
with:
|
||||||
version: v1.61
|
version: v2.1.1
|
||||||
args: --config ../../.golangci.yml
|
args: --config ../../.golangci.yml
|
||||||
working-directory: examples/plugin
|
working-directory: examples/plugin
|
||||||
|
|
||||||
|
|||||||
128
.golangci.yml
128
.golangci.yml
@@ -1,70 +1,72 @@
|
|||||||
run:
|
version: "2"
|
||||||
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
|
|
||||||
|
|
||||||
linters:
|
linters:
|
||||||
|
default: none
|
||||||
enable:
|
enable:
|
||||||
- staticcheck
|
|
||||||
- revive
|
|
||||||
- govet
|
|
||||||
- unconvert
|
|
||||||
- unused
|
|
||||||
- gosec
|
|
||||||
- gocyclo
|
|
||||||
- dupl
|
- dupl
|
||||||
- misspell
|
|
||||||
- unparam
|
|
||||||
- typecheck
|
|
||||||
- ineffassign
|
|
||||||
- stylecheck
|
|
||||||
- gochecknoinits
|
- gochecknoinits
|
||||||
- gocritic
|
- gocritic
|
||||||
|
- gocyclo
|
||||||
|
- gosec
|
||||||
|
- govet
|
||||||
|
- ineffassign
|
||||||
|
- misspell
|
||||||
- nakedret
|
- nakedret
|
||||||
- gosimple
|
|
||||||
- prealloc
|
- prealloc
|
||||||
fast: false
|
- revive
|
||||||
disable-all: true
|
- staticcheck
|
||||||
|
- unconvert
|
||||||
issues:
|
- unparam
|
||||||
exclude-dirs:
|
- unused
|
||||||
- vendor
|
settings:
|
||||||
exclude-rules:
|
goconst:
|
||||||
- text: "at least one file in a package should have a package comment"
|
min-len: 2
|
||||||
linters:
|
min-occurrences: 2
|
||||||
- stylecheck
|
gocritic:
|
||||||
- text: "should have a package comment"
|
disabled-checks:
|
||||||
linters:
|
- wrapperFunc
|
||||||
- revive
|
- hugeParam
|
||||||
- path: _test\.go
|
- rangeValCopy
|
||||||
linters:
|
- singleCaseSwitch
|
||||||
- gosec
|
- ifElseChain
|
||||||
- dupl
|
enabled-tags:
|
||||||
- linters:
|
- performance
|
||||||
- unparam
|
- style
|
||||||
- unused
|
- experimental
|
||||||
- revive
|
govet:
|
||||||
path: _test\.go$
|
enable:
|
||||||
text: "unused-parameter"
|
- shadow
|
||||||
exclude-use-default: false
|
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)
|
resp, err := client.Get(m.PingURL)
|
||||||
if err != nil {
|
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)
|
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)
|
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 {
|
if v, ok := c.Labels["reproxy.keep-host"]; ok {
|
||||||
enabled = true
|
enabled = true
|
||||||
if v == "true" || v == "yes" || v == "1" {
|
switch v {
|
||||||
|
case "true", "yes", "1":
|
||||||
t := true
|
t := true
|
||||||
keepHost = &t
|
keepHost = &t
|
||||||
} else if v == "false" || v == "no" || v == "0" {
|
case "false", "no", "0":
|
||||||
f := false
|
f := false
|
||||||
keepHost = &f
|
keepHost = &f
|
||||||
} else {
|
default:
|
||||||
log.Printf("[WARN] invalid value for reproxy.keep-host: %s", v)
|
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")
|
basicAuthAllowed = strings.Split(string(data), "\n")
|
||||||
for i, v := range basicAuthAllowed {
|
for i, v := range basicAuthAllowed {
|
||||||
basicAuthAllowed[i] = strings.TrimSpace(v)
|
basicAuthAllowed[i] = strings.TrimSpace(v)
|
||||||
basicAuthAllowed[i] = strings.Replace(basicAuthAllowed[i], "\t", "", -1)
|
basicAuthAllowed[i] = strings.ReplaceAll(basicAuthAllowed[i], "\t", "")
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
return basicAuthAllowed, nil
|
return basicAuthAllowed, nil
|
||||||
|
|||||||
Reference in New Issue
Block a user