bazel-tools icon indicating copy to clipboard operation
bazel-tools copied to clipboard

Bug with go 1.18

Open EArbeitman opened this issue 2 years ago • 0 comments

I'm noticing odd behavior when I switched my version of go from 1.17.1 to 1.18:

Working Example:

  1. Clone this repo: https://github.com/cloudflare/sciuro/tree/master
  2. Run command: bazel run :golangcilint --sandbox_debug
  3. Output:
INFO: SHA256 (https://golang.org/dl/?mode=json&include=all) = 23bea3b79d741aa5a9cc1fd49e79344ebb097b2e057a471d1f59ee6fa736c223
INFO: Analyzed target //:golangcilint (4 packages loaded, 7528 targets configured).
INFO: Found 1 target...
Target //:golangcilint up-to-date:
  bazel-bin/golangcilint.bash
INFO: Elapsed time: 14.051s, Critical Path: 5.13s
INFO: 3 processes: 3 internal.
INFO: Build completed successfully, 3 total actions
INFO: Build completed successfully, 3 total actions
INFO [config_reader] Used config file .golangci.yml
INFO [lintersdb] Active 24 linters: [bodyclose deadcode dogsled errcheck gochecknoinits goconst gocritic godox goimports gosec gosimple govet ineffassign interfacer misspell nakedret prealloc structcheck stylecheck typecheck unconvert unparam unused varcheck]
INFO [loader] Go packages loading at mode 575 (files|imports|name|exports_file|deps|types_sizes|compiled_files) took 26.60414599s
WARN [runner] The linter 'deadcode' is deprecated (since v1.49.0) due to: The owner seems to have abandoned the linter. Replaced by unused.
WARN [runner] The linter 'interfacer' is deprecated (since v1.38.0) due to: The repository of the linter has been archived by the owner.
WARN [runner] The linter 'varcheck' is deprecated (since v1.49.0) due to: The owner seems to have abandoned the linter. Replaced by unused.
WARN [runner] The linter 'structcheck' is deprecated (since v1.49.0) due to: The owner seems to have abandoned the linter. Replaced by unused.
INFO [runner/filename_unadjuster] Pre-built 0 adjustments in 1.560931ms
INFO [linters_context/goanalysis] analyzers took 57.594345968s with top 10 stages: buildir: 48.005146656s, gocritic: 2.614569304s, inspect: 2.051173251s, printf: 1.593158111s, ctrlflow: 1.251261296s, fact_purity: 1.238065289s, buildssa: 372.291988ms, interfacer: 112.679051ms, unparam: 98.398849ms, goimports: 81.000019ms
INFO [runner] Issues before processing: 6, after processing: 3
INFO [runner] Processors filtering stat (out/in): path_prettifier: 6/6, skip_files: 6/6, skip_dirs: 6/6, exclude: 6/6, diff: 3/3, path_prefixer: 3/3, cgo: 6/6, filename_unadjuster: 6/6, identifier_marker: 6/6, nolint: 3/3, path_shortener: 3/3, severity-rules: 3/3, max_from_linter: 3/3, autogenerated_exclude: 6/6, exclude-rules: 3/6, uniq_by_line: 3/3, max_per_file_from_linter: 3/3, max_same_issues: 3/3, source_code: 3/3, sort_results: 3/3
INFO [runner] processing took 1.540216ms with stages: nolint: 638.869µs, autogenerated_exclude: 278.346µs, path_prettifier: 265.082µs, exclude-rules: 107.305µs, source_code: 106.464µs, identifier_marker: 90.068µs, skip_dirs: 44.209µs, max_same_issues: 2.299µs, uniq_by_line: 1.498µs, cgo: 1.209µs, max_from_linter: 1.121µs, path_shortener: 998ns, max_per_file_from_linter: 880ns, filename_unadjuster: 668ns, skip_files: 315ns, exclude: 209ns, diff: 205ns, severity-rules: 197ns, sort_results: 148ns, path_prefixer: 126ns
INFO [runner] linters took 9.531411011s with stages: goanalysis_metalinter: 9.529793486s
cmd/sciuro/main.go:103:3        gocritic     commentedOutCode: may want to remove commented-out code
internal/node/reconciler.go:57  goimports    File is not `goimports`-ed
cmd/sciuro/main.go:94:7         ineffassign  ineffectual assignment to err
INFO File cache stats: 9 entries of total size 66.4KiB
INFO Memory: 363 samples, avg is 284.2MB, max is 1486.0MB
INFO Execution took 36.149926528s

Steps to produce error:

  1. Update go version in WORKSPACE: From
go_register_toolchains(version = "1.17.11")

To

go_register_toolchains(version = "1.18")
  1. Run command: bazel run :golangcilint --sandbox_debug
  2. Output:
~/d/sciuro[1]►bazel run :golangcilint --sandbox_debug                                   74.584s (master|💩) 16:33
INFO: Analyzed target //:golangcilint (1 packages loaded, 8109 targets configured).
INFO: Found 1 target...
Target //:golangcilint up-to-date:
  bazel-bin/golangcilint.bash
INFO: Elapsed time: 16.554s, Critical Path: 6.17s
INFO: 3 processes: 3 internal.
INFO: Build completed successfully, 3 total actions
INFO: Build completed successfully, 3 total actions
INFO [config_reader] Used config file .golangci.yml
INFO [lintersdb] Active 24 linters: [bodyclose deadcode dogsled errcheck gochecknoinits goconst gocritic godox goimports gosec gosimple govet ineffassign interfacer misspell nakedret prealloc structcheck stylecheck typecheck unconvert unparam unused varcheck]
INFO [loader] Go packages loading at mode 575 (compiled_files|files|types_sizes|deps|exports_file|imports|name) took 13.605686256s
WARN [runner] The linter 'interfacer' is deprecated (since v1.38.0) due to: The repository of the linter has been archived by the owner.
WARN [runner] The linter 'structcheck' is deprecated (since v1.49.0) due to: The owner seems to have abandoned the linter. Replaced by unused.
WARN [runner] The linter 'deadcode' is deprecated (since v1.49.0) due to: The owner seems to have abandoned the linter. Replaced by unused.
WARN [runner] The linter 'varcheck' is deprecated (since v1.49.0) due to: The owner seems to have abandoned the linter. Replaced by unused.
INFO [runner/filename_unadjuster] Pre-built 0 adjustments in 1.981737ms
INFO [linters_context/goanalysis] analyzers took 15.884239895s with top 10 stages: buildir: 12.702594634s, inspect: 992.303679ms, printf: 890.490565ms, ctrlflow: 771.030558ms, fact_purity: 525.691774ms, cgocall: 60.004µs, nakedret: 55.137µs, S1032: 46.473µs, errcheck: 43.938µs, buildssa: 43.069µs
INFO [runner/max_same_issues] 13/16 issues with text "client.On undefined (type *mockAlertCache has no field or method On)" were hidden, use --max-same-issues
INFO [runner/max_same_issues] 4/7 issues with text "m.Called undefined (type *mockK8SClient has no field or method Called)" were hidden, use --max-same-issues
INFO [runner/max_same_issues] 1/4 issues with text "mockAlertClient.AssertExpectations undefined (type *mockAlertClient has no field or method AssertExpectations)" were hidden, use --max-same-issues
INFO [runner] Issues before processing: 3816, after processing: 18
INFO [runner] Processors filtering stat (out/in): skip_files: 3816/3816, skip_dirs: 3816/3816, exclude: 3816/3816, uniq_by_line: 36/3816, path_shortener: 18/18, sort_results: 18/18, filename_unadjuster: 3816/3816, identifier_marker: 3816/3816, exclude-rules: 3816/3816, max_same_issues: 18/36, path_prettifier: 3816/3816, max_per_file_from_linter: 36/36, source_code: 18/18, severity-rules: 18/18, path_prefixer: 18/18, cgo: 3816/3816, autogenerated_exclude: 3816/3816, nolint: 3816/3816, diff: 36/36, max_from_linter: 18/18
INFO [runner] processing took 178.45023ms with stages: exclude-rules: 120.702092ms, identifier_marker: 53.547395ms, path_prettifier: 1.795468ms, nolint: 1.645285ms, skip_dirs: 247.682µs, cgo: 105.475µs, source_code: 102.918µs, uniq_by_line: 91.262µs, filename_unadjuster: 83.321µs, autogenerated_exclude: 77.762µs, max_same_issues: 43.576µs, path_shortener: 2.718µs, max_from_linter: 2.084µs, max_per_file_from_linter: 1.794µs, skip_files: 327ns, exclude: 250ns, sort_results: 226ns, severity-rules: 217ns, diff: 209ns, path_prefixer: 169ns
INFO [runner] linters took 4.219147507s with stages: goanalysis_metalinter: 4.040560649s
internal/alert/sync_test.go:29:18        typecheck  mockAlertClient.AssertExpectations undefined (type *mockAlertClient has no field or method AssertExpectations)
internal/alert/sync_test.go:35:18        typecheck  mockAlertClient.On undefined (type *mockAlertClient has no field or method On)
internal/alert/sync_test.go:44:18        typecheck  mockAlertClient.AssertExpectations undefined (type *mockAlertClient has no field or method AssertExpectations)
internal/alert/sync_test.go:49:18        typecheck  mockAlertClient.AssertExpectations undefined (type *mockAlertClient has no field or method AssertExpectations)
internal/alert/sync_test.go:51:18        typecheck  mockAlertClient.On undefined (type *mockAlertClient has no field or method On)
internal/alert/sync_test.go:88:12        typecheck  m.Called undefined (type *mockAlertClient has no field or method Called)
internal/node/reconciler_test.go:43:11   typecheck  cache.On undefined (type *mockAlertCache has no field or method On)
internal/node/reconciler_test.go:59:7    typecheck  c.On undefined (type *mockK8SClient has no field or method On)
internal/node/reconciler_test.go:87:7    typecheck  c.On undefined (type *mockK8SClient has no field or method On)
internal/node/reconciler_test.go:95:11   typecheck  cache.On undefined (type *mockAlertCache has no field or method On)
internal/node/reconciler_test.go:112:7   typecheck  c.On undefined (type *mockK8SClient has no field or method On)
internal/node/reconciler_test.go:189:12  typecheck  client.On undefined (type *mockAlertCache has no field or method On)
internal/node/reconciler_test.go:228:12  typecheck  client.On undefined (type *mockAlertCache has no field or method On)
internal/node/reconciler_test.go:268:12  typecheck  client.On undefined (type *mockAlertCache has no field or method On)
internal/node/reconciler_test.go:818:12  typecheck  m.Called undefined (type *mockAlertCache has no field or method Called)
internal/node/reconciler_test.go:845:12  typecheck  m.Called undefined (type *mockK8SClient has no field or method Called)
internal/node/reconciler_test.go:850:12  typecheck  m.Called undefined (type *mockK8SClient has no field or method Called)
internal/node/reconciler_test.go:855:12  typecheck  m.Called undefined (type *mockK8SClient has no field or method Called)
INFO File cache stats: 2 entries of total size 25.3KiB
INFO Memory: 180 samples, avg is 134.8MB, max is 780.9MB
INFO Execution took 17.840796251s

Notice how typecheck is detected when go version is set to 1.18, but not in 1.17.1

EArbeitman avatar Mar 02 '23 21:03 EArbeitman