working with go template files hindered by aggressive format on save feature #2972
Unanswered
plastikfan
asked this question in
Help
Replies: 0 comments
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
-
I am trying to compose quite a complicated suite of go templates (used to generate go code), but the format on save feature invoked by vscode/go-extension makes this a difficult undertaking. A couple of points I need to mention first are:
However, there is a really big problem now (possibly because of the go file association). Consider the following template definition:
The purpose of this template is to provide static header content for a go source file to be generated. I also have a footer. You will notice that there is no go template syntax here, that is because the header (and the footer), have static content. The dynamic content is in another file.
Whenever, I go to save the above file, the format on save feature is activated that proceeds to remove the import statement, breaking my code generation. The dynamic content I mentioned before relies on these imports. Is there a way to bypass format on save for a specific file type, namely .go.tmpl?
When I look at the vscode settings, there is only a single option: Editor:Format On Save, which allows to to turn on or off the feature. Clearly, I do not want to turn off this feature, for the relative minor requirement of go template file editing, rather, I would have preferred if there was an option to limit this feature to .go file types only, or allow other suffix exclusions.
If there is another way to get around this issue (within vscode), I would be most grateful to hear of it.
I was going to raise an issue on the go-extension repo, but thought I'd post this request first to see if there is a work-around.
Thanks.
Beta Was this translation helpful? Give feedback.
All reactions