-
Welcome
Description of the problemGo code as below: // ClusterIPRanges
_, ipNet, err := net.ParseCIDR(DefaultCIDR)
if err != nil {
return errors.Wrapf(err, "invalid cluster-cidr %s", DefaultCIDR)
}
cfg.ControlConfig.ClusterIPRanges = append(cfg.ControlConfig.ClusterIPRanges, ipNet) Got error: cmd/geda/app/bootstrap/k3s.go:23:5: ipNet declared but not used (typecheck)
_, ipNet, err := net.ParseCIDR(DefaultCIDR)
^ Version of golangci-lint$ golangci-lint --version
# golangci-lint has version 1.42.0 built from c6142e3 on 2021-08-17T08:27:57Z Configuration file$ cat .golangci.yml
# run:
concurrency: 4
deadline: 5m
linter-settings:
goconst:
min-len: 2
min-occurrences: 2
linters:
enable:
- goconst
- gofmt
- goimports
- misspell
- unparam
issues:
exclude-use-default: false
exclude-rules:
- path: _test.go
linters:
- errcheck
exclude:
- (comment on exported (method|function|type|const)|should have( a package)? comment|comment should be of the form)
Go environment$ go version && go env
# go version go1.16.6 darwin/amd64
GO111MODULE=""
GOARCH="amd64"
GOBIN=""
GOCACHE="/Users/derek/Library/Caches/go-build"
GOENV="/Users/derek/Library/Application Support/go/env"
GOEXE=""
GOFLAGS=""
GOHOSTARCH="amd64"
GOHOSTOS="darwin"
GOINSECURE=""
GOMODCACHE="/Users/derek/go/pkg/mod"
GOOS="darwin"
GOPATH="/Users/derek/go"
GOPROXY="https://goproxy.io,direct"
GOROOT="/usr/local/Cellar/go/1.16.6/libexec"
GOSUMDB="sum.golang.org"
GOTMPDIR=""
GOTOOLDIR="/usr/local/Cellar/go/1.16.6/libexec/pkg/tool/darwin_amd64"
GOVCS=""
GOVERSION="go1.16.6"
GCCGO="gccgo"
AR="ar"
CC="clang"
CXX="clang++"
CGO_ENABLED="1"
GOMOD="/Users/derek/Workspaces/geda/go.mod"
CGO_CFLAGS="-g -O2"
CGO_CPPFLAGS=""
CGO_CXXFLAGS="-g -O2"
CGO_FFLAGS="-g -O2"
CGO_LDFLAGS="-g -O2"
PKG_CONFIG="pkg-config"
GOGCCFLAGS="-fPIC -arch x86_64 -m64 -pthread -fno-caret-diagnostics -Qunused-arguments -fmessage-length=0 -fdebug-prefix-map=/var/folders/mf/y5s_1mcx3vb0n7thsn_d_g3c0000gn/T/go-build172231809=/tmp/go-build -gno-record-gcc-switches -fno-common" Verbose output of running$ golangci-lint cache clean
$ golangci-lint run -v
#INFO [config_reader] Config search paths: [./ /Users/derek/Workspaces/geda /Users/derek/Workspaces /Users/derek /Users /]
INFO [config_reader] Used config file .golangci.yml
INFO [lintersdb] Active 15 linters: [deadcode errcheck goconst gofmt goimports gosimple govet ineffassign misspell staticcheck structcheck typecheck unparam unused varcheck]
INFO [loader] Go packages loading at mode 575 (compiled_files|deps|name|types_sizes|exports_file|files|imports) took 4.077825318s
INFO [runner/filename_unadjuster] Pre-built 0 adjustments in 1.571762ms
INFO [linters context/goanalysis] analyzers took 6m5.377470535s with top 10 stages: buildir: 5m8.273972594s, nilness: 27.449475311s, inspect: 5.80335826s, ctrlflow: 4.623810022s, typedness: 4.563202093s, fact_deprecated: 4.488277725s, printf: 3.933454729s, fact_purity: 3.54004935s, SA5012: 2.428113135s, buildssa: 74.200227ms
INFO [runner] Issues before processing: 153, after processing: 1
INFO [runner] Processors filtering stat (out/in): uniq_by_line: 1/144, max_same_issues: 1/1, skip_dirs: 153/153, exclude: 153/153, exclude-rules: 153/153, identifier_marker: 153/153, skip_files: 153/153, autogenerated_exclude: 153/153, nolint: 144/153, path_prefixer: 1/1, sort_results: 1/1, filename_unadjuster: 153/153, path_prettifier: 153/153, diff: 1/1, max_per_file_from_linter: 1/1, max_from_linter: 1/1, source_code: 1/1, path_shortener: 1/1, severity-rules: 1/1, cgo: 153/153
INFO [runner] processing took 5.576239ms with stages: nolint: 2.109345ms, identifier_marker: 1.822508ms, autogenerated_exclude: 594.325µs, exclude: 565.598µs, path_prettifier: 237.926µs, skip_dirs: 75.92µs, source_code: 71.972µs, exclude-rules: 49.501µs, uniq_by_line: 17.229µs, cgo: 13.296µs, filename_unadjuster: 9.153µs, max_same_issues: 3.138µs, path_shortener: 1.692µs, max_per_file_from_linter: 1.33µs, max_from_linter: 1.206µs, diff: 762ns, skip_files: 494ns, severity-rules: 376ns, sort_results: 303ns, path_prefixer: 165ns
INFO [runner] linters took 1m46.354873834s with stages: goanalysis_metalinter: 1m46.349154728s
cmd/geda/app/bootstrap/k3s.go:23:5: ipNet declared but not used (typecheck)
_, ipNet, err := net.ParseCIDR(DefaultCIDR)
^
INFO File cache stats: 6 entries of total size 21.6KiB
INFO Memory: 707 samples, avg is 2054.8MB, max is 3045.6MB
INFO Execution took 1m50.449564677s Code example or link to a public repository // ClusterIPRanges
_, ipNet, err := net.ParseCIDR(DefaultCIDR)
if err != nil {
return errors.Wrapf(err, "invalid cluster-cidr %s", DefaultCIDR)
}
cfg.ControlConfig.ClusterIPRanges = append(cfg.ControlConfig.ClusterIPRanges, ipNet) |
Beta Was this translation helpful? Give feedback.
Replies: 7 comments 5 replies
-
Hey, thank you for opening your first Issue ! 🙂 If you would like to contribute we have a guide for contributors. |
Beta Was this translation helpful? Give feedback.
-
Hello, Can you provide a full reproducible example?
|
Beta Was this translation helpful? Give feedback.
-
@ldez I try to write a simple example. It isn't able to reproduce. package main
import (
"fmt"
"net"
)
func main() {
ipNets := []*net.IPNet{}
_, ipNet, err := net.ParseCIDR("10.42.0.0/16")
if err != nil {
panic(err)
}
ipNets = append(ipNets, ipNet)
fmt.Printf("%v\n", ipNets)
} The source code of the problem is here https://github.com/dereknex/geda/blob/provision-nodes/cmd/geda/app/bootstrap/k3s.go . I will try again. |
Beta Was this translation helpful? Give feedback.
-
I have a try to the example, it's ok! But there's a same issue in my code!
function like: var GatewayMac [6]byte
func ReSync() error {
mac, err := getDefaultGatewayMac()
if err != nil {
return fmt.Errorf("failed to get default gateway: %v", err)
}
copy(GatewayMac[:], mac)
return nil
}
.golangci.ymllinters:
enable:
- deadcode
- dupl
- errcheck
- goconst
- gocyclo
- gofmt
#- golint #no longer supported
#- goimports
#- gosec
- gosimple
- govet
- ineffassign
#- interfacer #no longer supported
- lll
#- maligned #no longer supported
- misspell
- nakedret
- prealloc
#- scopelint #no longer supported
- staticcheck
- structcheck
- typecheck
- unconvert
- unparam
- unused
- varcheck
- bodyclose
# - exhaustive
# - exhaustivestruct
- exportloopref
- goprintffuncname
# - forcetypeassert
linters-settings:
errcheck:
# path to a file containing a list of functions to exclude from checking
# see https://github.com/kisielk/errcheck#excluding-functions for details
exclude: .errcheck_exclude.txt
issues:
exclude-rules:
- linters:
- unparam
source: "getList\\).remove"
run:
skip-dirs:
- pkg
skip-files:
- ".*test.go$"
skip-dirs-use-default: true command:
|
Beta Was this translation helpful? Give feedback.
-
After I changed the golang version 1.15 to version 1.16, it's OK in my code! |
Beta Was this translation helpful? Give feedback.
-
I'm encountering this in a simple loop statement. My Go version is 1.17. Unfortunately can't share as it's a private repo but it's a very simple piece of code: collection := make([]Thing, len(listOfThings))
for i, thing := range listOfThings {
collection[i] = actOn(thing)
}
Actually noticing a lot of this. Imported packages marked as not used, but they're used… I'm just starting to add |
Beta Was this translation helpful? Give feedback.
-
I have the same problem with jaeger import. I can build and run golangci (or go vet, or any other command for that matter) just fine, but as soon as the golangci-lint is executed inside docker I get typecheck error:
The next stage in the pipeline (go build basically) executes without an issue though (if lining stage is ommited). I did |
Beta Was this translation helpful? Give feedback.
After I changed the golang version 1.15 to version 1.16, it's OK in my code!
But don't know why.