how to debug revel framework(golang) application in visual studio code(vscode) - revel

{
"version": "0.2.0",
"configurations": [
{
"name": "Launch",
"type": "go",
"request": "attach",
"mode": "debug",
"remotePath": "",
"port": 2345,
"host": "127.0.0.1",
"program": "revel.exe",
"env": {},
"args": [],
"showLog": true
},
]
}
how to debug revel framework(golang) application in visual studio code(vscode)
how to write the configuration file(launch.json)

Here are the steps to debug a revel framework (golang) app in vscode.
Import revel project folder into vscode
Edit ~/.vscode/launch.json so that it looks like the following: (replace values in <> with values for your own local env.
{
"version": "0.2.0",
"configurations": [
{
"name": "Launch",
"type": "go",
"request": "launch",
"remotePath": "",
"port": 2345,
"host": "127.0.0.1",
"mode": "debug",
"program": "${workspaceRoot}/app/tmp/",
"env": {},
"args": ["-importPath", "<project folder name>", "-srcPath", "C:\\Users\\<username>\\go\\src", "-runMode", "dev"]
}
]
}
Note that -importPath should be the directory (relative to $GOPATH\src where your project lives)
Note that the value for -srcPath should match your $GOPATH\src directory (I'm running on Windows)
Once your launch.json is set up as so, you can start the app in deb mode and put breakpoints wherever you wish.

Related

VScode's debugger not working [MacOS - Clang - C]

My problem is generated when trying to debug C (the programming language) in vscode using the latest MacOS version with command line tools installed.
The error appears when the external terminal is launched in order to debug. I'm using the clang compiler with the following configuration files for the debugger in vscode:
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": "clang - Build and debug active file",
"type": "cppdbg",
"request": "launch",
"program": "${fileDirname}/${fileBasenameNoExtension}",
"args": [],
"stopAtEntry": false,
"cwd": "${fileDirname}",
"environment": [],
"externalConsole": true,
"MIMode": "lldb",
"preLaunchTask": "C/C++: clang build active file"
}
]
}
tasks.json:
{
"tasks": [
{
"label": "Open Terminal",
"type": "shell",
"command": "osascript -e 'tell application \"Terminal\"\ndo script \"echo hello\"\nend tell'",
"problemMatcher": []
},
{
"type": "cppbuild",
"label": "C/C++: clang build active file",
"command": "/usr/bin/clang",
"args": [
"-g",
"${file}",
"-o",
"${fileDirname}/${fileBasenameNoExtension}"
],
"options": {
"cwd": "${fileDirname}"
},
"problemMatcher": ["$gcc"],
"group": {
"kind": "build",
"isDefault": true
},
"detail": "Task generated by Debugger."
}
],
"version": "2.0.0"
}
The error that appears in the terminal:
username#Martins-MBP ~ % cd ''; env 'USER=Martin' '__CFBundleIdentifier=com.microsoft.VSCode' 'COMMAND_MODE=unix2003' 'LOGNAME=Martin' 'PATH=/usr/local/bin:/usr/bin:/bin:/usr/sbin:/sbin' 'SSH_AUTH_SOCK=/private/tmp/com.apple.launchd.ABVM6fu0pS/Listeners' 'SHELL=/bin/zsh' 'HOME=/Users/Martin' '__CF_USER_TEXT_ENCODING=0x1F5:0x0:0x2' 'TMPDIR=/var/folders/zb/b62pl9hd43n4chv3k7jg5cxr0000gn/T/' 'XPC_SERVICE_NAME=application.com.microsoft.VSCode.142509.142515' 'XPC_FLAGS=0x0' 'ORIGINAL_XDG_CURRENT_DESKTOP=undefined' 'SHLVL=0' 'PWD=/' 'OLDPWD=/' '_=/Applications/Visual Studio Code.app/Contents/MacOS/Electron' 'APPLICATION_INSIGHTS_NO_DIAGNOSTIC_CHANNEL=true' '/bin/sh' '/var/folders/zb/b62pl9hd43n4chv3k7jg5cxr0000gn/T/Microsoft-MIEngine-Cmd-ukaihz0n.2gz'

