-
Notifications
You must be signed in to change notification settings - Fork 2
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Aliased basic type names render unexpectedly #8
Comments
It certainly won't result in incompatible code: in the Go type system, You'll see they are literally the same value in the "go/types" API. And you'll also note that there is no But I understand the desire to control which of the aliases is used in the resulting code. I wonder if it would suffice to have configuration options passed to |
I would prefer some way to specify the rendering preference on the TypeName, that way you can render a signature like Maybe something like type basicTypeName reflect.Kind
var _ TypeName = basicTypeName(0)
func (t basicTypeName) Kind() TypeKind { return KindBasic }
func (t basicTypeName) Symbol() Symbol { return Symbol{} }
func (t basicTypeName) Elem() TypeName { return nil }
func (t basicTypeName) Key() TypeName { return nil }
func (t basicTypeName) Len() int64 { return -1 }
func (t basicTypeName) Dir() reflect.ChanDir { return 0 }
func (t basicTypeName) BasicKind() reflect.Kind { return reflect.Kind(t) }
func (t basicTypeName) Signature() *Signature { return nil }
func (t basicTypeName) Fields() []FieldType { return nil }
func (t basicTypeName) Methods() []MethodType { return nil }
func (t basicTypeName) Embeds() []Symbol { return nil }
func (t basicTypeName) String() string { return typeNameToString(t) }
func (t basicTypeName) isTypeNameOrSpec() {}
type basicTypeNameWithRenderingPref struct {
kind reflect.Kind
literal string
}
var _ TypeName = basicTypeName(0)
func (t basicTypeNameWithRenderingPref) Kind() TypeKind { return KindBasic }
func (t basicTypeNameWithRenderingPref) Symbol() Symbol { return Symbol{} }
func (t basicTypeNameWithRenderingPref) Elem() TypeName { return nil }
func (t basicTypeNameWithRenderingPref) Key() TypeName { return nil }
func (t basicTypeNameWithRenderingPref) Len() int64 { return -1 }
func (t basicTypeNameWithRenderingPref) Dir() reflect.ChanDir { return 0 }
func (t basicTypeNameWithRenderingPref) BasicKind() reflect.Kind { return reflect.Kind(t) }
func (t basicTypeNameWithRenderingPref) Signature() *Signature { return nil }
func (t basicTypeNameWithRenderingPref) Fields() []FieldType { return nil }
func (t basicTypeNameWithRenderingPref) Methods() []MethodType { return nil }
func (t basicTypeNameWithRenderingPref) Embeds() []Symbol { return nil }
func (t basicTypeNameWithRenderingPref) String() string {
if t.literal == "" {
return basicTypeName(t.kind).String()
}
return t.literal
}
func (t basicTypeNameWithRenderingPref) isTypeNameOrSpec() {} |
int32 always seems to render as rune, and the same for uint8 and byte. This may result in compatible code (except for embedded alised types perhaps), but it is odd and makes the code written by gopoet less readable.
The text was updated successfully, but these errors were encountered: