Skip to content
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

generate single file for multiple data type #23

Open
oliveagle opened this issue Jul 25, 2018 · 1 comment
Open

generate single file for multiple data type #23

oliveagle opened this issue Jul 25, 2018 · 1 comment

Comments

@oliveagle
Copy link

package max

// template type Max(A)

type A int

func Max(x, y A) A {
	if x < y {
		return y
	}
	return x
}

for above template, is ok to generate multiple files.

//go:generate gotemplate "xxx/max" "MaxInt(int)"
//go:generate gotemplate "xxx/max" "MaxInt8(int8)"
//go:generate gotemplate "xxx/max" "MaxInt16(int16)"
//go:generate gotemplate "xxx/max" "MaxInt32(int32)"
//go:generate gotemplate "xxx/max" "MaxInt64(int64)"

since the template is too simple, it's better to organize these functions into a single file.

is it possible to accept multiple arguments something like this?

// go:generate gotemplate -out "MaxInts" "xxx/max" "MaxInt(int)" "MaxInt8(int8)" "MaxInt16(int16)" "MaxInt32(int32)" "MaxInt64(int64)"
@ncw
Copy link
Owner

ncw commented Jul 30, 2018

This isn't possible at the moment, but it doesn't sound too difficult... Fancy sending a PR?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

2 participants