golang / vscode-go

Go extension for Visual Studio Code
https://marketplace.visualstudio.com/items?itemName=golang.Go
Other
3.86k stars 742 forks source link

Let "Add Import" search go.dev and list popular modules #398

Open ysmood opened 4 years ago

ysmood commented 4 years ago

Currently, it will list locally cached modules. It will be great if it can also start to list remote modules on go.dev while listing the local ones.

We can also provide a separate command like "Search Import" to list go.dev result only.

hyangah commented 4 years ago

Currently this importable package listing is implemented through gopkgs and there is an open issue accompanied with a PR by @marwan-at-work to replace gopkgs with go list. This feature request is to add another source for importable package listing.

cc @julieqiu for API provision from go.dev @stamblerre if gopls has any plan to support a similar feature

ysmood commented 4 years ago

@hyangah seems like go list doesn't support listing remote modules.

How about we add some typescript to send a request to the go.dev API and fetch the result then append them to the result of go list?

julieqiu commented 4 years ago

At the moment, there isn't an API for pkg.go.dev. We do intend to add one, but it's not something we are working on at the moment: golang/go#36785.

ysmood commented 4 years ago

Sure, we can leave this issue open, it's just a good to have function. If you ever used npm, they have this search online function like npm search zip, the result looks like:

Click to expand ``` $ npm search zip NAME | DESCRIPTION | AUTHOR | DATE | VERSION | KEYWORDS zip | An implementation… | =kriskowal… | 2014-04-05 | 1.2.0 | zip compression extract-zip | unzip a zip file… | =malept… | 2020-06-10 | 2.0.1 | unzip zip extract adm-zip | Javascript… | =cthackers | 2020-06-23 | 0.4.16 | zip methods archive unzip jszip | Create, read and… | =cwmma… | 2020-06-14 | 3.5.0 | zip deflate inflate archiver | a streaming… | =ctalkington | 2020-07-23 | 5.0.0 | archive archiver stream zip tar cross-zip | Cross-platform .zip… | =feross | 2020-05-10 | 3.1.0 | ZIP cross platform cross-platform linux mac os x windows zip zip-stream | a streaming zip… | =ctalkington | 2020-07-21 | 4.0.2 | archive stream zip-stream zip decompress | Extracting archives… | =shinnn =kevva | 2020-04-01 | 4.2.1 | bz2 bzip2 decompress extract tar tar.bz tar.gz zip unzip gulp-zip | ZIP compress files | =sindresorhus | 2020-06-27 | 5.0.2 | gulpplugin zip archive archiver compress compression file gulp-vinyl-zip | Streaming vinyl… | =joaomoreno | 2020-05-18 | 2.2.1 | gulp gulpplugin yazl yazul zip streams vinyl vinyl-zip file-type | Detect the file… | =mifi… | 2020-06-14 | 14.6.2 | mime file type archive image img pic picture flash photo video detect check is exif exe binary buffer uint8array jpg pn yauzl | yet another unzip… | =superjoe… | 2018-07-03 | 2.10.0 | unzip zip stream archive file decompress-response | Decompress a HTTP… | =sindresorhus | 2020-05-15 | 6.0.0 | decompress response http https zlib gzip zip deflate unzip ungzip incoming message stream compressed brotli node-stream-zip | node.js library for… | =antelle | 2020-06-02 | 1.11.2 | zip archive unzip stream minizlib | A small fast zlib… | =mylesborins… | 2019-10-05 | 2.1.0 | zlib gzip gunzip deflate inflate compression zip unzip s3-zip | Download selected… | =robodo | 2019-11-04 | 3.1.3 | amazon aws S3 zip files zip-a-folder | Forked the idea of… | =maugenst | 2020-02-08 | 0.0.12 | zip folder async promise tiny-inflate | A tiny inflate… | =devongovett | 2019-11-17 | 1.0.3 | inflate zlib gzip zip unzipper | Unzip… | =zjonsson | 2020-04-20 | 0.10.11 | zip unzip zlib uncompress archive stream extract w-zip | A compression tool… | =semisphere | 2020-06-01 | 1.0.5 | package tool compression zip 7z nodejs ```

Maybe one day go list will support that too.

hyangah commented 4 years ago

@ysmood let me be clear - We are not questioning the value of this new feature - I agree this is an interesting feature to investigate.

I mentioned gopkgs and go list to describe the current state. I brought in @julieqiu and @stamblerre because we need support from pkg.go.dev, and also we want to discuss where this information querying happens (from the extension side as we do currently, or eventually from gopls so other editors can share the benefit).

And, thank you for the feature request!

stamblerre commented 4 years ago

I think we should definitely integrate gopls with the future pkg.go.dev API. In addition to searching for packages to import, we'd also be able to offer unimported completions for packages outside of a user's module cache.

The feature request in gopls is https://github.com/golang/go/issues/32749.