-
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
When using go generate, genny does not remove the original go generate comment. #25
Comments
I don't run in to this problem.
Can you show a simplified version of your file so others can reproduce it? |
This is what I'm using package util
//go:generate $GOPATH/bin/genny -in=$GOFILE -out=gen-$GOFILE gen "valueType=Thread"
import (
"sync"
"github.com/cheekybits/genny/generic"
)
type valueType generic.Type
//valueTypeSlice is a synchronizable slice that supports easy deletion of indices.
type valueTypeSlice struct {
Slice []valueType
sync.Mutex
}
//Delete deletes an index from a slice by replacing the value at the end with the last index then reslicing to prune the last element.
//A call to delete must be synchronized via the built in mutex.
//Delete does not check bounds and will panic if index is outside the bounds of the slice.
func (s *valueTypeSlice) Delete(index int) {
s.Slice[index] = s.Slice[len(s.Slice)-1]
if len(s.Slice) > 0 {
s.Slice = s.Slice[:len(s.Slice)-1]
}
} go generate (1.6.2) produces // This file was automatically generated by genny.
// Any changes will be lost if this file is regenerated.
// see https://github.com/cheekybits/genny
package util
import "sync"
//go:generate $GOPATH/bin/genny -in=$GOFILE -out=gen-$GOFILE gen "Thread=Thread"
//ThreadSlice is a synchronizable slice that supports easy deletion of indices.
type ThreadSlice struct {
Slice []Thread
sync.Mutex
}
//Delete deletes an index from a slice by replacing the deleted value with the last value of the slice and pruning.
//A call to delete must be synchronized via the built in mutex.
//Delete does not check bounds and will panic if index is outside the bounds of the slice.
func (s *ThreadSlice) Delete(index int) {
s.Slice[index] = s.Slice[len(s.Slice)-1]
if len(s.Slice) > 0 {
s.Slice = s.Slice[:len(s.Slice)-1]
}
} |
I can reproduce now. Change It looks like |
Thanks, would this still be considered a bug? A part of me feels like there should never be |
Just as a related comment I personally have never put the |
When using go generate, genny does not remove the original go generate comment causing subsequent go generates to fail after a
gen-gen-file.go
is created. This creates the nuisance of having to manually remove the go generate line in generated files.The text was updated successfully, but these errors were encountered: