How to make autocompletion as in goland?
For VSC.
How do I need.
No good.
I have installed packages:
gocode
godef
golint
go-find-references
go-outline
goreturns
gorename
gopkgs
go-symbols
And configured settings.json:
{
"go.toolsGopath": "/home/user/go",
"go.gopath": "/home/user/go",
"go.goroot": "/snap/go/3739",
"go.buildOnSave": true,
"go.lintOnSave": true,
"go.vetOnSave": true,
"go.buildFlags": [],
"go.lintFlags": [],
"go.vetFlags": [],
"go.useCodeSnippetsOnFunctionSuggest": false,
"go.formatOnSave": false,
"go.formatTool": "goreturns"
}
Within VS Code go to the extensions tab and search for "Go". There will be one listed created by Microsoft which provides IntelliSense. Install this extension and restart VS Code, you should have the functionality you are looking for.
Note: you will need to be in a .go file for the IntelliSense to kick in.
Related
I am working on macOS Catalina versions 10.15.7.
I have a problem with Ruby(Peng Lv) extension for VScode. It seems it does work - no syntax highlighting except for the 'do', 'end', symbols ':', strings and comments.
Here is the list of all my extension:
endwise 1.4.2
Ruby(Peng Lv) 0,28,1
Ruby Solargraph 0,21,1
VSCode Ruby 0.28.0
vscodhe-icons 11.1.0
and my settings.json looks like this:
{
"workbench.colorTheme": "Visual Studio Dark",
"editor.tabSize": 2,
"emmet.triggerExpansionOnTab": true,
"window.zoomLevel": 0,
"explorer.compactFolders": false,
"workbench.iconTheme": "vscode-icons",
"ruby.useBundler": true, // use the internal language server (see below)
"files.autoSave": "afterDelay",
"ruby.format": true
}
I have tried installing many different version od Ruby(Peng Lv) extensions but nothing changed.I really don't know what is the issue. Do you know what should I do to resolve this annoying problem?
In case someone came across that problem, all you have to do is change the VScode theme from Dark to Dark+.
when starting a go module on VSCode I get prompted to install some tool
choosing install the installation fails, below the logs in vscode terminal
VSCODE keeps yelling at me an "fail to install" stuff, simply because ignores my path
as you can see below
Tools environment: GOPATH=/home/go
Installing 1 tool at /home/go/bin in module mode.
gopls
Installing golang.org/x/tools/gopls FAILED
1 tools failed to install.
gopls: failed to install gopls(golang.org/x/tools/gopls): Error: Command failed: /usr/local/go/bin/go get -v golang.org/x/tools/gopls
go: writing stat cache: mkdir /home/go: permission denied
go: downloading golang.org/x/tools/gopls v0.5.1
go: downloading golang.org/x/tools v0.0.0-20201017001424-6003fad69a88
go get golang.org/x/tools/gopls: mkdir /home/go: permission denied
undefined
these are my GOPATH and GOROOT
# GOLANG
export GOROOT=/usr/local/go
export GOPATH=$HOME/go
export PATH=$GOPATH/bin:$PATH
export PATH=$GOROOT/bin:$PATH
and this is my vscode settings.json
{
"[dart]": {
"editor.formatOnSave": true,
"editor.formatOnType": true,
"editor.rulers": [
80
],
"editor.selectionHighlight": false,
"editor.suggest.snippetsPreventQuickSuggestions": false,
"editor.suggestSelection": "first",
"editor.tabCompletion": "onlySnippets",
"editor.wordBasedSuggestions": false
},
"workbench.iconTheme": "material-icon-theme",
"workbench.colorTheme": "One Dark Pro",
"dart.sdkPath": "/home/francesco/development/dart",
"dart.openDevTools": "flutter",
"go.formatTool": "goimports",
"dart.checkForSdkUpdates": false,
"go.useLanguageServer": true,
"go.inferGopath": false,
"go.gopath": "/home/go",
"go.goroot": "/usr/local/go"
}
what action should I take to fix the error?
Your error is:
go: writing stat cache: mkdir /home/go: permission denied
Go tries to write to /home/go. This folder is derived from:
export GOPATH=$HOME/go
So it looks your $HOME doesn't point to your home folder. GOPATH should point to a folder where you have write permission, because the module cache is located under GOPATH. So it should point to a folder under your user home, e.g. /home/francesco/go.
I recently solved this problem on my Windows machine. At first I had thought it was a file permissions problem. But it was a GOPATH environment variable problem.
I had it set to 2 values: C:\Program Files\Go (which is where I installed Go) and C:.... which was where I wanted all my Go projects to go.
So I removed the first entry. Just leaving GOPATH to point to the place on my hard drive where I wanted all my projects, and hey presto, problems gone, all tools installed correctly.
This may have been due to a previous version of Go not being entirely removed.
I recently started working on vscode. I wanted to debug my C code. But the moment I am launching the debugger getting Error : Unable to start debugging. The value of miDebuggerPath is invalid.
I have my gdb installed on wsl . It's path is /usr/bin/gdb. I have copied same path to launch.json in miDebuggerPath.
Here is my launch.json :
{
// Use IntelliSense to learn about possible attributes.
// Hover to view descriptions of existing attributes.
// For more information, visit: https://go.microsoft.com/fwlink/?linkid=830387
"version": "0.2.0",
"configurations": [
{
"name": "(gdb) Launch",
"type": "cppdbg",
"request": "launch",
"program": "${workspaceFolder}/bin/main",
"args": [],
"stopAtEntry": false,
"cwd": "${workspaceFolder}",
"environment": [],
"externalConsole": true,
"MIMode": "gdb",
"miDebuggerPath": "/usr/bin/gdb",
"setupCommands": [
{
"description": "Enable pretty-printing for gdb",
"text": "-enable-pretty-printing",
"ignoreFailures": true
}
]
}
]
}
It should not throw the error and I should able to launch my debugger.
So this happened to me on WSL-Ubuntu. In my case gdb was broken because of unmet dependencies. Took a while to fix but once I reinstalled gdb properly in my WSL-Ubuntu, I finally got it working.
Installing gdb can be done on shell as
sudo apt-get install gdb
There can be multiple reasons why it could end up as broken, but once you fix gdb, vscode-debugging should be running. At the very least, you won't see that error popping.
I had the same problem, my solution was:
1. Change this section in launch.json
"miDebuggerPath": "/usr/bin/gdb",
for:
"miDebuggerPath": "C:/MinGW/bin/gdb.exe",
2. Do you need to install in your PC MinGW, this is the link:
https://osdn.net/projects/mingw/downloads/68260/mingw-get-setup.exe/
3. Next, open the MinGW then you install in the URL "C:/MinGW/bin" the gdb (select)
mingw32-gdb-bin
4. Enjoy the vs-code
it should be
"miDebuggerPath": "/usr/bin/gdbus",
If you're running under WSL, you should check where gdb is in your current distro to set your "miDebuggerPath" using
whereis gdb
in my case it was in
/usr/bin/gdb
but it could be somewhere else, that depends on what Linux distribution are you using with WSL
Could you try this:
sudo apt install binfmt-support
I am using VcXsrv, and this fixed all my installation problems, including chrome and GNU C++.
i had a similar problem ,this fixed. WINDOWS 10
QUICK ANSWER : try
1)C:\your compiler\bin\gdb.exe (paste your compiler path )
or
2)C:\TDM-GCC-32\bin\gdb32.exe for 32 bit compiler .(in my case)
(i tried to use opengl GLFW glad with 32bit tdm-gcc c++ compiler , i used a repo from OpenGL C++ template by vkphillia
but when i tried to run it in vs code using "run without debugging " option ,it showed the error "Unable to start debugging : The value of miDebuggerPath is invalid",
i copied my tdm_gcc compiler's bin path in midebugger path and it was like this ,
C:\TDM-GCC-32\bin\gdb.exe , but it did not remove the error then i checked for the gdb.exe application in my tdm gcc compiler bin where i noticed that there was no gdb.exe but a gdb32.exe file
I had the similar problem, running on linux.
Installing gdb fixed it.
visual studio code using golang debugger does not match the gopath path code ?
I construct up golang environment using visual studio code IDE MAC OS, then install the necessary tools:
go get -v -u github.com/peterh/liner github.com/derekparker/delve/cmd/dlv
go get -u -v github.com/nsf/gocode
go get -u -v github.com/rogpeppe/godef
go get -u -v github.com/golang/lint/golint
go get -u -v github.com/lukehoban/go-find-references
go get -u -v github.com/lukehoban/go-outline
go get -u -v sourcegraph.com/sqs/goreturns
go get -u -v golang.org/x/tools/cmd/gorename
go get -u -v github.com/tpng/gopkgs
go get -u -v github.com/newhook/go-symbols
I ever set my go path /Users/friends/gopath , before long I changed my gopath /Users/friends/Document/share/gopath. I changed the gopath ~/.bash_profile ,visual studio code setting about
go.gopath": "/Users/friends/Documents/VirtualMachine/share/gopath
when I debug my code, it tips that can't find the file in/Users/friends/gopath/src/...../apiSGetChainsIds.go , actually the file exist in /Users/friends/Documents/VirtualMachine/share/gopath/src/..../apiSGetChainsIds.go .It is obvious that the debugger find the previous gopath ,is it the golang tools bug? or something I wrong?
my usersetting is
{
"files.autoSave": "afterDelay",
//"go.buildOnSave": "package",
//"go.lintOnSave": "package",
//"go.vetOnSave": "package",
"go.buildFlags": [],
"go.lintFlags": [],
"go.vetFlags": [],
"go.useCodeSnippetsOnFunctionSuggest": false,
"go.formatOnSave": false,
"go.formatTool": "goreturns",
"editor.fontSize": 14,
"go.goroot": "/usr/local/Cellar/go/1.8.3/libexec",
"go.gopath": "/Users/friends/Documents/VirtualMachine/share/gopath"
}
I had also the problem to get it to run today, and here is what was necessary:
get your self delve (https://github.com/derekparker/delve)
either a) if you prefer to build and install it, clone the repo to
~/go/src/github.com/derekparker/delve
and then run:
go install github.com/derekparker/delve/cmd/dlv
because of latest macOS security updates, you need also to code sign it:
codesign -s dlv-cert $(which dlv)
or b) try brew
add a launch configuration into launch.json, my working looked as follows:
"configurations": [
{
"name": "Launch Package",
"type": "go",
"request": "launch",
"mode": "debug",
"program": "${workspaceRoot}/myAppPackagePath/",
"cwd": "${workspaceRoot}",
"args": ["option1","option2","..."],
"showLog": true
}
]
I'm having trouble installing d3 typings. I followed Microsoft's instructions at https://github.com/Microsoft/PowerBI-visuals/blob/master/Tutorial/Typings.md as well as what Sachin Patney does in his video at https://www.youtube.com/watch?v=_2-yMGtEv2w.
Running "npm install typings -g" appears to work fine.
Running "typings install --save --global dt~d3" or "typings i dt~d3 -G" both yield this error: "typings ERR! message Attempted to compile "d3" as a global module, but it looks like an external module. You'll need to remove the global option to continue."
If I remove the global option, it adds the typings info in my visual's folder using a "modules" folder in the path instead of a "globals" folder (i.e., MyVisual|typings|modules|d3 instead of MyVisual|typings|globals|d3). Intellisense also doesn't work for d3.
Any idea why I can't install d3 typings globally?
Although #FabioEnne's answer did solve my problem regarding global install and intellisense, I still ran into other issues related to the initial cause of that problem. But I think I found the fix...
According to Jon Gallant:
The Power BI team just released v1.2 of the Custom Visuals SDK. With this version you now need to reference d3 v3.5.5 yourself. d3 v4 does not work yet. I’m working with the team to get a v4 compat and sample together, but for now you can only use v3.5.5.
(#FabioEnne's solution added v4.4.0 onto my system.)
Jon provides the solution to this problem at his site: http://blog.jongallant.com/2016/11/pbiviz-12-d3-35-reference/. (He included a video.)
This gist of Jon's solution is:
Install Typings:
npm i -g typings
Add d3 v3.5.5:
npm i d3#3.5.5 --save
Add d3 typing:
typings install d3=github:DefinitelyTyped/DefinitelyTyped/d3/d3.d.ts#6e2f2280ef16ef277049d0ce8583af167d586c59 --global --save
Add files to tsconfig.json:
{
"compilerOptions": {
"allowJs": true,
"emitDecoratorMetadata": true,
"experimentalDecorators": true,
"target": "ES5",
"sourceMap": true,
"out": "./.tmp/build/visual.js"
},
"files": [
".api/v1.3.0/PowerBI-visuals.d.ts",
"typings/index.d.ts",
"node_modules/d3/d3.min.js",
"src/visual.ts"
]
}
Right, I just had the same issues, do this and youl'll be fine:
Manually delete all the contents inside the folder "Typings"
Open Windows powershell and enter the following command:
npm install #types/d3
Open the tsconfig.json and modify it as follow:
{
"compilerOptions": {
"allowJs": true,
"emitDecoratorMetadata": true,
"experimentalDecorators": true,
"target": "ES5",
"sourceMap": true,
"out": "./.tmp/build/visual.js"
},
"files": [
".api/v1.3.0/PowerBI-visuals.d.ts",
"node_modules/#types/d3/index.d.ts",
"src/visual.ts"
]
}
In this way I was able to continue, let me know if it worked for you as well.