The way I do it in VS Code is to do something like this from the repo root:

# Get the dev version of Go into PATH for the editor and local dev work
$ export PATH=$PWD/bin:$PATH
# Build a baseline version of go and save it to restore if things break, or 
for comparison
$ (cd src; GOGC=off ./make.bash) && toolstash save
# Launch VS Code with the relevant module roots, with PATH set
$ code ../go.code-workspace

Where go.code-workspace is in the folder above my checkout (as it's not in 
.gitignore):

{
    "folders": [
                {
                        "path": "go/src"
                },
                {
                        "path": "go/src/cmd"
                },
                {
                        "path": "go/test"
                }
        ],
    "settings": {
                "editor.codeActionsOnSave": {"source.fixAll": false},
                "go.lintOnSave": "off",
                "go.lintTool": "staticcheck",
                "gopls": {
                        // "ui.semanticTokens": true,
                        "ui.diagnostic.analyses": {
                                "unsafeptr": false,
                                "simplifycompositelit": false,
                        },
                        "ui.diagnostic.staticcheck": false,
                },
                "go.languageServerFlags": [
                        "-remote=auto;godev",
                ],
        }
}

Which defines explicitly marks those roots for gopls, and sets a couple of 
settings that make editing the toolchain a little less annoying (thanks to 
the extra diagnostics and fixes and such).

It's entirely possible that there's an easier way to do this, or that it's 
already moot thanks to experimental multi-module stuff / workfile stuff. 
That'd be nice to know (so I can remove all of this), but for now this is 
what I do and I'm relatively content
On Thursday, February 24, 2022 at 4:20:17 PM UTC-8 mari.fr...@gmail.com 
wrote:

> Hi all,
>
> I wanted to dig deeper into Go and start exploring the toolchain and the 
> standard library. I cloned github.com/golang/go and noticed that the 
> src/cmd directory contains a go.mod. I opened my editor (Visual Studio Code 
> + Go plugin) in the src/cmd directory. I expected to be able to navigate 
> the code like I normally do, but something about that project makes my 
> editor unhappy.
>
> I assume that there are people here that already have their favourite 
> editor/IDE set up to contribute to the language itself. Can you please 
> share your setup? Are there any tips and tricks you can share to have code 
> navigation and autocompletion working in golang/go?
>

-- 
You received this message because you are subscribed to the Google Groups 
"golang-nuts" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to golang-nuts+unsubscr...@googlegroups.com.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/golang-nuts/029a9e25-fd81-4d5f-8e06-977ddd720b9an%40googlegroups.com.

Reply via email to