Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat(hz): add default service name #852

Merged
merged 1 commit into from
Jul 18, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
7 changes: 6 additions & 1 deletion cmd/hz/generator/layout.go
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,7 @@ import (
"reflect"
"strings"

"github.com/cloudwego/hertz/cmd/hz/meta"
"github.com/cloudwego/hertz/cmd/hz/util"
"gopkg.in/yaml.v2"
)
Expand Down Expand Up @@ -169,10 +170,14 @@ func serviceToLayoutData(service Layout) (map[string]interface{}, error) {
if len(service.RouterDir) != 0 {
routerPkg = filepath.Base(service.RouterDir)
}
serviceName := service.ServiceName
if len(serviceName) == 0 {
serviceName = meta.DefaultServiceName
}

return map[string]interface{}{
"GoModule": goMod,
"ServiceName": service.ServiceName,
"ServiceName": serviceName,
"UseApacheThrift": service.UseApacheThrift,
"HandlerPkg": handlerPkg,
"RouterPkg": routerPkg,
Expand Down
2 changes: 2 additions & 0 deletions cmd/hz/meta/const.go
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,8 @@ import "runtime"
// Version hz version
const Version = "v0.6.5"

const DefaultServiceName = "hertz_service"

// Mode hz run modes
type Mode int

Expand Down