summaryrefslogtreecommitdiff
path: root/doProto.go
diff options
context:
space:
mode:
Diffstat (limited to 'doProto.go')
-rw-r--r--doProto.go29
1 files changed, 24 insertions, 5 deletions
diff --git a/doProto.go b/doProto.go
index 579865c..4be9c1d 100644
--- a/doProto.go
+++ b/doProto.go
@@ -26,7 +26,7 @@ import (
"go.wit.com/log"
)
-func doProto(argvProto string) error {
+func doProto(argvProto string) (string, error) {
pf := new(File)
me.pb.Files = append(me.pb.Files, pf)
pf.Filename = argvProto
@@ -196,8 +196,27 @@ func doProto(argvProto string) error {
badExit(err)
}
}
- log.Info("")
- log.Info("you may have to run 'goimport -w *.go' on the new *pb.go files")
- log.Info("")
- return nil
+ var err error
+ if err == nil {
+ // run goimports to clean the autogenpb files up
+ globPattern := pf.Filebase + "*.pb.go"
+ var files []string
+ files, err = filepath.Glob(globPattern)
+ if err != nil {
+ log.Info("glob error", err, files)
+ }
+ if len(files) == 0 {
+ // something went wrong
+ err = errors.New("autogenpb failed to create *.pb.go files")
+ } else {
+ cmd := []string{"goimports", "-w"}
+ cmd = append(cmd, files...)
+ log.Info("Running:", cmd)
+ shell.RunVerbose(cmd)
+ }
+ }
+ if err == nil {
+ return "autogenpb worked", nil
+ }
+ return "autogenpb failed", err
}