defaultgenerator.go 513 B

123456789101112131415161718192021222324252627282930313233
  1. package generator
  2. import (
  3. "os/exec"
  4. "github.com/tal-tech/go-zero/tools/goctl/util/console"
  5. )
  6. type defaultGenerator struct {
  7. log console.Console
  8. }
  9. func NewDefaultGenerator() *defaultGenerator {
  10. log := console.NewColorConsole()
  11. return &defaultGenerator{
  12. log: log,
  13. }
  14. }
  15. func (g *defaultGenerator) Prepare() error {
  16. _, err := exec.LookPath("go")
  17. if err != nil {
  18. return err
  19. }
  20. _, err = exec.LookPath("protoc")
  21. if err != nil {
  22. return err
  23. }
  24. _, err = exec.LookPath("protoc-gen-go")
  25. return err
  26. }