From 66694c1a09ff2522e553d37eeb025b183dea551d Mon Sep 17 00:00:00 2001 From: Jeff Carr Date: Mon, 12 Feb 2024 08:27:39 -0600 Subject: [PATCH] make a simple way to enable the debugger Signed-off-by: Jeff Carr --- Makefile | 11 ++++++----- debugger.go | 26 ++++++++++++++++++++++++++ main.go | 4 ++-- 3 files changed, 34 insertions(+), 7 deletions(-) create mode 100644 debugger.go diff --git a/Makefile b/Makefile index 879facc..af5ce76 100644 --- a/Makefile +++ b/Makefile @@ -1,11 +1,12 @@ all: - go build -v -x + GO111MODULE=off go build -v -x ./helloworld -push: - git add --all - git commit -a - git push +gocui: + ./helloworld --gui gocui >/tmp/helloworld.stdout 2>&1 + +goimports: + goimports -w *.go redomod: rm -f go.* diff --git a/debugger.go b/debugger.go new file mode 100644 index 0000000..116d549 --- /dev/null +++ b/debugger.go @@ -0,0 +1,26 @@ +package main + +/* + enables GUI options and the debugger in your application +*/ + +import ( + "go.wit.com/dev/alexflint/arg" + "go.wit.com/lib/debugger" + "go.wit.com/log" +) + +var args struct { +} + +func init() { + arg.MustParse(&args) + + if debugger.ArgDebug() { + log.Info("cmd line --debugger == true") + go func() { + log.Sleep(2) + debugger.DebugWindow() + }() + } +} diff --git a/main.go b/main.go index 04fa688..4d63459 100644 --- a/main.go +++ b/main.go @@ -15,6 +15,7 @@ func main() { helloworld() // go will sit here until the window exits + // intermittently, it will show toolkit statistics gui.Watchdog() } @@ -43,11 +44,10 @@ func helloworld() { color.AddText("Cyan") color.AddText("Magenta") color.AddText("Yellow") - color.Custom = func () { + color.Custom = func() { log.Info("color is now", color.String()) } - check := grid.NewCheckbox("Checkers").SetProgName("CHECKERS") check.Custom = func() { log.Info("Checkers is now", check.Bool())