Skip to content

Commit fb8ba52

Browse files
committed
vscode-go: remove references to gopkgs
Removed remaining references in the codebase to gopkgs. For #258. Change-Id: I9257b87316f193f960bd121bfdcc5cd890ac73d4 Reviewed-on: https://go-review.googlesource.com/c/vscode-go/+/382475 Trust: Jamal Carvalho <[email protected]> Run-TryBot: Jamal Carvalho <[email protected]> TryBot-Result: kokoro <[email protected]> Reviewed-by: Hyang-Ah Hana Kim <[email protected]>
1 parent 68fae93 commit fb8ba52

File tree

7 files changed

+33
-102
lines changed

7 files changed

+33
-102
lines changed

docs/settings.md

-1
Original file line numberDiff line numberDiff line change
@@ -54,7 +54,6 @@ Alternate tools or alternate paths for the same tools used by the Go extension.
5454
| `dlv` | Alternate tool to use instead of the dlv binary or alternate path to use for the dlv binary. <br/> Default: `"dlv"` |
5555
| `go` | Alternate tool to use instead of the go binary or alternate path to use for the go binary. <br/> Default: `"go"` |
5656
| `go-outline` | Alternate tool to use instead of the go-outline binary or alternate path to use for the go-outline binary. <br/> Default: `"go-outline"` |
57-
| `gopkgs` | Alternate tool to use instead of the gopkgs binary or alternate path to use for the gopkgs binary. <br/> Default: `"gopkgs"` |
5857
| `gopls` | Alternate tool to use instead of the gopls binary or alternate path to use for the gopls binary. <br/> Default: `"gopls"` |
5958
### `go.autocompleteUnimportedPackages`
6059

docs/tools.md

