diff --git a/cmd/gf/internal/cmd/genpbentity/genpbentity.go b/cmd/gf/internal/cmd/genpbentity/genpbentity.go index e7138850d..74bc4ab04 100644 --- a/cmd/gf/internal/cmd/genpbentity/genpbentity.go +++ b/cmd/gf/internal/cmd/genpbentity/genpbentity.go @@ -38,6 +38,7 @@ type ( g.Meta `name:"pbentity" config:"{CGenPbEntityConfig}" brief:"{CGenPbEntityBrief}" eg:"{CGenPbEntityEg}" ad:"{CGenPbEntityAd}"` Path string `name:"path" short:"p" brief:"{CGenPbEntityBriefPath}" d:"manifest/protobuf/pbentity"` Package string `name:"package" short:"k" brief:"{CGenPbEntityBriefPackage}"` + GoPackage string `name:"goPackage" short:"g" brief:"{CGenPbEntityBriefGoPackage}"` Link string `name:"link" short:"l" brief:"{CGenPbEntityBriefLink}"` Tables string `name:"tables" short:"t" brief:"{CGenPbEntityBriefTables}"` Prefix string `name:"prefix" short:"f" brief:"{CGenPbEntityBriefPrefix}"` @@ -111,6 +112,7 @@ CONFIGURATION SUPPORT ` CGenPbEntityBriefPath = `directory path for generated files storing` CGenPbEntityBriefPackage = `package path for all entity proto files` + CGenPbEntityBriefGoPackage = `go package path for all entity proto files` CGenPbEntityBriefLink = `database configuration, the same as the ORM configuration of GoFrame` CGenPbEntityBriefTables = `generate models only for given tables, multiple table names separated with ','` CGenPbEntityBriefPrefix = `add specified prefix for all entity names and entity proto files` @@ -236,6 +238,7 @@ func init() { `CGenPbEntityAd`: CGenPbEntityAd, `CGenPbEntityBriefPath`: CGenPbEntityBriefPath, `CGenPbEntityBriefPackage`: CGenPbEntityBriefPackage, + `CGenPbEntityBriefGoPackage`: CGenPbEntityBriefGoPackage, `CGenPbEntityBriefLink`: CGenPbEntityBriefLink, `CGenPbEntityBriefTables`: CGenPbEntityBriefTables, `CGenPbEntityBriefPrefix`: CGenPbEntityBriefPrefix, @@ -369,10 +372,13 @@ func generatePbEntityContentFile(ctx context.Context, in CGenPbEntityInternalInp } } } + if in.GoPackage == "" { + in.GoPackage = in.Package + } entityContent := gstr.ReplaceByMap(getTplPbEntityContent(""), g.MapStrStr{ "{Imports}": packageImportsArray.Join("\n"), "{PackageName}": gfile.Basename(in.Package), - "{GoPackage}": in.Package, + "{GoPackage}": in.GoPackage, "{OptionContent}": in.Option, "{EntityMessage}": entityMessageDefine, })