Thanks for sharing this! Picking up on that configuration, I found this 
piece of documentation about gopls [1]. I followed these steps:

   - Check out github.com/golang/go to /Users/frm/src/go.
   - Build the language distribution as described here [2].
   - Create a new VSCode workspace at /Users/frm/src/go.code-workspace 
   (shown below).
   - Add the necessary directories and configuration to the workspace.
   - Restart the language server.
   - Reinstall/Update all the tools.

This is the workspace configuration. I wanted to use the minimum amount of 
configuration, so I could understand what the right options really are.

{
"folders": [
{
"path": "go/src/cmd"
},
{
"path": "go/test"
},
{
"path": "go/src"
}
],
"settings": {
"go.goroot": "/Users/frm/src/go"
}
}

After following the steps above, I managed to have navigation and code 
completion in my editor.

[1]: 
https://github.com/golang/tools/blob/master/gopls/doc/advanced.md#working-on-the-go-source-distribution
[2]: https://go.dev/doc/install/source

On Friday, 25 February 2022 at 01:45:15 UTC+1 Zik Aeroh wrote:

> 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/feff5d92-1428-48d9-90de-b1a3ecc8893en%40googlegroups.com.

Reply via email to