How can I run my debugger commands while the program is running?

I've configured my launch.json & tasks.json then return to my file.c and click the green arrow.
I see 'attached image'. Click OK to allow access then I am left with my Debugger but no variables exist and my options like step_into, step_over disappear then I find myself in the same loop.
Below is the JSON for launch and tasks.
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": "clang - Build and debug active file",
"type": "cppdbg",
"request": "launch",
"program": "${fileDirname}/${fileBasenameNoExtension}",
"args": [],
"stopAtEntry": false,
"cwd": "${workspaceFolder}",
"environment": [],
"externalConsole": false,
"MIMode": "lldb",
"preLaunchTask": "clang build active file"
}
]
}
tasks.json:
{
// See https://go.microsoft.com/fwlink/?LinkId=733558
// for the documentation about the tasks.json format
"version": "2.0.0",
"tasks": [
{
"label": "build",
"type": "shell",
"command": "msbuild",
"args": [
"/property:GenerateFullPaths=true",
"/t:build",
"/consoleloggerparameters:NoSummary"
],
"group": "build",
"presentation": {
"reveal": "silent"
},
"problemMatcher": "$msCompile"
},
{
"type": "shell",
"label": "clang build active file",
"command": "/usr/bin/clang",
"args": [
"-g",
"${file}",
"-o",
"${fileDirname}/${fileBasenameNoExtension}"
],
"options": {
"cwd": "/usr/bin"
},
"problemMatcher": [
"$gcc"
],
"group": "build"
}
]
}
It looks like the code is not "paused", so the debugger will not activate while the code is actively running. Try to set a breakpoint and see if that fixes the issue.

Visual Studio Code debugging - Jest breakpoints not working as expected

Recently I have upgraded to Jest 23.x.x, using the same VSCode debugging configuration as in Jest 22.x.x, I get weird behaviors: breakpoints are moved, and you cannot really debug (not hitting the real line of code). If I downgrade to 22 everything works as expected.
Is there any breaking change or update from 22 to 23 to be aware of for this case?
My vscode debug launch configuration
{
"version": "0.2.0",
"configurations": [
{
"type": "node",
"request": "launch",
"name": "Jest All",
"program": "${workspaceFolder}/node_modules/jest/bin/jest",
"args": [
"--runInBand",
"--no-cache"
],
"console": "integratedTerminal",
"internalConsoleOptions": "neverOpen"
},
{
"type": "node",
"request": "launch",
"name": "Jest Current File",
"program": "${workspaceFolder}/node_modules/jest/bin/jest",
"args": [
"${relativeFile}",
"--runInBand",
"--no-cache"
],
"console": "integratedTerminal",
"internalConsoleOptions": "neverOpen"
},
]
}

SourceMaps.loadSourceMapContents: Could not download sourcemap from https://ajax.googleapis.com/ajax/libs/angularjs/1.4.8/angular.min.js.map

I am trying to debug my web app with vscode and framework angular.js I have downloaded debuging for chrome extentions but when start the program display the follow error on debug console.
SourceMaps.loadSourceMapContents: Could not download sourcemap from https://ajax.googleapis.com/ajax/libs/angularjs/1.4.8/angular.min.js.map
My file launch.json:
{
"version": "0.2.0",
"configurations": [
{
"name": "Launch Chrome against localhost",
"type": "chrome",
"request": "launch",
"url": "http://localhost/index.html",
"webRoot": "${workspaceRoot}"
},
{
"name": "Attach to Chrome",
"type": "chrome",
"request": "attach",
"port": 9222,
"webRoot": "${workspaceRoot}"
}
]
}
My html code where call angular.min-js:
<head>
<script src="https://ajax.googleapis.com/ajax/libs/angularjs/1.4.8/angular.min.js"></script>
<script src="../js/todo.js"></script>
<link rel="stylesheet" href="../css/todo.css">
</head>
The web app is in IIS localhost. Do you have any suggestions to solve this? or another method to debug angular app and build web app.
I have solved this problem with follow steps:
download source from https://angularjs.org/
reference the source as a file src="../js/angular.min.js"
Modify "webRoot" in launch.json. add /JS/ here is where stored javascripts file.
launch.json
{
"version": "0.2.0",
"configurations": [
{
"name": "Launch Chrome against localhost",
"type": "chrome",
"request": "launch",
"url": "http://localhost/index.html",
"webRoot": "${workspaceRoot}/JS/"
,"diagnosticLogging": true,
"sourceMaps": true
},
{
"name": "Attach to Chrome",
"type": "chrome",
"request": "attach",
"port": 9222,
"webRoot": "${workspaceRoot}/JS/",
"sourceMaps": true
}
]
}

