Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/sanposhiho/easydebug
Go: add debug statements after store values 📝
https://github.com/sanposhiho/easydebug
golang tool
Last synced: 3 months ago
JSON representation
Go: add debug statements after store values 📝
- Host: GitHub
- URL: https://github.com/sanposhiho/easydebug
- Owner: sanposhiho
- License: mit
- Created: 2020-09-03T11:12:15.000Z (over 4 years ago)
- Default Branch: master
- Last Pushed: 2020-09-05T07:34:55.000Z (over 4 years ago)
- Last Synced: 2024-06-20T08:01:24.436Z (8 months ago)
- Topics: golang, tool
- Language: Go
- Homepage:
- Size: 9.77 KB
- Stars: 16
- Watchers: 2
- Forks: 1
- Open Issues: 4
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
README
# easydebug
tool: add debug statements after statements to store values- You can add debug statements after all statements to store values.
- You can remove all debug statements with this tool, of course.
- You can edit debug function `dmp` to arrange debug as you like## Installation
```
go get -u github.com/sanposhiho/easydebug
```## Usage
### add debug statements
```
easydebug -f target.go -mode 0
```### remove debug statements
```
easydebug -f target.go -mode 1
```## sample
### before
```
package mainfunc test() int {
hoge := 1fuga := 3
if hoge == 2 {
fuga = abusoluteTwo()hoge = 12
}
return hoge + fuga
}func abusoluteTwo() int {
return 2
}
```### after
```
package mainfunc test() int {
hoge := 1
dmp("hoge", hoge)fuga := 3
dmp("fuga", fuga)if hoge == 2 {
fuga = abusoluteTwo()
dmp("fuga", fuga)hoge = 12
dmp("hoge", hoge)}
return hoge + fuga
}func abusoluteTwo() int {
return 2
}// generated from goeasydebug
// function for data dump
func dmp(valueName string, v ...interface{}) {
for _, vv := range(v) {
// arrange debug as you like
fmt.Printf("%s: %#v\n",valueName, vv)
}
}
```