-
Notifications
You must be signed in to change notification settings - Fork 2k
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
Add gotype comments in templates to map types between go template and go files #4155
Conversation
Dependency Review✅ No vulnerabilities or license issues found.Scanned Manifest Files |
Codecov Report
@@ Coverage Diff @@
## main #4155 +/- ##
==========================================
+ Coverage 51.95% 51.97% +0.02%
==========================================
Files 59 59
Lines 16762 16762
==========================================
+ Hits 8708 8712 +4
+ Misses 7755 7753 -2
+ Partials 299 297 -2 see 1 file with indirect coverage changes 📣 We’re building smart automated test selection to slash your CI/CD build times. Learn more |
Does this work only in IntelliJ? |
A good idea 👍🏻 VSCode supports this feature too. Apart from IDE support, the comments help to understand the code. |
You will only get the popups linking to the go structs in IntelliJ. For example, for the VirtualServer templates, you would have this block
This makes it very obvious which file in the project holds the go structs related to this template. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
👍🏻
@jjngx how do you use it in VS Code? |
I don't use it. |
I don't think it's supported in vsCode (at least not directly or even with changes in settings.json ) but its nice info re struct definition regardless. |
Proposed changes
Add gotype comments to specify mapping of types between Go templates (.tmpl) and go files (.go)
closes #4159
Testing
This is the screenshot of how it would look like in IntelliJ or GoLand. For example,
$u.Servers
links to the fieldServers
in[]StreamUpstreamServer
structBrowse the definition on
pkg.dev.go
. Note the that information on the website is stuck on v1.12.5 until #3770 is resolved.Autocomplete:
However, I tested this syntax for IntelliJ and GoLand only. For other unsupported IDE the comments still provide developer hints on which go file to look for the go struct definition.
Checklist
Before creating a PR, run through this checklist and mark each as complete.