Skip to content
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
10 changes: 8 additions & 2 deletions golang/go_client.go
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@ package golang

import (
"bytes"
"fmt"
"go/format"
"strings"
"text/template"
Expand All @@ -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
Expand All @@ -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 {
Expand Down
2 changes: 1 addition & 1 deletion golang/go_template.go
Original file line number Diff line number Diff line change
Expand Up @@ -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.
Expand Down
1 change: 1 addition & 0 deletions golang/schema.go
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,7 @@ func NewSchema(schema smd.Schema) Schema {
type Schema struct {
gen.GeneratorData
Package string
CallerName string
Namespaces []Namespace
}

Expand Down