You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
455e1a9 snippets: add snippet for TestMain
bf1225f src/goEnv: unset GOOS/GOARCH/GOROOT/... from tool installation env
d7563f6 src/goInstallTools: use GOROOT/bin for gocode-gomod build too
3493cfe src/goDebug: respect user cwd debug configuration in noDebug
ec9a5f8 src/goDebugConfiguration: remove user set '--gcflags' from config
3c7e4da package.json: add missing transform variants for go.addTags
c13bcfe src/testUtils: fix test streaming output handling
2c5a0b9 src/testUtils: hide running test StatusBarItem after cancelling tests
a4e523d src/testUtils: convert a goTest promise chain to async-await
Change-Id: I5bcbf26cf7119e02f23e72937e73dc647f392ddd
Copy file name to clipboardExpand all lines: docs/debugging.md
+17Lines changed: 17 additions & 0 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -9,6 +9,7 @@ This document explains how to debug your Go programs in VS Code. The Go debugger
9
9
*[Configuration](#configuration)
10
10
*[Launch Configurations](#launch-configurations)
11
11
*[Specifying build tags](#specifying-build-tags)
12
+
*[Specifying other build flags](#specifying-other-build-flags)
12
13
*[Using VS Code Variables](#using-vs-code-variables)
13
14
*[Snippets](#snippets)
14
15
*[Debugging on Windows Subsystem for Linux (WSL)](#debugging-on-windows-subsystem-for-linux-wsl)
@@ -135,6 +136,22 @@ in your launch configuration. This property supports multiple tags, which you ca
135
136
136
137
<!--TODO(rstambler): Confirm that the extension works with a comma (not space) separated list.-->
137
138
139
+
### Specifying other build flags
140
+
141
+
The flags specified in `buildFlags` and `env.GOFLAGS` are passed to the Go compiler when building your program for debugging. Delve adds `--gcflags='all=-N -l'` to the list of build flags to disable optimizations. User specified buildFlags conflict with this setting, so the extension removes them ([Issue #117](https://github.com/golang/vscode-go/issues/117)). If you wish to debug a program using custom `--gcflags`, build the program using `go build` and launch using `exec` mode:
142
+
143
+
```json
144
+
{
145
+
"name": "Launch executable",
146
+
"type": "go",
147
+
"request": "launch",
148
+
"mode": "exec",
149
+
"program": "/absolute/path/to/executable"
150
+
}
151
+
```
152
+
153
+
Note that it is not recommended to debug optimized executables as Delve may not have the information necessary to properly debug your program.
154
+
138
155
### Using [VS Code variables]
139
156
140
157
Any property in the launch configuration that requires a file path can be specified in terms of [VS Code variables]. Here are some useful ones to know:
`User specified build flag '--gcflags' in 'buildFlags' is being ignored (see [debugging with build flags](https://github.com/golang/vscode-go/blob/master/docs/debugging.md#specifying-other-build-flags) documentation)`
`User specified build flag '--gcflags' in 'GOFLAGS' is being ignored (see [debugging with build flags](https://github.com/golang/vscode-go/blob/master/docs/debugging.md#specifying-other-build-flags) documentation)`
0 commit comments