Skip to content

vs-code golangci-lint multiple processes eats up all memory #582

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Closed
ghost opened this issue Jun 19, 2019 · 2 comments
Closed

vs-code golangci-lint multiple processes eats up all memory #582

ghost opened this issue Jun 19, 2019 · 2 comments
Labels
topic: memory Huge memory consumption

Comments

@ghost
Copy link

ghost commented Jun 19, 2019

Impossible to use golangci-lint on vscode/go.12

Using the following settings on vscode

    "go.lintTool": "golangci-lint",
    "go.lintFlags": [
      "--config=${workspaceFolder}/.golangci.yml",
      "--fast",
    ],

Please include the following information:

  1. Version of golangci-lint: golangci-lint --version (or git commit if you don't use binary distribution)

I can't even get the version

 golangci-lint --version
Error: unknown flag: --version
Usage:
  golangci-lint [flags]
  golangci-lint [command]

Available Commands:
  config      Config
  help        Help
  linters     List current linters configuration
  run         Run this tool in cloud on every github pull request in https://golangci.com for free (public repos)

Flags:
      --color string              Use color when printing; can be 'always', 'auto', or 'never' (default "auto")
  -j, --concurrency int           Concurrency (default NumCPU) (default 4)
      --cpu-profile-path string   Path to CPU profile output file
  -h, --help                      help for golangci-lint
      --mem-profile-path string   Path to memory profile output file
  -v, --verbose                   verbose output

Use "golangci-lint [command] --help" for more information about a command.

failed executing command with error unknown flag: --version
  1. Config file: cat .golangci.yml
run:
  tests: true

linters:
  enable:
    - errcheck # Errcheck is a program for checking for unchecked errors in go programs. These unchecked errors can be critical bugs in some cases [fast: true, auto-fix: false]
    - govet # (vet, vetshadow): Vet examines Go source code and reports suspicious constructs, such as Printf calls whose arguments do not align with the format string [fast: true, auto-fix: false]
    - errcheck # Errcheck is a program for checking for unchecked errors in go programs. These unchecked errors can be critical bugs in some cases [fast: true, auto-fix: false]
    - staticcheck # Staticcheck is a go vet on steroids, applying a ton of static analysis checks [fast: false, auto-fix: false]
    - unused # Checks Go code for unused constants, variables, functions and types [fast: false, auto-fix: false]
    - gosimple # Linter for Go source code that specializes in simplifying a code [fast: false, auto-fix: false]
    - structcheck # Finds an unused struct fields [fast: true, auto-fix: false]
    - varcheck # Finds unused global variables and constants [fast: true, auto-fix: false]
    - ineffassign # Detects when assignments to existing variables are not used [fast: true, auto-fix: false]
    - deadcode # Finds unused code [fast: true, auto-fix: false]
    - typecheck # Like the front-end of a Go compiler, parses and type-checks Go code [fast: true,       auto-fix: false]
    - golint # Golint differs from gofmt. Gofmt reformats Go source code, whereas golint prints out style mistakes [fast: true, auto-fix: false]
    - gofmt # Gofmt checks whether code was gofmt-ed. By default this tool runs with -s option to check for code simplification [fast: true, auto-fix: true]

    # TODO(mbana): enable these in next PR
    # - gosec # Inspects source code for security problems [fast: true, auto-fix: false]
    - interfacer # Linter that suggests narrower interface types [fast: false, auto-fix: false]
    - unconvert # Remove unnecessary type conversions [fast: true, auto-fix: false]
    - dupl # Tool for code clone detection [fast: true, auto-fix: false]
    - goconst # Finds repeated strings that could be replaced by a constant [fast: true, auto-fix: false]

    - gocyclo # Computes and checks the cyclomatic complexity of functions [fast: true, auto-fix: false]
    - lll # Reports long lines [fast: true, auto-fix: false]
    - unparam # Reports unused function parameters [fast: false, auto-fix: false]
    - nakedret # Finds naked returns in functions greater than a specified function length [fast: true, auto-fix: false]
    - megacheck

    # TODO(mbana): enable these in next PR
    - prealloc # Finds slice declarations that could potentially be preallocated [fast: true, auto-fix: false]
    # - scopelint # Scopelint checks for unpinned variables in go programs [fast: true, auto-fix: false]
    - gocritic # The most opinionated Go source code linter [fast: true, auto-fix: false]
    # - gochecknoinits # Checks that no init functions are present in Go code [fast: true, auto-fix: false]
    - gochecknoglobals # Checks that no globals are present in Go code [fast: true, auto-fix: false]

  enable-all: false
  disable-all: true
  fast: false

# all available settings of specific linters
linters-settings:
  govet:
    # report about shadowed variables
    check-shadowing: true
  errcheck:
    # report about not checking of errors in type assetions: `a := b.(MyStruct)`;
    # default is false: such cases aren't reported by default.
    check-type-assertions: true
    # report about assignment of errors to blank identifier: `num, _ := strconv.Atoi(numStr)`;
    # default is false: such cases aren't reported by default.
    check-blank: true
  staticcheck:
    fast: true
  unused:
    fast: true
  gosimple:
    fast: true
  golint:
    # minimal confidence for issues, default is 0.8
    min-confidence: 1.0
  gofmt:
    # simplify code: gofmt with `-s` option, true by default
    simplify: true
  misspell:
    # Correct spellings using locale preferences for US or UK.
    # Default is to use a neutral variety of English.
    # Setting locale to US will correct the British spelling of 'colour' to 'color'.
    locale: UK
  gocyclo:
    min-complexity: 13
  interfacer:
    fast: true
  lll:
    # max line length, lines longer will be reported. Default is 120.
    # '\t' is counted as 1 character by default, and can be changed with the tab-width option
    line-length: 1024
    fast: true
  unparam:
    fast: true


  # see: https://github.com/golangci/golangci-lint/blob/master/.golangci.example.yml#L47
  #
  # by default isn't set. If set we pass it to "go list -mod={option}". From "go help modules":
  # If invoked with -mod=readonly, the go command is disallowed from the implicit
  # automatic updating of go.mod described above. Instead, it fails when any changes
  # to go.mod are needed. This setting is most useful to check that go.mod does
  # not need updates, such as in a continuous integration and testing system.
  # If invoked with -mod=vendor, the go command assumes that the vendor
  # directory holds the correct copies of dependencies and ignores
  # the dependency descriptions in go.mod.
  modules-download-mode: readonly

# output configuration options
output:
  # colored-line-number|line-number|json|tab|checkstyle, default is "colored-line-number"
  format: colored-line-number

  # print lines of code with issue, default is true
  print-issued-lines: false

  # print linter name in the end of issue text, default is true
  print-linter-name: true

issues:
  # Maximum issues count per one linter. Set to 0 to disable. Default is 50.
  max-per-linter: 0

  # Maximum count of issues with the same text. Set to 0 to disable. Default is 3.
  max-same-issues: 0
  1. Go environment: go version && go env
➜  conformance-suite git:(release/v1.1.11) ✗ go env
GOARCH="amd64"
GOBIN="/Users/diegomariani/workspace/go/bin"
GOCACHE="/Users/diegomariani/Library/Caches/go-build"
GOEXE=""
GOFLAGS=""
GOHOSTARCH="amd64"
GOHOSTOS="darwin"
GOOS="darwin"
GOPATH="/Users/diegomariani/workspace/go"
GOPROXY=""
GORACE=""
GOROOT="/usr/local/go"
GOTMPDIR=""
GOTOOLDIR="/usr/local/go/pkg/tool/darwin_amd64"
GCCGO="gccgo"
CC="clang"
CXX="clang++"
CGO_ENABLED="1"
GOMOD="/Users/dm/project/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 -m64 -pthread -fno-caret-diagnostics -Qunused-arguments -fmessage-length=0 -fdebug-prefix-map=/var/folders/8x/xdz924n9511_nw4f1l42f8400000gn/T/go-build861223409=/tmp/go-build -gno-record-gcc-switches -fno-common"

It's basically now impossible to use vscode with golangci-lint because just after starting to type everything gets super slow and I can see on my activity monitor 5 different processes for golangci-lint each one with 1GB ram usage.

@ghost
Copy link
Author

ghost commented Jun 26, 2019

Screenshot 2019-06-26 at 11 36 03

@tpounds tpounds added the topic: memory Huge memory consumption label Sep 25, 2019
@jirfag
Copy link
Contributor

jirfag commented Oct 15, 2019

Hi, thank you for reporting!

  1. In the newest version (no release, only in master) only one golangci-Lunt can be run at one moment
  2. We have dramatically reduced memory usage in the v1.20.0

@jirfag jirfag closed this as completed Oct 15, 2019
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
topic: memory Huge memory consumption
Projects
None yet
Development

No branches or pull requests

2 participants