// Copyright 2017-2025 WIT.COM Inc. All rights reserved. // Use of this source code is governed by the GPL 3.0 // protobuf the way I am using them, require GO 1.20. I think. I could be wrong. // The Go Protocol Buffers library embeds a sync.Mutex within the MessageState struct to prevent unintended shallow copies of message structs // this optionally (but it is the default) inserts a mutex into the struct generated by protoc // probably don't need these build lines anymore //go:build go1.20 // +build go1.20 // go:generate autogenpb --proto file.proto package main import ( "os" "strings" "go.wit.com/lib/fhelp" "go.wit.com/lib/gui/prep" "go.wit.com/lib/gui/shell" "go.wit.com/log" ) // sent via -ldflags var VERSION string var BUILDTIME string var ARGNAME string = "autogenpb" func main() { me = new(mainType) me.sh = prep.Autocomplete(&argv) // adds shell auto complete to go-args me.pb = new(Files) if argv.Identify != "" { if err := doIdentify(argv.Identify); err != nil { badExit(err) } okExit("") } // you need a proto file if argv.Proto == "" { log.Info("you must provide --proto ") me.sh.WriteHelp() os.Exit(-1) } if !shell.Exists(argv.Proto) { log.Info("protobuf", argv.Proto, "is missing") os.Exit(-1) } if !strings.HasSuffix(argv.Proto, ".proto") { log.Info("protobuf", argv.Proto, "must end in .proto") os.Exit(-1) } if path, err := fhelp.CheckCmd("goimports"); err != nil { log.Info("this tool requires goimports") if path != "" { log.Info("path might be:", path) } log.Info("this tool requires goimports") cmd := []string{"go", "install", "-v", "-x", "golang.org/x/tools/cmd/goimports@latest"} log.Info("Need to run:", cmd) if fhelp.QuestionUser("build goimports?") { shell.RunRealtime(cmd) } else { os.Exit(-1) } } doProto(argv.Proto) } func okExit(s string) { log.Info("autogenpb ok", s) os.Exit(0) } func badExit(err error) { log.Info("autogenpb error:", err) os.Exit(-1) }