Skip to content

Commit 0b77054

Browse files
logica0419gopherbot
authored andcommitted
extension/src/goLint: enabled to override path-mode flag
Currently, users can't override or disable any flags added by vscode-go. However, in some environments, the `path-mode` flag needs to be overridden. (#3750 (comment)) The flags related to the output format shouldn't be changed so that vscode-go can parse them correctly. Thus, I enable overriding the `path-mode` flag. Fixes #3750 Change-Id: I6258c7054ef91137c13d566744ac01a33caf0bd4 Reviewed-on: https://go-review.googlesource.com/c/vscode-go/+/667735 kokoro-CI: kokoro <[email protected]> LUCI-TryBot-Result: Go LUCI <[email protected]> Reviewed-by: Carlos Amedee <[email protected]> Reviewed-by: Hongxiang Jiang <[email protected]> Auto-Submit: Hongxiang Jiang <[email protected]>
1 parent 04fc87c commit 0b77054

File tree

2 files changed

+5
-9
lines changed

2 files changed

+5
-9
lines changed

CHANGELOG.md

+1
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,7 @@ diff between options locally discovered and options available for download.
1313
* Added a new lint tool, `golangci-lint-v2`. It's added as an installable tool, so you can install it via the `Go: Install/Update Tools` command.
1414
* You can switch v1 and v2 per workspace by using `golangci-lint` and `golangci-lint-v2` option. You must keep the `golangci-lint` executable version on your machine to v1 for that.
1515
* You can also use `golangci-lint` executable updated to v2. Just keep using the `golangci-lint` option for that.
16+
* The `path-mode` flag set by vscode-go can be overridden by the`go.lintFlags` option.
1617
* Looking for a way to format your code with golangci-lint v2 on VS Code? Check the [golangci-lint documentation](https://golangci-lint.run/welcome/integrations/#visual-studio-code).
1718

1819
### Fixes

extension/src/goLint.ts

+4-9
Original file line numberDiff line numberDiff line change
@@ -121,7 +121,7 @@ export async function goLint(
121121
const { moduleVersion } = await inspectGoToolVersion(getBinPath(lintTool));
122122
// if moduleVersion is undefined, treat it as version=1
123123
// if moduleVersion is higher than v1 (v2, v3...), treat it as version=2
124-
!moduleVersion || moduleVersion.startsWith('v1') ? (version = 1) : (version = 2);
124+
version = !moduleVersion || moduleVersion.startsWith('v1') ? 1 : 2;
125125
}
126126

127127
// append common flags
@@ -139,10 +139,10 @@ export async function goLint(
139139
// print only file:number:column
140140
args.push('--print-issued-lines=false');
141141
}
142-
if (args.indexOf('--out-format=colored-line-number') === -1) {
142+
if (args.indexOf('--out-format=line-number') === -1) {
143143
// print file:number:column.
144144
// Explicit override in case .golangci.yml calls for a format we don't understand
145-
args.push('--out-format=colored-line-number');
145+
args.push('--out-format=line-number');
146146
}
147147
break;
148148

@@ -160,12 +160,7 @@ export async function goLint(
160160
// Explicit override in case .golangci.yml calls for a format we don't understand
161161
args.push('--output.text.path=stdout');
162162
}
163-
if (args.indexOf('--output.text.colors=true') === -1) {
164-
// print file:number:column.
165-
// Explicit override in case .golangci.yml calls for a format we don't understand
166-
args.push('--output.text.colors=true');
167-
}
168-
if (args.indexOf('--path-mode=abs') === -1) {
163+
if (!args.some((v) => v.startsWith('--path-mode='))) {
169164
// print file name as absolute path
170165
args.push('--path-mode=abs');
171166
}

0 commit comments

Comments
 (0)