fix: create file when proto file not exist
This commit is contained in:
parent
c3800bcf99
commit
c57b75721e
@ -1,6 +1,7 @@
|
|||||||
package bootstrap
|
package bootstrap
|
||||||
|
|
||||||
import (
|
import (
|
||||||
|
"errors"
|
||||||
"os"
|
"os"
|
||||||
|
|
||||||
"github.com/sirupsen/logrus"
|
"github.com/sirupsen/logrus"
|
||||||
@ -57,9 +58,17 @@ func AddServiceCommand() *cobra.Command {
|
|||||||
|
|
||||||
buf, err := gobuf.NewParser(pbPath)
|
buf, err := gobuf.NewParser(pbPath)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
logrus.Errorf("read proto file failed: %v", err)
|
if !errors.Is(err, os.ErrNotExist) {
|
||||||
return
|
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) {
|
if buf.ExistService(svcName) {
|
||||||
logrus.Errorf("router group name exist")
|
logrus.Errorf("router group name exist")
|
||||||
return
|
return
|
||||||
|
2
go.mod
2
go.mod
@ -6,7 +6,7 @@ require (
|
|||||||
code.gitea.io/sdk/gitea v0.17.1
|
code.gitea.io/sdk/gitea v0.17.1
|
||||||
github.com/sirupsen/logrus v1.9.3
|
github.com/sirupsen/logrus v1.9.3
|
||||||
github.com/spf13/cobra v1.8.0
|
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
|
gopkg.in/yaml.v3 v3.0.1
|
||||||
)
|
)
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user