Skip to content
This repository has been archived by the owner on Jul 15, 2023. It is now read-only.

Document and maintain standard library development setup #3165

Closed
FiloSottile opened this issue Apr 8, 2020 · 6 comments
Closed

Document and maintain standard library development setup #3165

FiloSottile opened this issue Apr 8, 2020 · 6 comments
Labels

Comments

@FiloSottile
Copy link
Contributor

FiloSottile commented Apr 8, 2020

vscode-go and gopls mostly work on the standard library, which is awesome, but it takes some setup and it broke a few times recently. It would be great to document a supported setup, and maintain it such that it doesn't break over time.

Here's what I have so far in ~/go/src/.vscode/settings.json.

{
    "go.alternateTools": {
        "go": "~/go/bin/go"
    },
    // Workaround https://github.com/microsoft/vscode-go/issues/3163
    "gopls": {
        "env": {
            "PATH": "$HOME/go/bin/go:$PATH",
        },
    },
    // Keep tools built for this Go tree separate.
    "go.toolsGopath": "~/.vscode/godev",
    // Respect existing style in the standard library.
    "html.format.enable": false,
    "editor.codeActionsOnSave": {
        "source.organizeImports": false
    },
}

The following issues affect standard library development, and should be mentioned in the docs.

@stamblerre
Copy link
Contributor

Definitely agree that we need to add documentation for this use case. I have a few more questions inline.

vscode-go and gopls mostly work on the standard library

When you say "mostly" - are there features that don't work? If so, it would be good to know about so we can address the issues.

but it takes some setup and it broke a few times recently

What breakages are you referring to specifically? AFAIK, we've never respected the "go.alternateTools" setting, and we've always required users to open directories within a module. Are there others that I'm missing?

"editor.codeActionsOnSave": {
    "source.organizeImports": false
}

Out of curiosity, why do you disable import organization?

@stamblerre stamblerre added the upstream-gopls Issue for gopls label Apr 10, 2020
@FiloSottile
Copy link
Contributor Author

vscode-go and gopls mostly work on the standard library

When you say "mostly" - are there features that don't work? If so, it would be good to know about so we can address the issues.

I've noticed the occasional minor issue, but sometimes it's hard to tell if the tree is in a bad state, or if it's something gopls can fix. I'll pay more attention and open issues referencing this one when I do in the future.

I also do some development on the dev.boringcrypto branch, which I totally don't expect you to support, so I wonder how much breakage I was seeing because of that. I now have a separate worktree for that.

but it takes some setup and it broke a few times recently

What breakages are you referring to specifically? AFAIK, we've never respected the "go.alternateTools" setting, and we've always required users to open directories within a module. Are there others that I'm missing?

Not sure how, but it somewhat worked for me until recently even if I always opened GOROOT and did not set gopls.env. I think I went from go.goroot to go.alternateTools at some point and some things resumed working (although now I know it was still misconfigured). Before gopls and in the transition to gopls vscode-go also broke a couple times on the stdlib.

"editor.codeActionsOnSave": {
    "source.organizeImports": false
}

Out of curiosity, why do you disable import organization?

Imports in the standard library are not grouped (that is, golang.org/x imports are sorted with the rest), and I could not find a setting to get that behavior. It's niche, so I didn't bother opening a feature request. Maybe we should fix it in the standard library by doing a giant CL grouping them.

Relatedly, sometimes (maybe when the packages are new?) new imports get added with the std/ prefix. I could not figure out exactly when that happens.

@stamblerre
Copy link
Contributor

Thanks for the clarifications! Please file issues when you see something that's not working, since we want to make sure that gopls supports as many use cases as we can.

And, yeah I don't think goimports supports one block of imports. If you find a repro for the std/ case, please file an issue.

@stamblerre
Copy link
Contributor

@katiehockman filed a similar issue in the upstream repository, so I'm going to close this issue in favor of that one: golang/go#38603.

@FiloSottile
Copy link
Contributor Author

FWIW, I think the docs should be about how to make the whole vscode-go work for standard library development, not just gopls.

@heschi
Copy link

heschi commented Apr 29, 2020

Happened to skim this bug. std/ prefixes would most likely be a consequence of adding a new package, or maybe just a new symbol to a package, while being in the wrong GOROOT.

@vscodebot vscodebot bot locked and limited conversation to collaborators Jun 7, 2020
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
Projects
None yet
Development

No branches or pull requests

3 participants