summaryrefslogtreecommitdiff
path: root/main.go
diff options
context:
space:
mode:
Diffstat (limited to 'main.go')
-rw-r--r--main.go31
1 files changed, 20 insertions, 11 deletions
diff --git a/main.go b/main.go
index ed17b91..edbd627 100644
--- a/main.go
+++ b/main.go
@@ -1,9 +1,9 @@
//go:build go1.20
+// +build go1.20
+
// Copyright 2017-2025 WIT.COM Inc. All rights reserved.
// Use of this source code is governed by the GPL 3.0
-// +build go1.20
-
// 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
@@ -21,6 +21,7 @@ import (
"github.com/alexflint/go-arg"
"github.com/go-cmd/cmd"
+ "go.wit.com/lib/fhelp"
"go.wit.com/lib/gui/shell"
"go.wit.com/log"
)
@@ -102,16 +103,15 @@ func main() {
argv.GoSrc = filepath.Join(homeDir, "go/src")
}
+ var startpwd string
+ startpwd, _ = os.Getwd()
+ log.Info("start pwd = ", startpwd)
if argv.GoPath == "" {
- pwd, _ := os.Getwd()
- argv.GoPath = strings.TrimPrefix(pwd, argv.GoSrc)
+ argv.GoPath = strings.TrimPrefix(startpwd, argv.GoSrc)
argv.GoPath = strings.Trim(argv.GoPath, "/")
}
log.Info(argv.GoSrc, argv.GoPath)
- pwd, _ := os.Getwd()
- log.Info("pwd = ", pwd)
-
if !shell.Exists("go.sum") {
shell.RunQuiet([]string{"go-mod-clean"})
if !shell.Exists("go.sum") {
@@ -145,20 +145,29 @@ func main() {
// try to make foo.pb.go with protoc if it's not here
// this is helpful because the protoc-gen-go lines
// are also annoying to code by hand
- checkCmd("protoc")
- checkCmd("protoc-gen-go")
+ // checkCmd("protoc")
+ // checkCmd("protoc-gen-go")
+
+ if !fhelp.CheckProtoc() {
+ badExit(fmt.Errorf("you do not have 'protoc' installed"))
+ }
pf.Pbfilename = pf.Filebase + ".pb.go"
// try to create the foo.pb.go file using protoc if it is not there
if !shell.Exists(pf.Pbfilename) {
- checkCmd("protoc")
- checkCmd("protoc-gen-go")
+ if !fhelp.CheckProtoc() {
+ badExit(fmt.Errorf("you do not have 'protoc' installed"))
+ }
+
+ // checkCmd("protoc")
+ // checkCmd("protoc-gen-go")
if err := pb.protocBuild(pf); err != nil {
badExit(err)
}
}
+ os.Chdir(startpwd)
// try to add the Mutex to the pb.go file
if err := pb.addMutex(pf); err != nil {