[vscode-go] src/goLint: switch the default lint tool to staticcheck

467 views
Skip to first unread message

Hyang-Ah Hana Kim (Gerrit)

unread,
Dec 18, 2020, 1:18:52 PM12/18/20
to goph...@pubsubhelper.golang.org, Hyang-Ah Hana Kim, golang-co...@googlegroups.com

Hyang-Ah Hana Kim has uploaded this change for review.

View Change

src/goLint: switch the default lint tool to staticcheck

Golint is unmaintained and effectively deprecated.
So, switch to staticcheck, which is one of the existing linter
options we've provided, and is actively maintained.

Compared to golint, we observed staticcheck provides more useful
signals about the code style and common errors, while it is still
easy to use. Some controversial checks existed in the golint are
turned off by default (ST1000, ST1003, ST1016), or removed. Users
can turn them on if want, by supplying -checks as lintFlags.
Unlike golint, staticcheck reports only compile errors and does
not show other lint errors if compile errors are present - I am not
sure how much this will bother users yet. We may want to consider
turning off the compile error reports (since there is a separate build
check and also gopls will report those errors).

Errors from lint and gopls aren't currently deduplicated, that
will be addressed separately.

Fixes golang/vscode-go#189
Updates #38968
Updates golang/vscode-go#142

Change-Id: Ie9334867aef3673aed01d7eaf757966486178dbc
---
M .github/workflows/release-nightly.yml
M .github/workflows/test-long.yml
M .github/workflows/test-smoke.yml
M build/all.bash
M docs/settings.md
M docs/tools.md
M package.json
M src/goLint.ts
M src/goTools.ts
M test/integration/extension.test.ts
M test/testdata/linterTest/linter_1.go
M test/testdata/linterTest/linter_2.go
12 files changed, 40 insertions(+), 23 deletions(-)

diff --git a/.github/workflows/release-nightly.yml b/.github/workflows/release-nightly.yml
index f232d3f..2aaf455 100644
--- a/.github/workflows/release-nightly.yml
+++ b/.github/workflows/release-nightly.yml
@@ -52,7 +52,7 @@
go get github.com/sqs/goreturns
go get github.com/uudashr/gopkgs/v2/cmd/gopkgs
go get github.com/zmb3/gogetdoc
- go get golang.org/x/lint/golint
+ go get honnef.co/go/tools/...
go get golang.org/x/tools/cmd/gorename
go get golang.org/x/tools/gopls
go get github.com/cweill/gotests/...
diff --git a/.github/workflows/test-long.yml b/.github/workflows/test-long.yml
index 4b129a0..2aca343 100644
--- a/.github/workflows/test-long.yml
+++ b/.github/workflows/test-long.yml
@@ -51,7 +51,7 @@
go get github.com/sqs/goreturns
go get github.com/uudashr/gopkgs/v2/cmd/gopkgs
go get github.com/zmb3/gogetdoc
- go get golang.org/x/lint/golint
+ go get honnef.co/go/tools/...
go get golang.org/x/tools/cmd/gorename
go get golang.org/x/tools/gopls
go get github.com/cweill/gotests/...
diff --git a/.github/workflows/test-smoke.yml b/.github/workflows/test-smoke.yml
index 941cfc3..fbc783f 100644
--- a/.github/workflows/test-smoke.yml
+++ b/.github/workflows/test-smoke.yml
@@ -47,7 +47,7 @@
go get github.com/sqs/goreturns
go get github.com/uudashr/gopkgs/v2/cmd/gopkgs
go get github.com/zmb3/gogetdoc
- go get golang.org/x/lint/golint
+ go get honnef.co/go/tools/...
go get golang.org/x/tools/cmd/gorename
go get golang.org/x/tools/gopls
go get github.com/cweill/gotests/...
diff --git a/build/all.bash b/build/all.bash
index afd0706..85ffdde 100755
--- a/build/all.bash
+++ b/build/all.bash
@@ -103,7 +103,7 @@
GO111MODULE=on go get github.com/sqs/goreturns
GO111MODULE=on go get github.com/uudashr/gopkgs/v2/cmd/gopkgs
GO111MODULE=on go get github.com/zmb3/gogetdoc
- GO111MODULE=on go get golang.org/x/lint/golint
+ GO111MODULE=on go get honnef.co/go/tools/...
GO111MODULE=on go get golang.org/x/tools/cmd/gorename
GO111MODULE=on go get github.com/go-delve/delve/cmd/dlv
}
diff --git a/docs/settings.md b/docs/settings.md
index 80cf4bf..4ce7b95 100644
--- a/docs/settings.md
+++ b/docs/settings.md
@@ -398,7 +398,7 @@

Allowed Values:`[golint golangci-lint revive staticcheck]`

