diff --git a/create_api.go b/create_api.go index 55fee05..409a720 100644 --- a/create_api.go +++ b/create_api.go @@ -1,6 +1,7 @@ package bootstrap import ( + "errors" "os" "github.com/sirupsen/logrus" @@ -57,9 +58,17 @@ func AddServiceCommand() *cobra.Command { buf, err := gobuf.NewParser(pbPath) if err != nil { - logrus.Errorf("read proto file failed: %v", err) - return + if !errors.Is(err, os.ErrNotExist) { + logrus.Errorf("read proto file failed: %v", err) + return + } + err := buf.CreateFile(pbPath) + if err != nil { + logrus.Errorf("read proto file failed (when create new file): %v", err) + return + } } + if buf.ExistService(svcName) { logrus.Errorf("router group name exist") return diff --git a/go.mod b/go.mod index 5b3525f..c6d026d 100644 --- a/go.mod +++ b/go.mod @@ -6,7 +6,7 @@ require ( code.gitea.io/sdk/gitea v0.17.1 github.com/sirupsen/logrus v1.9.3 github.com/spf13/cobra v1.8.0 - gitter.top/common/gobuf v0.0.2 + gitter.top/common/gobuf v0.0.3 gopkg.in/yaml.v3 v3.0.1 )