-4
Original file line numberDiff line numberDiff line change
@@ -38,10 +38,6 @@ For a comprehensive overview of how to debug your Go programs, please see the [d
3838
### [`dlv-dap`](https://github.com/go-delve/delve)
3939
This extension requires an unstable version of [`dlv`](#dlv) when users opt in to use Delve's native DAP implementation. `dlv-dap` is a `dlv` built from the master, which includes unreleased features. Please see the documentation about [Dlv DAP - Delve's Native DAP implementation](./dlv-dap.md) for details.
4040

41-
### [`gopkgs`](https://pkg.go.dev/github.com/uudashr/gopkgs?tab=overview)
42-
43-
This tool provides autocompletion for unimported packages. Replacement of `gopkgs` with [`gopls`] is a work-in-progress. <!--TODO: reference to the issue-->
44-
4541
### [`go-outline`](https://pkg.go.dev/github.com/ramya-rao-a/go-outline?tab=overview)
4642

4743
This tool provides the information needed to compute the various test code lenses. It will be replaced with [`gopls`]. <!--TODO: reference to the issue-->

docs/troubleshooting.md

+1-1
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,7 @@ Check the bottom of the VS Code window for any warnings and notifications. For e
1818

1919
Run the [`Go: Locate Configured Go Tools`](commands.md#go-locate-configured-go-tools) command. The output is split into sections.
2020

21-
In the first indented section, check that at least `gopkgs`, `go-outline`, `dlv`, and `gopls` are installed -- they're necessary for the extension's basic functionality. The other tools [provide optional features](tools.md) and are less important unless you need those features. You can install tools by running the [`Go: Install/Update Tools`](commands.md#go-installupdate-tools) command.
21+
In the first indented section, check that at least `go-outline`, `dlv`, and `gopls` are installed -- they're necessary for the extension's basic functionality. The other tools [provide optional features](tools.md) and are less important unless you need those features. You can install tools by running the [`Go: Install/Update Tools`](commands.md#go-installupdate-tools) command.
2222

2323
Then, look at the `Workspace Folder` section(s) for the environment in use. Verify that `GOROOT` is set to a valid Go installation; if not, follow the [getting started guide](../README.md#install-go). If `GOPATH` is unset, or surprising, read more about [setting up your `GOPATH`](gopath.md#setting-gopath). Also, `GOMOD` should usually point to your project's `go.mod` file if you're in module mode. (More complicated workspace setups may have a blank `GOMOD`. See the `gopls` [workspace documentation](https://github.com/golang/tools/blob/master/gopls/doc/workspace.md) for more on valid workspace setups.) To change the workspace environment, use settings such as [`go.gopath`](settings.md#go.gopath) and [`go.toolsEnvVars`](settings.md#go.toolsEnvVars).
2424

package.json

-5
Original file line numberDiff line numberDiff line change
@@ -1963,11 +1963,6 @@
19631963
"default": "go",
19641964
"description": "Alternate tool to use instead of the go binary or alternate path to use for the go binary."
19651965
},
1966-
"gopkgs": {
1967-
"type": "string",
1968-
"default": "gopkgs",
1969-
"description": "Alternate tool to use instead of the gopkgs binary or alternate path to use for the gopkgs binary."
1970-
},
19711966
"gopls": {
19721967
"type": "string",
19731968
"default": "gopls",

src/goPackages.ts

+13-13
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@ import { toolExecutionEnvironment } from './goEnv';
1212
import { getBinPath, getCurrentGoPath, isVendorSupported } from './util';
1313
import { envPath, fixDriveCasingInWindows, getCurrentGoRoot, getCurrentGoWorkspaceFromGOPATH } from './utils/pathUtils';
1414

15-
type GopkgsDone = (res: Map<string, PackageInfo>) => void;
15+
type GoListPkgsDone = (res: Map<string, PackageInfo>) => void;
1616
interface Cache {
1717
entry: Map<string, PackageInfo>;
1818
lastHit: number;
@@ -23,11 +23,11 @@ export interface PackageInfo {
2323
isStd: boolean;
2424
}
2525

26-
let gopkgsNotified = false;
26+
let goListPkgsNotified = false;
2727
let cacheTimeout = 5000;
2828

29-
const gopkgsSubscriptions: Map<string, GopkgsDone[]> = new Map<string, GopkgsDone[]>();
30-
const gopkgsRunning: Set<string> = new Set<string>();
29+
const goListPkgsSubscriptions: Map<string, GoListPkgsDone[]> = new Map<string, GoListPkgsDone[]>();
30+
const goListPkgsRunning: Set<string> = new Set<string>();
3131

3232
const allPkgsCache: Map<string, Cache> = new Map<string, Cache>();
3333

@@ -87,28 +87,28 @@ function getAllPackagesNoCache(workDir: string): Promise<Map<string, PackageInfo
8787
resolve(pkgMap);
8888
};
8989

90-
let subs = gopkgsSubscriptions.get(workDir);
90+
let subs = goListPkgsSubscriptions.get(workDir);
9191
if (!subs) {
9292
subs = [];
93-
gopkgsSubscriptions.set(workDir, subs);
93+
goListPkgsSubscriptions.set(workDir, subs);
9494
}
9595
subs.push(callback);
9696

9797
// Ensure only single gokpgs running
98-
if (!gopkgsRunning.has(workDir)) {
99-
gopkgsRunning.add(workDir);
98+
if (!goListPkgsRunning.has(workDir)) {
99+
goListPkgsRunning.add(workDir);
100100

101101
goListPkgs(workDir).then((pkgMap) => {
102-
gopkgsRunning.delete(workDir);
103-
gopkgsSubscriptions.delete(workDir);
102+
goListPkgsRunning.delete(workDir);
103+
goListPkgsSubscriptions.delete(workDir);
104104
subs.forEach((cb) => cb(pkgMap));
105105
});
106106
}
107107
});
108108
}
109109

110110
/**
111-
* Runs gopkgs
111+
* Runs `go list all std`
112112
* @argument workDir. The workspace directory of the project.
113113
* @returns Map<string, string> mapping between package import path and package name
114114
*/
@@ -122,11 +122,11 @@ export async function getAllPackages(workDir: string): Promise<Map<string, Packa
122122

123123
const pkgs = await getAllPackagesNoCache(workDir);
124124
if (!pkgs || pkgs.size === 0) {
125-
if (!gopkgsNotified) {
125+
if (!goListPkgsNotified) {
126126
vscode.window.showInformationMessage(
127127
'Could not find packages. Ensure `go list -f {{.Name}};{{.ImportPath}}` runs successfully.'
128128
);
129-
gopkgsNotified = true;
129+
goListPkgsNotified = true;
130130
}
131131
}
132132
allPkgsCache.set(workDir, {

src/goTools.ts

-1
Original file line numberDiff line numberDiff line change
@@ -139,7 +139,6 @@ export function getConfiguredTools(
139139
// Start with default tools that should always be installed.
140140
for (const name of [
141141
'gocode',
142-
'gopkgs',
143142
'go-outline',
144143
'go-symbols',
145144
'guru',

test/integration/extension.test.ts

+19-77
Original file line numberDiff line numberDiff line change
@@ -761,59 +761,26 @@ It returns the number of bytes written and any write error encountered.
761761
} // not working in module mode.
762762
const vendorSupport = await isVendorSupported();
763763
const filePath = path.join(fixturePath, 'vendoring', 'main.go');
764-
const workDir = path.dirname(filePath);
765764
const vendorPkgsFullPath = ['test/testfixture/vendoring/vendor/example/vendorpls'];
766765
const vendorPkgsRelativePath = ['example/vendorpls'];
767766

768-
const gopkgsPromise = getAllPackages(workDir).then((pkgMap) => {
769-
const pkgs = Array.from(pkgMap.keys()).filter((p) => {
770-
const pkg = pkgMap.get(p);
771-
return pkg && pkg.name !== 'main';
772-
});
767+
vscode.workspace.openTextDocument(vscode.Uri.file(filePath)).then(async (document) => {
768+
await vscode.window.showTextDocument(document);
769+
const pkgs = await listPackages();
773770
if (vendorSupport) {
774-
vendorPkgsFullPath.forEach((pkg) => {
775-
assert.equal(pkgs.indexOf(pkg) > -1, true, `Package not found by goPkgs: ${pkg}`);
776-
});
777771
vendorPkgsRelativePath.forEach((pkg) => {
772+
assert.equal(pkgs.indexOf(pkg) > -1, true, `Relative path for vendor package ${pkg} not found`);
773+
});
774+
vendorPkgsFullPath.forEach((pkg) => {
778775
assert.equal(
779776
pkgs.indexOf(pkg),
780777
-1,
781-
`Relative path to vendor package ${pkg} should not be returned by gopkgs command`
778+
`Full path for vendor package ${pkg} should be shown by listPackages method`
782779
);
783780
});
784781
}
785782
return pkgs;
786783
});
787-
788-
const listPkgPromise: Thenable<string[]> = vscode.workspace
789-
.openTextDocument(vscode.Uri.file(filePath))
790-
.then(async (document) => {
791-
await vscode.window.showTextDocument(document);
792-
const pkgs = await listPackages();
793-
if (vendorSupport) {
794-
vendorPkgsRelativePath.forEach((pkg) => {
795-
assert.equal(pkgs.indexOf(pkg) > -1, true, `Relative path for vendor package ${pkg} not found`);
796-
});
797-
vendorPkgsFullPath.forEach((pkg) => {
798-
assert.equal(
799-
pkgs.indexOf(pkg),
800-
-1,
801-
`Full path for vendor package ${pkg} should be shown by listPackages method`
802-
);
803-
});
804-
}
805-
return pkgs;
806-
});
807-
808-
const values = await Promise.all<string[]>([gopkgsPromise, listPkgPromise]);
809-
if (!vendorSupport) {
810-
const originalPkgs = values[0].sort();
811-
const updatedPkgs = values[1].sort();
812-
assert.equal(originalPkgs.length, updatedPkgs.length);
813-
for (let index = 0; index < originalPkgs.length; index++) {
814-
assert.equal(updatedPkgs[index], originalPkgs[index]);
815-
}
816-
}
817784
});
818785

819786
test('Vendor pkgs from other projects should not be allowed to import', async function () {
@@ -824,44 +791,19 @@ It returns the number of bytes written and any write error encountered.
824791
const filePath = path.join(fixturePath, 'baseTest', 'test.go');
825792
const vendorPkgs = ['test/testfixture/vendoring/vendor/example/vendorpls'];
826793

827-
const gopkgsPromise = new Promise<void>((resolve, reject) => {
828-
const cmd = cp.spawn(getBinPath('gopkgs'), ['-format', '{{.ImportPath}}'], {
829-
env: process.env
830-
});
831-
const chunks: any[] = [];
832-
cmd.stdout.on('data', (d) => chunks.push(d));
833-
cmd.on('close', () => {
834-
const pkgs = chunks
835-
.join('')
836-
.split('\n')
837-
.filter((pkg) => pkg)
838-
.sort();
839-
if (vendorSupport) {
840-
vendorPkgs.forEach((pkg) => {
841-
assert.equal(pkgs.indexOf(pkg) > -1, true, `Package not found by goPkgs: ${pkg}`);
842-
});
843-
}
844-
return resolve();
845-
});
794+
vscode.workspace.openTextDocument(vscode.Uri.file(filePath)).then(async (document) => {
795+
await vscode.window.showTextDocument(document);
796+
const pkgs = await listPackages();
797+
if (vendorSupport) {
798+
vendorPkgs.forEach((pkg) => {
799+
assert.equal(
800+
pkgs.indexOf(pkg),
801+
-1,
802+
`Vendor package ${pkg} should not be shown by listPackages method`
803+
);
804+
});
805+
}
846806
});
847-
848-
const listPkgPromise: Thenable<void> = vscode.workspace
849-
.openTextDocument(vscode.Uri.file(filePath))
850-
.then(async (document) => {
851-
await vscode.window.showTextDocument(document);
852-
const pkgs = await listPackages();
853-
if (vendorSupport) {
854-
vendorPkgs.forEach((pkg) => {
855-
assert.equal(
856-
pkgs.indexOf(pkg),
857-
-1,
858-
`Vendor package ${pkg} should not be shown by listPackages method`
859-
);
860-
});
861-
}
862-
});
863-
864-
return Promise.all<void>([gopkgsPromise, listPkgPromise]);
865807
});
866808

867809
test('Workspace Symbols', () => {

0 commit comments

Comments
 (0)