Skip to content

Commit

Permalink
unexport goimport
Browse files Browse the repository at this point in the history
  • Loading branch information
julieqiu committed Jan 12, 2025
1 parent 83533ab commit d66f5cb
Showing 1 changed file with 10 additions and 10 deletions.
20 changes: 10 additions & 10 deletions generator/internal/language/golang.go
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,7 @@ func newGoCodec(options map[string]string) (*goCodec, error) {
year, _, _ := time.Now().Date()
codec := &goCodec{
generationYear: fmt.Sprintf("%04d", year),
importMap: map[string]*GoImport{},
importMap: map[string]*goImport{},
}
for key, definition := range options {
switch {
Expand All @@ -59,9 +59,9 @@ func newGoCodec(options map[string]string) (*goCodec, error) {
if len(defs) != 2 {
return nil, fmt.Errorf("%s should be in the format path;name, got=%q", definition, keys[1])
}
codec.importMap[keys[1]] = &GoImport{
Path: defs[0],
Name: defs[1],
codec.importMap[keys[1]] = &goImport{
path: defs[0],
name: defs[1],
}
}
}
Expand All @@ -79,16 +79,16 @@ type goCodec struct {
// The package name to generate code into
goPackageName string
// A map containing package id to import path information
importMap map[string]*GoImport
importMap map[string]*goImport
// Some packages are not intended for publication. For example, they may be
// intended only for testing the generator or the SDK, or the service may
// not be GA.
doNotPublish bool
}

type GoImport struct {
Path string
Name string
type goImport struct {
path string
name string
}

func (c *goCodec) loadWellKnownTypes(s *api.APIState) {
Expand Down Expand Up @@ -192,7 +192,7 @@ func (c *goCodec) messageName(m *api.Message) string {
return c.messageName(m.Parent) + "_" + strcase.ToCamel(m.Name)
}
if imp, ok := c.importMap[m.Package]; ok {
return imp.Name + "." + c.toPascal(m.Name)
return imp.name + "." + c.toPascal(m.Name)
}
return c.toPascal(m.Name)
}
Expand Down Expand Up @@ -362,7 +362,7 @@ func (c *goCodec) additionalContext(*api.API) any {
func (c *goCodec) imports() []string {
var imports []string
for _, imp := range c.importMap {
imports = append(imports, fmt.Sprintf("%q", imp.Path))
imports = append(imports, fmt.Sprintf("%q", imp.path))
}
return imports
}
Expand Down

0 comments on commit d66f5cb

Please sign in to comment.