diff options
| author | Jeff Carr <[email protected]> | 2025-08-16 00:36:47 -0500 |
|---|---|---|
| committer | Jeff Carr <[email protected]> | 2025-08-16 00:36:47 -0500 |
| commit | de6b45ced2fec64bdd4eb1c7d90c13251d394fe8 (patch) | |
| tree | d5c4b08c74b4c3b3df544d0585a4cc0cea2878a1 /main.go | |
day1v0.0.1
Diffstat (limited to 'main.go')
| -rw-r--r-- | main.go | 96 |
1 files changed, 96 insertions, 0 deletions
@@ -0,0 +1,96 @@ +// Copyright 2017-2025 WIT.COM Inc. All rights reserved. +// Use of this source code is governed by the GPL 3.0 + +package main + +import ( + "debug/buildinfo" + "fmt" + "os" + "path/filepath" + "unicode" + + "go.wit.com/dev/alexflint/arg" + "go.wit.com/log" +) + +// sent via -ldflags +var VERSION string +var BUILDTIME string + +func main() { + me = new(autoType) + me.argpp = arg.MustParse(&argv) + + if argv.Bash { + argv.doBash() + os.Exit(0) + } + if len(argv.BashAuto) != 0 { + argv.doBashAuto() + os.Exit(0) + } + + if argv.Drives != nil { + doDrives() + doDrives2() + } + + listenForBlockEvents() + okExit("everything compiled") +} + +func doFixup() { + okExit("list drives") +} + +// this is dumb. sync this with go-deb +func trimNonNumericFromStart(s string) string { + for i, r := range s { + if unicode.IsDigit(r) { + return s[i:] + } + } + return "" +} + +func okExit(thing string) { + if thing != "" { + log.Info(thing, "ok") + } + // log.Info("Finished go-clean on", check.GetGoPath(), "ok") + os.Exit(0) +} + +func badExit(err error) { + log.Info("go-clean failed: ", err) + os.Exit(-1) +} + +func dumpDebug() { + // Get absolute path of the currently running binary + exePath, err := os.Executable() + if err != nil { + fmt.Println("Error getting executable path:", err) + return + } + + // Resolve symlinks if necessary + exePath, err = filepath.EvalSymlinks(exePath) + if err != nil { + fmt.Println("Error resolving symlink:", err) + return + } + + // Read build info + bi, err := buildinfo.ReadFile(exePath) + if err != nil { + fmt.Println("Error reading build info:", err) + return + } + + fmt.Println("Go Version:", bi.GoVersion) + for _, dep := range bi.Deps { + fmt.Printf("Dependency: %s %s\n", dep.Path, dep.Version) + } +} |
