fix path. add notes to help install protoc
This commit is contained in:
parent
84c25d74da
commit
6bb2b972b4
5
main.go
5
main.go
|
@ -6,6 +6,7 @@ package main
|
||||||
import (
|
import (
|
||||||
"errors"
|
"errors"
|
||||||
"os"
|
"os"
|
||||||
|
"path/filepath"
|
||||||
"strings"
|
"strings"
|
||||||
|
|
||||||
"github.com/alexflint/go-arg"
|
"github.com/alexflint/go-arg"
|
||||||
|
@ -51,8 +52,10 @@ func main() {
|
||||||
os.Exit(-1)
|
os.Exit(-1)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// todo, look for go.work files
|
||||||
if argv.GoSrc == "" {
|
if argv.GoSrc == "" {
|
||||||
argv.GoSrc = "/home/jcarr/go/src"
|
homeDir, _ := os.UserHomeDir()
|
||||||
|
argv.GoSrc = filepath.Join(homeDir, "go/src")
|
||||||
}
|
}
|
||||||
|
|
||||||
if argv.GoPath == "" {
|
if argv.GoPath == "" {
|
||||||
|
|
31
protoc.go
31
protoc.go
|
@ -4,10 +4,12 @@ package main
|
||||||
|
|
||||||
import (
|
import (
|
||||||
"errors"
|
"errors"
|
||||||
|
"fmt"
|
||||||
"os"
|
"os"
|
||||||
"path/filepath"
|
"path/filepath"
|
||||||
"strings"
|
"strings"
|
||||||
|
|
||||||
|
"github.com/go-cmd/cmd"
|
||||||
"go.wit.com/lib/gui/shell"
|
"go.wit.com/lib/gui/shell"
|
||||||
"go.wit.com/log"
|
"go.wit.com/log"
|
||||||
)
|
)
|
||||||
|
@ -88,6 +90,33 @@ func protocBuild(names map[string]string) error {
|
||||||
for i, s := range cmd {
|
for i, s := range cmd {
|
||||||
log.Info("\t", i, s)
|
log.Info("\t", i, s)
|
||||||
}
|
}
|
||||||
shell.PathRun(argv.GoSrc, cmd)
|
return runprotoc(argv.GoSrc, cmd)
|
||||||
|
}
|
||||||
|
|
||||||
|
func runprotoc(pwd string, mycmd []string) error {
|
||||||
|
result := shell.PathRun(argv.GoSrc, mycmd)
|
||||||
|
if result.Error != nil {
|
||||||
|
return userNotes(result)
|
||||||
|
}
|
||||||
|
if result.Exit != 0 {
|
||||||
|
return userNotes(result)
|
||||||
|
}
|
||||||
return nil
|
return nil
|
||||||
}
|
}
|
||||||
|
|
||||||
|
func userNotes(result cmd.Status) error {
|
||||||
|
log.Info("protoc failed", result.Cmd, "with", result.Exit)
|
||||||
|
for _, line := range result.Stdout {
|
||||||
|
log.Info("STDOUT:", line)
|
||||||
|
}
|
||||||
|
for _, line := range result.Stderr {
|
||||||
|
log.Info("STDERR:", line)
|
||||||
|
}
|
||||||
|
log.Info("This is likely because you don't have protoc and protoc-gen-go installed")
|
||||||
|
log.Info("")
|
||||||
|
log.Info("On debian, you can:")
|
||||||
|
log.Info(" apt install protobuf-compiler # for protoc")
|
||||||
|
log.Info(" apt install protoc-gen-go # for protoc-gen-go")
|
||||||
|
log.Info("")
|
||||||
|
return fmt.Errorf("protoc failed with %d %v", result.Exit, result.Error)
|
||||||
|
}
|
||||||
|
|
Loading…
Reference in New Issue