From d3820f683dee340a92755f96bda06d303633137c Mon Sep 17 00:00:00 2001 From: directduck Date: Mon, 19 Jan 2026 10:55:20 +0300 Subject: [PATCH] Add callerNamespace to go client --- golang/go_client.go | 10 ++++++++-- golang/go_template.go | 2 +- golang/schema.go | 1 + 3 files changed, 10 insertions(+), 3 deletions(-) diff --git a/golang/go_client.go b/golang/go_client.go index 9b776ae..f9376e0 100644 --- a/golang/go_client.go +++ b/golang/go_client.go @@ -2,6 +2,7 @@ package golang import ( "bytes" + "fmt" "go/format" "strings" "text/template" @@ -12,12 +13,13 @@ import ( ) const ( - version = "1.1.0" + version = "1.1.1" lang = "golang" ) type Settings struct { - Package string + Package string + CallerNamespace string } // Generator main package structure @@ -38,6 +40,10 @@ func NewClient(schema smd.Schema, settings Settings) *Generator { func (g *Generator) Generate() ([]byte, error) { g.schema.GeneratorData = gen.DefaultGeneratorData().AddLangAndLocalVersion(version, lang) g.schema.Package = g.settings.Package + g.schema.CallerName = g.settings.Package + if g.settings.CallerNamespace != "" { + g.schema.CallerName = fmt.Sprintf("%s-%s", g.settings.CallerNamespace, g.settings.Package) + } tmpl, err := template.New("golang client").Funcs(templateFuncs).Parse(goTpl) if err != nil { diff --git a/golang/go_template.go b/golang/go_template.go index bf78e26..b7926b4 100644 --- a/golang/go_template.go +++ b/golang/go_template.go @@ -20,7 +20,7 @@ import ( "github.com/vmkteam/zenrpc/v2" ) -const name = "{{ .Package }}" +const name = "{{ .CallerName }}" var ( // Always import time package. Generated models can contain time.Time fields. diff --git a/golang/schema.go b/golang/schema.go index c9ebf97..6eb23cc 100644 --- a/golang/schema.go +++ b/golang/schema.go @@ -31,6 +31,7 @@ func NewSchema(schema smd.Schema) Schema { type Schema struct { gen.GeneratorData Package string + CallerName string Namespaces []Namespace }