Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/eze-kiel/dbg
Golang embeddable debugger
https://github.com/eze-kiel/dbg
Last synced: 4 days ago
JSON representation
Golang embeddable debugger
- Host: GitHub
- URL: https://github.com/eze-kiel/dbg
- Owner: eze-kiel
- Created: 2021-02-16T16:57:26.000Z (over 3 years ago)
- Default Branch: main
- Last Pushed: 2021-02-16T17:42:55.000Z (over 3 years ago)
- Last Synced: 2024-06-20T08:16:17.598Z (5 months ago)
- Language: Go
- Size: 59.6 KB
- Stars: 1
- Watchers: 2
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
Awesome Lists containing this project
README
# dbg
Lightweight and easy-to-use embeddable debugger for Go.
`dbg` provides basic informations such as the position in the program, the caller function, the memory usage etc. with a colored output.
![Sample](img/example.png)
## Getting started
```
$ go get github.com/eze-kiel/dbg
```## Usage
### Display infos at a given position
Adding `dbg.Point()` somewhere in your program will display some informations about the place:
Example
```go
func main() {
dbg.Point()
}
```Output:
```
(pkg:main|func:main) main.go:6
```You can also give arguments to `Point()`, for example to display the content of an object. Its type will be shown next to its value.
Example
```go
func main() {
myvar := 1337
dbg.Point(myvar)
}
```Output:
```
(pkg:main|func:main) main.go:7 1337 (int)
```Another function, `dbg.Printf()` emulates the behavior of `fmt.Printf` but adds the debugger prefix:
Example
```go
func main() {
name := "General Kenobi"
dbg.Printf("hello there, %s\n", name)
}
```Output:
```
(pkg:main|func:main) main.go:7 hello there, General Kenobi
```### Display memory stats
`dbg.Mem()` allows you to see some memory informations. Its does not require any parameter.
### Stop program execution
`dbg.Halt(code int)` allows you to stop the program execution with a given error code.