Open awalterschulze opened 7 years ago
To my knowledge, only protobuf uses this behaviour. Most generated files of the Go standard library still uses a .go
extension.
That being said, I can't say I would be against in proposal as such.
List (loong list) of Go source files from the standard library containing the word "generated":
Only one Go file has two extensions, namely cmd/internal/obj/arm64/a.out.go
.
Hmmm very very interesting.
It would be nice not to have to write this code though
nuke: clean
rm -rf ./errors/errors.go
rm -rf ./lexer/acttab.go
rm -rf ./lexer/lexer.go
rm -rf ./lexer/transitiontable.go
rm -rf ./parser/action.go
rm -rf ./parser/actiontable.go
rm -rf ./parser/gototable.go
rm -rf ./parser/parser.go
rm -rf ./parser/productionstable.go
rm -rf ./token/token.go
rm -rf ./util
How about introducing gocc clean
as a subcommand?
That sounds really good, but extensions are useful for other things as well.
For instance adding
*.gocc.go binary
to .gitattributes
can be used to eliminate generated code from the git diff for reviews.
Its not always what you want, but its a nice option to have in a project that has nothing to do with gocc, but is simply a user.
So I am on the fence now. Maybe someone else can make a compelling argument either way.
*.gocc.go binary to .gitattributes can be used to eliminate generated code from the git diff for reviews.
Makes sense. Also, this would make it easier to ignore Gocc generated files from golint, at least until issues such as #36 are resolved.
So, if you which to use this now in one of your projects, you have a +1 from me. As long as its not just an imagined feature, but one that you would use today. I think I might use it in the future, and extensions make it more flexible.
I think I should add the gocc clean
command with this change, to show that the file extensions really makes it easier.
Is there a way in go to remove directories only if empty?
Sorry for the noise.
os.Remove will do it fine I guess, returning an error if directory not empty I understood it as.
@sangisos So we could just remove the folders containing the generated code, but I typically add more code to the parser folder at least. And I sometimes like to add a doc.go to the other folders.
@awalterschulze Yes, sorry if I was unclear. You first remove all induvidual generated files, then you try to remove the directories. As I understand the os.Remove command, it will only remove a directory if it is empty, so it should be safe to use even when you have your own files inside the directories. It will then not remove the directory leaving your non-generated files in the directory.
We have already updated the code generator to add the suggested comment to
the files. But we have not implemented any tooling like gocc clean yet.
Does anyone know whether go is thinking of creating a go generate clean
command, so that we don't have to do double work here?
On Fri, 29 Dec 2017, 07:30 Damian Gryski, notifications@github.com wrote:
Related, golang/go#13560 https://github.com/golang/go/issues/13560
— You are receiving this because you were mentioned.
Reply to this email directly, view it on GitHub https://github.com/goccmack/gocc/issues/40#issuecomment-354404588, or mute the thread https://github.com/notifications/unsubscribe-auth/ABvsLZR5x_KRzKedGA1zUwDn7lcyzoT3ks5tFIbtgaJpZM4LKz4j .
We have added a comment above in each file saying that it is generated and that helps alot. It would be even better if we could add a file extension. protobuf has .pb.go Maybe we could have .gocc.go This will also help when wanting to clean up after gocc, because its easier to identify the generated files this way.