-
install macos Developer tools in macos
-
install VS Code
-
install Go Developer tools and go langauge extension for VS Code
-
install Go SDK
-
install Delve
-
setup GOPATH environment var, ensure delve binary is added in the GOPATH
-
add the soruce code and under .vscode add launch.json and tasks.json
-
tasks.json is required for running delve as a seprate process which can be used to provde stdin inputs for the program getting debugged
-
launch.json is required to invoke the go binary
-
remove both json files if your code is not expecting any user input. just run debug and dlv will run the debug sessions. these both json files are ONLY needed if you want to capture any user input as part of the debug session
-
run go mod init
-
run go build
-
run command+shift+B for running the task.json to run the dlv debugger. if this is not working for some reason, then copy the command and run it in the terminal manually. and then run the debugger using Run option -> Start Debuggings
-
when you hit the scanf in the source code, go to the delve debugger and give the input. To exit the code loop, run ctrl+D EOF which exits the scanf loop
-
If the 'F11' function key resolves to Desktop view, then Go to 'System preferences' --> Keyboard --> shortcuts --> untick 'Show Desktop'. to redefine Function keys use the keyboard menu and tick 'Use F1, F2 etc' option
VS Code installation link: https://code.visualstudio.com/docs/setup/mac
installing macos tools which is a prereq for installing gosdk and delve binaries: https://apple.stackexchange.com/questions/254380/why-am-i-getting-an-invalid-active-developer-path-when-attempting-to-use-git-a -
install delve binary for macos https://github.com/go-delve/delve/blob/master/Documentation/installation/README.md
Go Download link https://golang.org/dl/
setting up envs in macos https://medium.com/@himanshuagarwal1395/setting-up-environment-variables-in-macos-sierra-f5978369b255
setting up envs for zsh in macos https://apple.stackexchange.com/questions/356441/how-to-add-permanent-environment-variable-in-zsh
setting up delve debugger for getting stdin https://stackoverflow.com/questions/50884981/how-to-read-input-when-debugging-go-in-visual-studio-code