-Default: `golint`
+Default: `staticcheck`

### `go.liveErrors`

diff --git a/docs/tools.md b/docs/tools.md
index 8a620aa..c91d567 100644
--- a/docs/tools.md
+++ b/docs/tools.md
@@ -150,11 +150,12 @@

The command used to provide build errors on-save is `go build -i -o` or `go test -i -c -o` (for test files). The binary generated by the build is written to a temporary location.

-Other lint tools can be used instead of [`golint`] by configuring the [`"go.lintTool"`](settings.md#go.lintTool) setting. Other options include:
+Other lint tools can be used instead of [`staticcheck`] by configuring the [`"go.lintTool"`](settings.md#go.lintTool) setting. Other options include:

-* [`staticcheck`]: This tool provides a great deal of useful checks that are not provided by [`golint`]. See the full list at [staticcheck.io/docs/checks](https://staticcheck.io/docs/checks). It is also officially supported by the [Go team at Google](https://staticcheck.io/sponsors).
+* [`staticcheck`]: See the full list at [staticcheck.io/docs/checks](https://staticcheck.io/docs/checks). It is also officially supported by the [Go team at Google](https://staticcheck.io/sponsors).
* [`golangci-lint`]: This tool combines a number of existing lint tools, including [staticcheck](#staticcheck), into one interface.
* [`revive`]: This tool is an enhancement on top of [`golint`], and it provides additional checks.
+* [`golint`]: This tool has been a traditional lint tool, but is about to get deprecated. See the [deprecation proposal](https://github.com/golang/go/issues/38968).

You can use the [`"go.lintFlags"`](settings.md#go.lintFlags) setting to further configure your linter of choice. Most linters can be configured via special configuration files, but you may still need to pass these command-line flags. The configuration documentation for each supported linter is listed here:

diff --git a/package.json b/package.json
index bd1e5ef..bdfaf54 100644
--- a/package.json
+++ b/package.json
@@ -1260,7 +1260,7 @@
},
"go.lintTool": {
"type": "string",
- "default": "golint",
+ "default": "staticcheck",
"description": "Specifies Lint tool name.",
"scope": "resource",
"enum": [
diff --git a/src/goLint.ts b/src/goLint.ts
index 0e8abfb..ebf8e54 100644
--- a/src/goLint.ts
+++ b/src/goLint.ts
@@ -81,7 +81,7 @@
return Promise.resolve([]);
}

- const lintTool = goConfig['lintTool'] || 'golint';
+ const lintTool = goConfig['lintTool'] || 'staticcheck';
const lintFlags: string[] = goConfig['lintFlags'] || [];
const lintEnv = toolExecutionEnvironment();
const args: string[] = [];
diff --git a/src/goTools.ts b/src/goTools.ts
index e9387ba..3e17123 100644
--- a/src/goTools.ts
+++ b/src/goTools.ts
@@ -343,7 +343,7 @@
name: 'golint',
importPath: 'golang.org/x/lint/golint',
replacedByGopls: false,
- isImportant: true,
+ isImportant: false,
description: 'Linter',
minimumGoVersion: semver.coerce('1.9'),
},
diff --git a/test/integration/extension.test.ts b/test/integration/extension.test.ts
index 3957b2e..6d50932 100644
--- a/test/integration/extension.test.ts
+++ b/test/integration/extension.test.ts
@@ -395,8 +395,11 @@
const file1 = await vscode.workspace.openTextDocument(vscode.Uri.file(path.join(fixturePath, 'linterTest', 'linter_1.go')));
const file2 = await vscode.workspace.openTextDocument(vscode.Uri.file(path.join(fixturePath, 'linterTest', 'linter_2.go')));
const warnings = await goLint(file2.uri, Object.create(vscode.workspace.getConfiguration('go'), {
- lintTool: { value: 'golint' },
- lintFlags: { value: [] }
+ lintTool: { value: 'staticcheck' },
+ lintFlags: { value: ['-checks', 'all,-ST1000,-ST1016'] }
+ // staticcheck skips debatable checks such as ST1003 by default,
+ // but this test depends on ST1003 (MixedCaps package name) presented in both files
+ // in the same package. So, enable that.
}), 'package');

const diagnosticCollection = vscode.languages.createDiagnosticCollection('linttest');
@@ -416,15 +419,17 @@
vetOnSave: { value: 'package' },
vetFlags: { value: ['-all'] },
lintOnSave: { value: 'package' },
- lintTool: { value: 'golint' },
+ lintTool: { value: 'staticcheck' },
lintFlags: { value: [] },
buildOnSave: { value: 'package' }
});
const expectedLintErrors = [
+ // Unlike golint, staticcheck will report only those compile errors,
+ // but not lint errors when the program is broken.
{
- line: 7,
+ line: 11,
severity: 'warning',
- msg: 'exported function Print2 should have comment or be unexported'
+ msg: 'undeclared name: prin (compile)',
},
];
// If a user has enabled diagnostics via a language server,
@@ -432,6 +437,7 @@
const lspConfig = buildLanguageServerConfig(getGoConfig());
const expectedBuildVetErrors = lspConfig.enabled ? [] : [{ line: 11, severity: 'error', msg: 'undefined: prin' }];

+ // `check` itself doesn't run deDupeDiagnostics, so we expect all vet/lint errors.
const expected = [...expectedLintErrors, ...expectedBuildVetErrors];
const diagnostics = await check(vscode.Uri.file(path.join(fixturePath, 'errorsTest', 'errors.go')), config);
const sortedDiagnostics = ([] as ICheckResult[]).concat
diff --git a/test/testdata/linterTest/linter_1.go b/test/testdata/linterTest/linter_1.go
index b76bee3..1c42905 100644
--- a/test/testdata/linterTest/linter_1.go
+++ b/test/testdata/linterTest/linter_1.go
@@ -1,12 +1,17 @@
package linterTest

-import "fmt"
+import (
+ "fmt"
+)

func ExportedFunc() {
- a := 10
- func() {
- a := 20
- }()
-
- fmt.Println("OUTER A: ", a)
+ x := compute()
+ if x == nil {
+ fmt.Println("nil pointer received")
+ }
+ // if x is nil, the next line will panic.
+ foo(*x)
}
+
+func compute() **int { return nil }
+func foo(x *int) { fmt.Println(*x) }
diff --git a/test/testdata/linterTest/linter_2.go b/test/testdata/linterTest/linter_2.go
index f58961a..33916a5 100644
--- a/test/testdata/linterTest/linter_2.go
+++ b/test/testdata/linterTest/linter_2.go
@@ -1,5 +1,10 @@
package linterTest

-func secondFunc() error {
+import (
+ "errors"
+ "fmt"
+)

+func secondFunc() error {
+ return errors.New(fmt.Sprint("Errors"))
}

To view, visit change 279212. To unsubscribe, or for help writing mail filters, visit settings.

Gerrit-Project: vscode-go
Gerrit-Branch: master
Gerrit-Change-Id: Ie9334867aef3673aed01d7eaf757966486178dbc
Gerrit-Change-Number: 279212
Gerrit-PatchSet: 1
Gerrit-Owner: Hyang-Ah Hana Kim <hya...@gmail.com>
Gerrit-Reviewer: Hyang-Ah Hana Kim <hya...@gmail.com>
Gerrit-MessageType: newchange

kokoro (Gerrit)

unread,
Dec 18, 2020, 1:30:51 PM12/18/20
to Hyang-Ah Hana Kim, goph...@pubsubhelper.golang.org, golang-co...@googlegroups.com

Attention is currently required from: Hyang-Ah Hana Kim.

Kokoro presubmit build finished with status: FAILURE
Logs at: https://source.cloud.google.com/results/invocations/ba0bab64-d122-40e4-8f71-0cfba978b272

Patch set 1:TryBot-Result -1

View Change

    To view, visit change 279212. To unsubscribe, or for help writing mail filters, visit settings.

    Gerrit-Project: vscode-go
    Gerrit-Branch: master
    Gerrit-Change-Id: Ie9334867aef3673aed01d7eaf757966486178dbc
    Gerrit-Change-Number: 279212
    Gerrit-PatchSet: 1
    Gerrit-Owner: Hyang-Ah Hana Kim <hya...@gmail.com>
    Gerrit-Reviewer: Hyang-Ah Hana Kim <hya...@gmail.com>
    Gerrit-Reviewer: kokoro <noreply...@google.com>
    Gerrit-Attention: Hyang-Ah Hana Kim <hya...@gmail.com>
    Gerrit-Comment-Date: Fri, 18 Dec 2020 18:30:46 +0000
    Gerrit-HasComments: No
    Gerrit-Has-Labels: Yes
    Gerrit-MessageType: comment

    Hyang-Ah Hana Kim (Gerrit)

    unread,
    Feb 22, 2021, 10:22:59 PM2/22/21
    to Hyang-Ah Hana Kim, goph...@pubsubhelper.golang.org, golang-co...@googlegroups.com

    Attention is currently required from: Hyang-Ah Hana Kim.

    Hyang-Ah Hana Kim uploaded patch set #2 to this change.

    View Change

    src/goLint: switch the default lint tool to staticcheck

    Golint is unmaintained and effectively deprecated.
    So, switch to staticcheck, which is one of the existing linter
    options we've provided, and is actively maintained.

    Compared to golint, we observed staticcheck provides more useful
    signals about the code style and common errors, while it is still
    easy to use. Some controversial checks existed in the golint are
    turned off by default (ST1000, ST1003, ST1016), or removed. Users
    can turn them on if want, by supplying -checks as lintFlags.
    Unlike golint, staticcheck reports only compile errors and does
    not show other lint errors if compile errors are present - I am not
    sure how much this will bother users yet. We may want to consider
    turning off the compile error reports (since there is a separate build
    check and also gopls will report those errors).

    Fixes golang/vscode-go#189
    Updates #38968


    Change-Id: Ie9334867aef3673aed01d7eaf757966486178dbc
    ---
    M .github/workflows/release-nightly.yml
    M .github/workflows/test-long-all.yml

    M .github/workflows/test-long.yml
    M .github/workflows/test-smoke.yml
    M build/all.bash
    M docs/tools.md

    M src/goLint.ts
    M src/goTools.ts
    M test/integration/extension.test.ts
    M test/testdata/linterTest/linter_1.go
    M test/testdata/linterTest/linter_2.go
    11 files changed, 41 insertions(+), 24 deletions(-)

    To view, visit change 279212. To unsubscribe, or for help writing mail filters, visit settings.

    Gerrit-Project: vscode-go
    Gerrit-Branch: master
    Gerrit-Change-Id: Ie9334867aef3673aed01d7eaf757966486178dbc
    Gerrit-Change-Number: 279212
    Gerrit-PatchSet: 2
    Gerrit-Owner: Hyang-Ah Hana Kim <hya...@gmail.com>
    Gerrit-Reviewer: Hyang-Ah Hana Kim <hya...@gmail.com>
    Gerrit-Reviewer: kokoro <noreply...@google.com>
    Gerrit-Attention: Hyang-Ah Hana Kim <hya...@gmail.com>
    Gerrit-MessageType: newpatchset

    kokoro (Gerrit)

    unread,
    Feb 22, 2021, 10:33:27 PM2/22/21
    to Hyang-Ah Hana Kim, goph...@pubsubhelper.golang.org, golang-co...@googlegroups.com

    Attention is currently required from: Hyang-Ah Hana Kim.

    Kokoro presubmit build finished with status: SUCCESS
    Logs at: https://source.cloud.google.com/results/invocations/4c81e752-6b39-4fa8-bf30-126549523575

    Patch set 2:TryBot-Result +1

    View Change

      To view, visit change 279212. To unsubscribe, or for help writing mail filters, visit settings.

      Gerrit-Project: vscode-go
      Gerrit-Branch: master
      Gerrit-Change-Id: Ie9334867aef3673aed01d7eaf757966486178dbc
      Gerrit-Change-Number: 279212
      Gerrit-PatchSet: 2
      Gerrit-Owner: Hyang-Ah Hana Kim <hya...@gmail.com>
      Gerrit-Reviewer: Hyang-Ah Hana Kim <hya...@gmail.com>
      Gerrit-Reviewer: kokoro <noreply...@google.com>
      Gerrit-Attention: Hyang-Ah Hana Kim <hya...@gmail.com>
      Gerrit-Comment-Date: Tue, 23 Feb 2021 03:33:21 +0000

      Rebecca Stambler (Gerrit)

      unread,
      Feb 23, 2021, 4:15:08 PM2/23/21
      to Hyang-Ah Hana Kim, goph...@pubsubhelper.golang.org, Suzy Mueller, kokoro, golang-co...@googlegroups.com

      Attention is currently required from: Suzy Mueller, Hyang-Ah Hana Kim.

      View Change

      2 comments:

        • We may want to consider
          turning off the compile error reports (since there is a separate build
          check and also gopls will report those errors).

        • Does the duplicate check not work on these?

      • File docs/tools.md:

        • Patch Set #2, Line 70: * [`golint`]: This used to be the default linter used by this extension before it was officially deprecated.

          should we just fully remove it?

      To view, visit change 279212. To unsubscribe, or for help writing mail filters, visit settings.

      Gerrit-Project: vscode-go
      Gerrit-Branch: master
      Gerrit-Change-Id: Ie9334867aef3673aed01d7eaf757966486178dbc
      Gerrit-Change-Number: 279212
      Gerrit-PatchSet: 2
      Gerrit-Owner: Hyang-Ah Hana Kim <hya...@gmail.com>
      Gerrit-Reviewer: Hyang-Ah Hana Kim <hya...@gmail.com>
      Gerrit-Reviewer: Rebecca Stambler <rsta...@golang.org>
      Gerrit-Reviewer: Suzy Mueller <suz...@golang.org>
      Gerrit-Reviewer: kokoro <noreply...@google.com>
      Gerrit-Attention: Suzy Mueller <suz...@golang.org>
      Gerrit-Attention: Hyang-Ah Hana Kim <hya...@gmail.com>
      Gerrit-Comment-Date: Tue, 23 Feb 2021 21:15:02 +0000
      Gerrit-HasComments: Yes
      Gerrit-Has-Labels: No
      Gerrit-MessageType: comment

      Suzy Mueller (Gerrit)

      unread,
      Feb 24, 2021, 11:12:28 AM2/24/21
      to Hyang-Ah Hana Kim, goph...@pubsubhelper.golang.org, Rebecca Stambler, kokoro, golang-co...@googlegroups.com

      Attention is currently required from: Hyang-Ah Hana Kim.

      View Change

      1 comment:

      • File docs/tools.md:

        • Patch Set #2, Line 65: See the full list at

          Maybe "See the full list of checks that staticcheck provides at"?

          Unclear to me when first reading it what this link has the full list of.

      To view, visit change 279212. To unsubscribe, or for help writing mail filters, visit settings.

      Gerrit-Project: vscode-go
      Gerrit-Branch: master
      Gerrit-Change-Id: Ie9334867aef3673aed01d7eaf757966486178dbc
      Gerrit-Change-Number: 279212
      Gerrit-PatchSet: 2
      Gerrit-Owner: Hyang-Ah Hana Kim <hya...@gmail.com>
      Gerrit-Reviewer: Hyang-Ah Hana Kim <hya...@gmail.com>
      Gerrit-Reviewer: Rebecca Stambler <rsta...@golang.org>
      Gerrit-Reviewer: Suzy Mueller <suz...@golang.org>
      Gerrit-Reviewer: kokoro <noreply...@google.com>
      Gerrit-Attention: Hyang-Ah Hana Kim <hya...@gmail.com>
      Gerrit-Comment-Date: Wed, 24 Feb 2021 16:12:23 +0000

      Hyang-Ah Hana Kim (Gerrit)

      unread,
      Mar 9, 2021, 12:45:23 AM3/9/21
      to Hyang-Ah Hana Kim, goph...@pubsubhelper.golang.org, Rebecca Stambler, kokoro, Suzy Mueller, golang-co...@googlegroups.com

      Attention is currently required from: Suzy Mueller.

      Patch set 5:Run-TryBot +1Trust +1

      View Change

        To view, visit change 279212. To unsubscribe, or for help writing mail filters, visit settings.

        Gerrit-Project: vscode-go
        Gerrit-Branch: master
        Gerrit-Change-Id: Ie9334867aef3673aed01d7eaf757966486178dbc
        Gerrit-Change-Number: 279212
        Gerrit-PatchSet: 5
        Gerrit-Owner: Hyang-Ah Hana Kim <hya...@gmail.com>
        Gerrit-Reviewer: Hyang-Ah Hana Kim <hya...@gmail.com>
        Gerrit-Reviewer: Rebecca Stambler <rsta...@golang.org>
        Gerrit-Reviewer: Suzy Mueller <suz...@golang.org>
        Gerrit-Reviewer: kokoro <noreply...@google.com>
        Gerrit-Attention: Suzy Mueller <suz...@golang.org>
        Gerrit-Comment-Date: Tue, 09 Mar 2021 05:45:20 +0000

        kokoro (Gerrit)

        unread,
        Mar 9, 2021, 12:56:53 AM3/9/21
        to Hyang-Ah Hana Kim, goph...@pubsubhelper.golang.org, Rebecca Stambler, Suzy Mueller, golang-co...@googlegroups.com

        Attention is currently required from: Suzy Mueller.

        Kokoro presubmit build finished with status: SUCCESS
        Logs at: https://source.cloud.google.com/results/invocations/1fc8a47e-92b5-45c3-abd2-1d4ac0f28ddb

        Patch set 5:TryBot-Result +1

        View Change

          To view, visit change 279212. To unsubscribe, or for help writing mail filters, visit settings.

          Gerrit-Project: vscode-go
          Gerrit-Branch: master
          Gerrit-Change-Id: Ie9334867aef3673aed01d7eaf757966486178dbc
          Gerrit-Change-Number: 279212
          Gerrit-PatchSet: 5
          Gerrit-Owner: Hyang-Ah Hana Kim <hya...@gmail.com>
          Gerrit-Reviewer: Hyang-Ah Hana Kim <hya...@gmail.com>
          Gerrit-Reviewer: Rebecca Stambler <rsta...@golang.org>
          Gerrit-Reviewer: Suzy Mueller <suz...@golang.org>
          Gerrit-Reviewer: kokoro <noreply...@google.com>
          Gerrit-Attention: Suzy Mueller <suz...@golang.org>
          Gerrit-Comment-Date: Tue, 09 Mar 2021 05:56:48 +0000

          Hyang-Ah Hana Kim (Gerrit)

          unread,
          Mar 9, 2021, 1:26:28 AM3/9/21
          to Hyang-Ah Hana Kim, goph...@pubsubhelper.golang.org, kokoro, Rebecca Stambler, Suzy Mueller, golang-co...@googlegroups.com

          Attention is currently required from: Suzy Mueller.

          View Change

          1 comment:

          To view, visit change 279212. To unsubscribe, or for help writing mail filters, visit settings.

          Gerrit-Project: vscode-go
          Gerrit-Branch: master
          Gerrit-Change-Id: Ie9334867aef3673aed01d7eaf757966486178dbc
          Gerrit-Change-Number: 279212
          Gerrit-PatchSet: 5
          Gerrit-Owner: Hyang-Ah Hana Kim <hya...@gmail.com>
          Gerrit-Reviewer: Hyang-Ah Hana Kim <hya...@gmail.com>
          Gerrit-Reviewer: Rebecca Stambler <rsta...@golang.org>
          Gerrit-Reviewer: Suzy Mueller <suz...@golang.org>
          Gerrit-Reviewer: kokoro <noreply...@google.com>
          Gerrit-Attention: Suzy Mueller <suz...@golang.org>
          Gerrit-Comment-Date: Tue, 09 Mar 2021 06:26:24 +0000
          Gerrit-HasComments: Yes
          Gerrit-Has-Labels: No
          Comment-In-Reply-To: Rebecca Stambler <rsta...@golang.org>
          Gerrit-MessageType: comment

          Hyang-Ah Hana Kim (Gerrit)

          unread,
          Mar 9, 2021, 1:26:32 AM3/9/21
          to Hyang-Ah Hana Kim, goph...@pubsubhelper.golang.org, golang-...@googlegroups.com, kokoro, Rebecca Stambler, Suzy Mueller, golang-co...@googlegroups.com

          Hyang-Ah Hana Kim submitted this change.

          View Change

          Approvals: Rebecca Stambler: Looks good to me, approved Hyang-Ah Hana Kim: Trusted; Run TryBots kokoro: TryBots succeeded
          src/goLint: switch the default lint tool to staticcheck

          Golint is unmaintained and effectively deprecated.
          So, switch to staticcheck, which is one of the existing linter
          options we've provided, and is actively maintained.

          Compared to golint, we observed staticcheck provides more useful
          signals about the code style and common errors, while it is still
          easy to use. Some controversial checks existed in the golint are
          turned off by default (ST1000, ST1003, ST1016), or removed. Users
          can turn them on if want, by supplying -checks as lintFlags.
          Unlike golint, staticcheck reports only compile errors and does
          not show other lint errors if compile errors are present. Because
          the compile errors will be also detected by the language server
          or by the buildOnSave/vetOnSave checks and the extension will
          deduplicate them, it may look to users as if the linter wasn't
          running - I am not sure how much this will bother users yet.


          Fixes golang/vscode-go#189
          Updates #38968

          Change-Id: Ie9334867aef3673aed01d7eaf757966486178dbc
          Reviewed-on: https://go-review.googlesource.com/c/vscode-go/+/279212
          Trust: Hyang-Ah Hana Kim <hya...@gmail.com>
          Run-TryBot: Hyang-Ah Hana Kim <hya...@gmail.com>
          TryBot-Result: kokoro <noreply...@google.com>
          Reviewed-by: Rebecca Stambler <rsta...@golang.org>

          ---
          M .github/workflows/release-nightly.yml
          M .github/workflows/test-long-all.yml
          M .github/workflows/test-long.yml
          M .github/workflows/test-smoke.yml
          M build/all.bash
          M docs/settings.md
          M docs/tools.md
          M package.json
          M src/goLint.ts
          M src/goTools.ts
          M test/integration/extension.test.ts
          M test/testdata/linterTest/linter_1.go
          M test/testdata/linterTest/linter_2.go
          13 files changed, 47 insertions(+), 47 deletions(-)

          diff --git a/.github/workflows/release-nightly.yml b/.github/workflows/release-nightly.yml
          index 0fd28c3..7341c45 100644
          --- a/.github/workflows/release-nightly.yml
          +++ b/.github/workflows/release-nightly.yml
          @@ -57,7 +57,7 @@
          diff --git a/.github/workflows/test-long-all.yml b/.github/workflows/test-long-all.yml
          index a999273..6e7521b 100644
          --- a/.github/workflows/test-long-all.yml
          +++ b/.github/workflows/test-long-all.yml
          @@ -53,7 +53,7 @@

          go get github.com/sqs/goreturns
          go get github.com/uudashr/gopkgs/v2/cmd/gopkgs
          go get github.com/zmb3/gogetdoc
          - go get golang.org/x/lint/golint
          + go get honnef.co/go/tools/...
          go get golang.org/x/tools/cmd/gorename
          go get golang.org/x/tools/gopls
          go get github.com/cweill/gotests/...
          diff --git a/.github/workflows/test-long.yml b/.github/workflows/test-long.yml
          index 4d6119b..3070067 100644
          --- a/.github/workflows/test-long.yml
          +++ b/.github/workflows/test-long.yml
          diff --git a/.github/workflows/test-smoke.yml b/.github/workflows/test-smoke.yml
          index 9dcb91c..e314ecd 100644
          --- a/.github/workflows/test-smoke.yml
          +++ b/.github/workflows/test-smoke.yml
          @@ -50,7 +50,7 @@
          index a13776f..fa80da7 100755
          --- a/build/all.bash
          +++ b/build/all.bash
          @@ -115,7 +115,7 @@

          GO111MODULE=on go get github.com/sqs/goreturns
          GO111MODULE=on go get github.com/uudashr/gopkgs/v2/cmd/gopkgs
          GO111MODULE=on go get github.com/zmb3/gogetdoc
          - GO111MODULE=on go get golang.org/x/lint/golint
          + GO111MODULE=on go get honnef.co/go/tools/...
          GO111MODULE=on go get golang.org/x/tools/cmd/gorename
           	GO111MODULE=on go get github.com/go-delve/delve/cmd/dlv@master
          }
          diff --git a/docs/settings.md b/docs/settings.md
          index 9f53602..36ef931 100644
          --- a/docs/settings.md
          +++ b/docs/settings.md
          @@ -312,9 +312,9 @@
          ### `go.lintTool`

          Specifies Lint tool name.<br/>
          -Allowed Options: `golint`, `golangci-lint`, `revive`, `staticcheck`
          +Allowed Options: `staticcheck`, `golint`, `golangci-lint`, `revive`


          -Default: `"golint"`
          +Default: `"staticcheck"`
          ### `go.liveErrors`

           Use gotype on the file currently being edited and report any semantic or syntactic errors found after configured delay. Not applicable when using the language server.
          diff --git a/docs/tools.md b/docs/tools.md
          index fc3f9ce..2cf6201 100644
          --- a/docs/tools.md
          +++ b/docs/tools.md
          @@ -60,13 +60,14 @@

          This tool provides support for the [`Go: Generate Unit Tests`](features.md#generate-unit-tests) set of commands.

          -### [`golint`]
          +### [`staticcheck`]

          -This is the default lint tool. Other lint tools can be used by configuring the [`"go.lintTool"`](settings.md#go.lintTool) setting. Other options include:
          +This is the default lint tool. See the [full list of checks](https://staticcheck.io/docs/checks) that `staticcheck` provides. Other lint tools can be used by configuring the [`"go.lintTool"`](settings.md#go.lintTool) setting.
          +Other options include:

          - * [`staticcheck`]: This tool provides a great deal of useful checks that are not provided by [`golint`]. See the full list at [staticcheck.io/docs/checks](https://staticcheck.io/docs/checks). It is also officially supported by the [Go team at Google](https://staticcheck.io/sponsors).
          - * [`golangci-lint`]: This tool combines a number of existing lint tools, including [staticcheck](#staticcheck), into one interface.
          + * [`golangci-lint`]: This meta-linter combines a number of existing lint tools, including [staticcheck](#staticcheck), into one interface.

          * [`revive`]: This tool is an enhancement on top of [`golint`], and it provides additional checks.
          +  * [`golint`]: This used to be the default linter used by this extension before it was officially deprecated.


          You can use the [`"go.lintFlags"`](settings.md#go.lintFlags) setting to further configure your linter of choice. Most linters can be configured via special configuration files, but you may still need to pass these command-line flags. The configuration documentation for each supported linter is listed here:

          diff --git a/package.json b/package.json
          index 1f9d8e2..393fb6c 100644
          --- a/package.json
          +++ b/package.json
          @@ -977,14 +977,14 @@

          },
          "go.lintTool": {
          "type": "string",
          - "default": "golint",
          + "default": "staticcheck",
          "description": "Specifies Lint tool name.",
          "scope": "resource",
          "enum": [
          +            "staticcheck",
          "golint",
          "golangci-lint",
          - "revive",
          - "staticcheck"
          + "revive"
          ]
          },
          "go.lintFlags": {
          diff --git a/src/goLint.ts b/src/goLint.ts
          index cad38de..685c644 100644
          --- a/src/goLint.ts
          +++ b/src/goLint.ts
          @@ -9,14 +9,7 @@
          import { toolExecutionEnvironment } from './goEnv';
          import { lintDiagnosticCollection } from './goMain';
          import { diagnosticsStatusBarItem, outputChannel } from './goStatus';
          -import {
          - getToolsGopath,
          - getWorkspaceFolderPath,
          - handleDiagnosticErrors,
          - ICheckResult,
          - resolvePath,
          - runTool
          -} from './util';
          +import { getWorkspaceFolderPath, handleDiagnosticErrors, ICheckResult, resolvePath, runTool } from './util';
          /**
          * Runs linter on the current file, package or workspace.
          */
          @@ -81,7 +74,7 @@

          return Promise.resolve([]);
          }

          - const lintTool = goConfig['lintTool'] || 'golint';
          + const lintTool = goConfig['lintTool'] || 'staticcheck';
          const lintFlags: string[] = goConfig['lintFlags'] || [];
          const lintEnv = toolExecutionEnvironment();
          const args: string[] = [];
          @@ -102,16 +95,6 @@
          }
          args.push(flag);
          });
          - if (lintTool === 'gometalinter') {
          - if (args.indexOf('--aggregate') === -1) {
          - args.push('--aggregate');
          - }
          - if (goConfig['toolsGopath']) {
          - // gometalinter will expect its linters to be in the GOPATH
          - // So add the toolsGopath to GOPATH
          - lintEnv['GOPATH'] += path.delimiter + getToolsGopath();
          - }
          - }
          if (lintTool === 'golangci-lint') {
          if (args.indexOf('run') === -1) {
          args.unshift('run');
          diff --git a/src/goTools.ts b/src/goTools.ts
          index 6e9c64a..a4ec994 100644

          --- a/src/goTools.ts
          +++ b/src/goTools.ts
          @@ -343,7 +343,7 @@
          name: 'golint',
          importPath: 'golang.org/x/lint/golint',
          replacedByGopls: false,
          - isImportant: true,
          + isImportant: false,
          description: 'Linter',
          minimumGoVersion: semver.coerce('1.9')
           	},
          diff --git a/test/integration/extension.test.ts b/test/integration/extension.test.ts
          index 0d28d30..cd69f9d 100644
          --- a/test/integration/extension.test.ts
          +++ b/test/integration/extension.test.ts
          @@ -425,8 +425,11 @@
          const warnings = await goLint(
          file2.uri,
          Object.create(getGoConfig(), {

          - lintTool: { value: 'golint' },
          - lintFlags: { value: [] }
          + lintTool: { value: 'staticcheck' },
          + lintFlags: { value: ['-checks', 'all,-ST1000,-ST1016'] }
          + // staticcheck skips debatable checks such as ST1003 by default,
          + // but this test depends on ST1003 (MixedCaps package name) presented in both files
          + // in the same package. So, enable that.
          }),
          'package'
          );
          @@ -448,15 +451,17 @@

          vetOnSave: { value: 'package' },
          vetFlags: { value: ['-all'] },
          lintOnSave: { value: 'package' },
          - lintTool: { value: 'golint' },
          + lintTool: { value: 'staticcheck' },
          lintFlags: { value: [] },
          buildOnSave: { value: 'package' }
          });
          const expectedLintErrors = [
          + // Unlike golint, staticcheck will report only those compile errors,
          + // but not lint errors when the program is broken.
          {
          - line: 7,
          + line: 11,
          severity: 'warning',
          - msg: 'exported function Print2 should have comment or be unexported'
          + msg: 'undeclared name: prin (compile)'
          }
           		];
          // If a user has enabled diagnostics via a language server,
          @@ -466,6 +471,7 @@
          3 is the latest approved patch-set. The change was submitted with unreviewed changes in the following files: The name of the file: docs/tools.md Insertions: 1, Deletions: 1. ``` @@ -69:70, +69:70 @@ - * [`golint`]: This used to be the default linter used by this extension before it was officially deprecated. + * [`golint`]: This used to be the default linter used by this extension before it was officially deprecated. ```

          To view, visit change 279212. To unsubscribe, or for help writing mail filters, visit settings.

          Gerrit-Project: vscode-go
          Gerrit-Branch: master
          Gerrit-Change-Id: Ie9334867aef3673aed01d7eaf757966486178dbc
          Gerrit-Change-Number: 279212
          Gerrit-PatchSet: 6
          Gerrit-Owner: Hyang-Ah Hana Kim <hya...@gmail.com>
          Gerrit-Reviewer: Hyang-Ah Hana Kim <hya...@gmail.com>
          Gerrit-Reviewer: Rebecca Stambler <rsta...@golang.org>
          Gerrit-Reviewer: Suzy Mueller <suz...@golang.org>
          Gerrit-Reviewer: kokoro <noreply...@google.com>
          Gerrit-MessageType: merged
          Reply all
          Reply to author
          Forward
          0 new messages