quickly generating rpc demo service (#60)

* add execute files

* add protoc-osx

* add rpc generation

* add rpc generation

* add: rpc template generation

* add README.md

* format error

* reactor templatex.go

* update project.go & README.md

* add: quickly generate rpc service
This commit is contained in:
Keson
2020-09-11 15:26:55 +08:00
committed by GitHub
parent 0d151c17f8
commit 17e6cfb7a9
10 changed files with 277 additions and 100 deletions

View File

@@ -24,7 +24,9 @@ type (
Path string // Project path name
Name string // Project name
Package string // The service related package
GoMod GoMod
// true-> project in go path or project init with go mod,or else->false
IsInGoEnv bool
GoMod GoMod
}
GoMod struct {
@@ -75,6 +77,7 @@ func Prepare(projectDir string, checkGrpcEnv bool) (*Project, error) {
goPath = strings.TrimSpace(ret)
src := filepath.Join(goPath, "src")
var isInGoEnv = true
if len(goMod) > 0 {
path = filepath.Dir(goMod)
name = filepath.Base(path)
@@ -103,6 +106,7 @@ func Prepare(projectDir string, checkGrpcEnv bool) (*Project, error) {
name = filepath.Clean(filepath.Base(absPath))
path = projectDir
pkg = name
isInGoEnv = false
} else {
r := strings.TrimPrefix(pwd, src+string(filepath.Separator))
name = filepath.Dir(r)
@@ -116,9 +120,10 @@ func Prepare(projectDir string, checkGrpcEnv bool) (*Project, error) {
}
return &Project{
Name: name,
Path: path,
Package: pkg,
Name: name,
Path: path,
Package: pkg,
IsInGoEnv: isInGoEnv,
GoMod: GoMod{
Module: module,
Path: goMod,