Skip to content

Commit

Permalink
fix: fix ref (#239)
Browse files Browse the repository at this point in the history
  • Loading branch information
HeyJavaBean authored Nov 4, 2024
1 parent 92985a8 commit c1083dc
Showing 1 changed file with 6 additions and 0 deletions.
6 changes: 6 additions & 0 deletions generator/golang/templates/ref/ref_tpl.go
Original file line number Diff line number Diff line change
Expand Up @@ -113,6 +113,7 @@ var constRef = `{{- $Consts := .Constants.GoConstants}}
{{- if $Consts}}
const (
{{- range $Consts}}
{{ if and Features.ReserveComments .ReservedComments}}{{.ReservedComments}}{{end}}
{{.GoName}} = {{$RefPackage}}.{{.GoName}}
{{- end}}{{/* range $Consts */}}
)
Expand All @@ -130,6 +131,7 @@ var (

var structRef = `
{{- $TypeName := .GoName}}
{{ if and Features.ReserveComments .ReservedComments}}{{.ReservedComments}}{{end}}
type {{$TypeName}}= {{$RefPackage}}.{{$TypeName}}
var New{{$TypeName}} = {{$RefPackage}}.New{{$TypeName}}
{{- range .Fields}}
Expand All @@ -152,6 +154,7 @@ var enumRef = `
{{- range .Enums}}
{{- $EnumType := .GoName}}
{{- $TypeName := .GoName}}
{{ if and Features.ReserveComments .ReservedComments}}{{.ReservedComments}}{{end}}
type {{$TypeName}}= {{$RefPackage}}.{{$TypeName}}
var {{$EnumType}}FromString = {{$RefPackage}}.{{$EnumType}}FromString
var {{$EnumType}}Ptr = {{$RefPackage}}.{{$EnumType}}Ptr
Expand All @@ -166,6 +169,8 @@ var enumRef = `
{{- else }}
const (
{{- range .Values}}
{{- if and Features.ReserveComments .ReservedComments}}
{{.ReservedComments}}{{end}}
{{.GoName}} = {{$RefPackage}}.{{.GoName}}
{{- end}}
)
Expand All @@ -176,6 +181,7 @@ var enumRef = `
var typedefRef = `
{{- range .Typedefs}}
{{- $NewTypeName := .GoName}}
{{ if and Features.ReserveComments .ReservedComments}}{{.ReservedComments}}{{end}}
type {{$NewTypeName}}= {{$RefPackage}}.{{$NewTypeName}}
{{if .Type.Category.IsStructLike}}
var New{{$NewTypeName}} = {{$RefPackage}}.New{{$NewTypeName}}
Expand Down

0 comments on commit c1083dc

Please sign in to comment.