-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #2 from edwarnicke/README.md
Adding README
- Loading branch information
Showing
1 changed file
with
40 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,40 @@ | ||
debug is a simple library for Go that allows you to optionally debug your executable based on env variables. | ||
|
||
# Usage | ||
|
||
Simply add debug.Self() to your main function as shown below: | ||
|
||
``` | ||
import ( | ||
"github.com/edwarnicke/debug" | ||
) | ||
func main() { | ||
if err := debug.Self(); err != nil { | ||
log.Infof("%s", err) | ||
} | ||
... | ||
} | ||
``` | ||
|
||
will cause your application to log out: | ||
|
||
``` | ||
Setting env variable DLV_LISTEN_{{executable name}} to a valid dlv '--listen' value will cause the dlv debugger to execute this binary and listen as directed. | ||
``` | ||
|
||
thus informing you of what env variable to set to a valid dlv listener value to trigger debugging. | ||
|
||
So if your application where named 'forwarder', you'd see: | ||
|
||
``` | ||
Setting env variable DLV_LISTEN_FORWARDER to a valid dlv '--listen' value will cause the dlv debugger to execute this binary and listen as directed. | ||
``` | ||
|
||
and setting the env variable: | ||
|
||
``` | ||
export DLV_LISTEN_FORWARDER=:50000 | ||
``` | ||
|
||
would cause your applicaton to exec itself over with dlv with arguments to run the application itself. |