visual studio code debug code does not match gopath using golang - go

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
}
]

Related

GO permissions issue for Visual Studio Code (MAC OS Big Sur 11.3.1)

I was wondering if you could help me with this issue I've really been struggling with recently.
I have recently installed Visual Studio Code and GO in order to work on a few projects and I have run into this error when attempting to download the GO extensions for my IDE;
Installing github.com/fatih/gomodifytags#latest FAILED
{
"killed": false,
"code": 1,
"signal": null,
"cmd": "/usr/local/go/bin/go install -v
github.com/fatih/gomodifytags#latest",
"stdout": "",
"stderr": "go: could not create module cache: mkdir /Users/go:
permission denied\n"
}
Every single attempt to install a GO related file on my IDE has been met with a permissions denial.
sudo chown -R your_name:admin $((go env GOROOT))

Auto run a command when terminal opens in Visual Studio Code on Mac

I'd like to run the command reload -b whenever a terminal opens in Visual Studio Code on a Mac. The accepted answer to a similar question gives a deprecated warning.
I've set my default profile (ZSH) and configured it as suggested in the docs, but the command still doesn't run.
Any help is much appreciated - thanks
My settings.json looks like:
"terminal.integrated.defaultProfile.osx": "zsh",
"terminal.integrated.defaultProfile.windows": "zsh",
"terminal.integrated.profiles.osx": {
"zsh (login)": {
"path": "zsh",
"args": [
"reload -b"
]
}
},

Unable to start debugging : The value of miDebuggerPath is invalid

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.

env: ruby_executable_hooks: No such file or directory

When trying to build SASS, I'm getting the following error on Sublime Text 2. I've added the SASS build plugin from here https://github.com/jaumefontal/SASS-Build-SublimeText2
env: ruby_executable_hooks: No such file or directory
[Finished in 0.0s with exit code 127]
Not really sure what I should be doing here to troubleshoot this.
Thanks!!
The amount of negative votes tells me I need to add more information. The problem is I'm not quite sure what information I should be adding.
My SASS.sublime-build file inside /Library/Application Support/Sublime Text 2/Packages/SASS Build/
{
"cmd": ["sass", "--update", "$file:${file_path}/${file_base_name}.css", "--stop-on-error", "--no-cache"],
"selector": "source.sass, source.scss",
"line_regex": "Line ([0-9]+):",
"osx":
{
"path": "/Users/vskylabv/.rvm/gems/ruby-2.0.0-p247/bin/ruby_executable_hooks:/usr/local/bin:$PATH"
},
"windows":
{
"shell": "true"
}
}
which ruby_executable_hooks
/Users/vskylabv/.rvm/gems/ruby-2.0.0-p247/bin/ruby_executable_hooks
The sass file being run is actually a script, with a hashbang line along the lines of #!/usr/bin/env ruby_executable_hooks (if it's not in sass, it's in another file being called). Sublime's environment is not necessarily the same as your command line environment, which is why you're getting the error message you're seeing. Open a terminal, and type
which ruby_executable_hooks
to find out the directory it lives in. Then, open Packages/SASS-Build/SASS.sublime-build:
{
"cmd": ["sass", "--update", "$file:${file_path}/${file_base_name}.css", "--stop-on-error", "--no-cache"],
"selector": "source.sass, source.scss",
"line_regex": "Line ([0-9]+):",
"osx":
{
"path": "/usr/local/bin:$PATH"
},
"windows":
{
"shell": "true"
}
}
If you're on OS X, change the "path" line in the "osx" section to:
"path": "/full/path/to/ruby_executable_hooks:/usr/local/bin:$PATH"
and save the file. Note the full path should just be the directory containing ruby_executable_hooks - for example, /Users/MichaelT/.rvm/gems/ruby-2.0.0-p247/bin.
Good luck!
You need to run the following command in the Terminal to refresh the executable-hooks to the latest version. That should take care of the issue.
sudo gem install --user-install executable-hooks
I had the same problem using an rvm installed version of sass in NetBeans 7.4.
You should switch to system ruby to avoid the rvm issues.
rvm use system
Now, check that you have sass in your system ruby:
gem list sass
Then if no sass, install the sass gem:
gem install sass
On OS X this will put sass into /usr/bin/sass
/usr/bin is in your path already so your sublime-build config should work.

Sublime Text 2 OSX Grunt build system woe

I'm trying to use Sublime Text 2s build system to run a Grunt task. I have no issues using Grunt within Terminal. My setup works well on my Windows machine but my Mac hates it.
This is my .sublime-build configuration:
{
"selector": "grunt.js",
"working_dir": "${project_path}/js",
"windows": {
…
},
"osx": {
"cmd": ["grunt", "--no-color"]
}
}
And the output returned is:
[Errno 2] No such file or directory
The working directory and path returned are correct. My software versions are:
OSX 10.8.2
Node 0.8.9
NPM 1.1.68
Grunt 0.3.17
Sublime Text 2.0.1
Please save me any more frustrated Googling!
Make sure grunt is in your path with sublime (it can be different then your terminal path). To find the path type: npm bin -g. You can set the path in your sublime-build config:
{
"selector": "grunt.js",
"working_dir": "${project_path}",
"path": "/usr/local/bin",
"osx": {
"cmd": ["grunt", "--no-color"]
}
}
Just a nitpick, set the working_dir to the base project path. Not important as grunt will find up until it reaches a gruntfile but that will find the gruntfile slightly faster ;)

Resources