-
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
define more type separately in 1 go file #32
Comments
one more question the go:generate xxxxxx command is too long, how can I write it into several lines |
I just want to write ReadPair in one file , and use different generic function for int and float |
Also, given func f(s S) {}
func g(s S, t T) {} genny will generate redundant definitions for |
I experienced the same issue. Would appreciate any guidance on how to implement a fix if a PR would be welcome. |
@olivoil Are you still thinking of making the PR? Please let me know if any more details would help. |
3 year passed |
check code below , I just want to define 2 type separately in 1 file
however it generate ReadPairInt8 ReadPairInt16 many times,
could u find a way fix it, like if there is only 1 type in one function , do not repeat it
or define a generic.SingleType
`
//go:generate genny -in=$GOFILE -out=../util/$GOFILE gen "T1=int8,int16,int32,int64,int,uint8,uint16,uint32,uint64,uint T2=float32,float64"
package util
import (
"strconv"
"github.com/cheekybits/genny/generic"
)
type T1 generic.Type
func ReadPairT1(data string) (x, y T1) {
splits := SplitParams(data)
lx, _ := strconv.Atoi(splits[0])
ly, _ := strconv.Atoi(splits[1])
x = T1(lx)
y = T1(ly)
return
}
type T2 generic.Type
func ReadPairT2(data string) (x, y T2) {
splits := SplitParams(data)
lx, _ := strconv.ParseFloat(splits[0], 32)
ly, _ := strconv.ParseFloat(splits[1], 32)
x = T2(lx)
y = T2(ly)
return
}
`
The text was updated successfully, but these errors were encountered: