repositorypackage
0.0.0-20240410074430-d06bcffd9018
Repository: https://github.com/emad-elsaid/examine.git
Documentation: pkg.go.dev
# README
Examine
A drop-in Go package to trace your program automatically.
[!CAUTION] Examine is still in very early development
Problem
- When working on a project I would like to trace execution especially for network requests (incoming and outgoing)
- The way to do it is either change the code to log these requests or add breakpoints and attach a debugger
- I would like to Do 1 without doing 2. I would like to just import a package that traces the program network requests
How to use
- Import Examine to your program with
import _ "github.com/emad-elsaid/examine"
- Build and run your program
go build ./cmd/path/to/cmd && ./cmd-name
- Examine prints traces of your network requests (this can change during development)
- As Examine pauses programs it will affect performance. and shouldn't be used in production for any case
How it works
- Examine forks your program
- Attaches Delve debugger to your program
- Adds breakpoints to Go standard library
- Whenever a breakpoint is hit. it'll store relevant information and print them and continue
Known issues
Can't print any variables if the program ran with go run
Turns out go run
doesn't include DWARF debugging information. so you have to go build
then run the program
Couldn't attach to PID
If you get this message:
ERROR Could not attach to pid 10042: this could be caused by a kernel security setting, try writing "0" to /proc/sys/kernel/yama/ptrace_scope
You need to turn on ptrace_scope
in your kernel by
sudo su
echo "0" > /proc/sys/kernel/yama/ptrace_scope