Skip to content

Commit

Permalink
Get log from binary path.
Browse files Browse the repository at this point in the history
  • Loading branch information
mikemadden42 committed Nov 2, 2023
1 parent 774a4a4 commit 6703d29
Showing 1 changed file with 4 additions and 1 deletion.
5 changes: 4 additions & 1 deletion main.go
Original file line number Diff line number Diff line change
Expand Up @@ -7,14 +7,17 @@ import (
"fmt"
"log"
"os"
"path/filepath"
)

// Based on the example program found here:
// https://www.jvt.me/posts/2023/05/15/go-parse-binary-architecture/
// Docs for debug package can be found here:
// https://pkg.go.dev/debug
func main() {
file, err := os.OpenFile("gofile.log", os.O_APPEND|os.O_CREATE|os.O_WRONLY, 0600)
fullBinary, _ := os.Executable()
baseBinary := filepath.Base(fullBinary)
file, err := os.OpenFile(baseBinary+".log", os.O_APPEND|os.O_CREATE|os.O_WRONLY, 0600)
if err != nil {
log.Fatal(err)
}
Expand Down

0 comments on commit 6703d29

Please sign in to comment.