-
Notifications
You must be signed in to change notification settings - Fork 126
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
Add generic Integer type #17
Comments
I would like to see "Integer" added instead changing Number to int. Integers support more operators than floats, which means "type Integer int" is necessary if you want to use those operators. Similar to how "type Type interface{}" is useful for indicating and ensuring support for a less specific set of types than "type Number float64", the latter is useful for indicating and ensuring support for integers and floats. |
I don't understand what |
IIRC, I was trying to support generating different types of |
Something like this would be useful for generating code for enum-type constants. |
@pdrum
|
@takeda — So I just tried this, and naively assigning the custom type to As a workaround, if what you want is for your templates to compile, behave well in your IDE, etc., you can put the type declarations in a separate file in the same directory. As far as I can tell this just works—which is interesting, because it suggests the whole |
Ah I see, I forgot that genny removes it. In that case I agree that |
It does make the templates more readable and more obviously templates. |
I encounter an error when using a generic type to index a slice or as the
len
argument tomake
My workaround has been to add a
generic.Integer
type, in addition to the existinggeneric.Number
type. An alternative might be to change thegeneric.Number
definition to:Another alternative is to add a
// +build ignore
tag to the template file, but then I think it can't be used for generic testing.The text was updated successfully, but these errors were encountered: