https://github.com/aletheia7/gstack
Go package used to easily find calling function, file name, and line number in go code
https://github.com/aletheia7/gstack
Last synced: 5 months ago
JSON representation
Go package used to easily find calling function, file name, and line number in go code
- Host: GitHub
- URL: https://github.com/aletheia7/gstack
- Owner: aletheia7
- License: bsd-2-clause
- Created: 2014-08-16T05:24:57.000Z (over 11 years ago)
- Default Branch: master
- Last Pushed: 2016-09-20T05:51:34.000Z (over 9 years ago)
- Last Synced: 2025-05-13T15:15:55.350Z (8 months ago)
- Language: Go
- Homepage:
- Size: 34.2 KB
- Stars: 2
- Watchers: 2
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
README
[](https://godoc.org/github.com/aletheia7/gstack)
#### gstack
gstack provides methods to easily obtain the function name, file path, and line number of go code.
gstack answers the questions: What function am I in? What is the full path to the file? What is the line number?
#### Install
```bash
go get github.com/aletheia7/gstack
cd
go test -v
```
#### Example
```go
package main
import (
"fmt"
"gstack"
)
func main() {
buried()
}
func buried() {
lost()
}
func lost() {
stack1 := gstack.New() // Index: 2
fmt.Println(stack1)
stack2 := gstack.New_index(3) // Index: 3
fmt.Println(stack2)
stack3 := gstack.New_index(4) // Index: 4
fmt.Println(stack3)
}
```
##### Ouput
```bash
Index: 2, Function: main.lost, File: //src/t/t.go, Line: 19
Index: 3, Function: main.buried, File: //src/t/t.go, Line: 14
Index: 4, Function: main.main, File: //src/t/t.go, Line: 9
```
#### License
Use of this source code is governed by a BSD-2-Clause license that can be found
in the LICENSE file.
[](https://opensource.org/)