localhost not working - chrome extension in vs code

In vs code, I have created a launch.json file in an HTML angularjs project. I am not able to launch the project in my localhost. It keeps on saying as Failed to load resource: net::ERR_CONNECTION_REFUSED (http://localhost:8080/).
Project Structure:-
Project => .vscode => launch.json
=> app
=> scripts
=> styles
=> index.html
launch.json:-
{
"version": "0.2.0",
"configurations": [
{
"name": "Launch Chrome against localhost, with sourcemaps",
"type": "chrome",
"request": "launch",
"url": "http://localhost:8080",
"sourceMaps": true,
"webRoot": "${workspaceRoot}"
},
{
"name": "Attach to Chrome, with sourcemaps",
"type": "chrome",
"request": "attach",
"port": 9222,
"sourceMaps": true,
"webRoot": "${workspaceRoot}"
}
]
}
Can someone help me to solve this? Thanks in advance
I was experiencing the same issue.
Changing my launch.json file to the following solved the issue (Chrome is my default browser):
{
// 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": [
{
"type": "pwa-node",
"request": "launch",
"name": "Launch Program",
"skipFiles": [
"<node_internals>/**"
],
"program": "${workspaceFolder}\\app.js"
}
]
}
Where app.js was in my root folder of the workspace.
Here's what was the preivous launch.json file:
{
// 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": [
{
"type": "pwa-chrome",
"request": "launch",
"name": "Launch Chrome against localhost",
"url": "http://localhost:8080",
"webRoot": "${workspaceFolder}"
}
]
}
Edit the launch.json file inside the .vs code folder, delete the last three lines in the configuration (name, url, webroot).
Before Editing launch.json file
{
// 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": [
{
"type": "pwa-chrome",
"request": "launch",
"name": "sample1",
"url": "http://localhost:8080",
"webRoot": "${workspaceFolder}"
}
]
}
After Editing launch.json file
{
// 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": [
{
"type": "pwa-chrome",
"request": "launch",
}
]
}
If above the answer did not work just delete the launch.json file in the .vs code Folder.
both worked for me.
Just Change your setting put all in your launch.json
{
"version": "0.2.0",
"configurations": [
{
"name": "Launch Chrome against localhost",
"type": "chrome",
"request": "launch",
"url": "http://localhost:4200",
"webRoot": "${workspaceRoot}"
},
{
"name": "Attach to Chrome",
"type": "chrome",
"request": "attach",
"port": 4200,
"webRoot": "${workspaceRoot}"
}
]
}
Have you tried removing the URL line? Here it is below:
{
"version": "0.2.0",
"configurations": [
{
"name": "Launch Chrome against localhost, with sourcemaps",
"type": "chrome",
"request": "launch",
// "url": "http://localhost:8080", remove this line?
"sourceMaps": true,
"webRoot": "${workspaceRoot}"
},
{
"name": "Attach to Chrome, with sourcemaps",
"type": "chrome",
"request": "attach",
"port": 9222,
"sourceMaps": true,
"webRoot": "${workspaceRoot}"
}
] }
I also
Installed Node JS on my computer (Download link -- https://nodejs.org/)
On Visual Studio, enter (Ctrl + Shift + X) and search 'Live Server'
Install 'Live Server' by Ritwick Dey, close and reopen Visual Studio

Resources