-
Notifications
You must be signed in to change notification settings - Fork 12
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
Ignore global variables prefixed with //go:embed #22
Conversation
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.
Thanks @zbindenren! It looks great. Thanks for adding a test too. I have a few questions (❓) below that are for filling gaps in my own knowledge 😄.
On a side note, it only makes sense to check for this if the file imports the |
I didn't know that. I was thinking that with: //go:embed path/to/file
file []byte it is not necessary. But it is. |
@zbindenren are you still working on this PR? |
Is this PR just waiting on a review and merge? Apologies if this fell off my queue. |
I am finished, I can make a new PR but it changes the isAllowed signature. But with this change it would better. Shall update the PR? |
@zbindenren I think you should make the change in this PR, just add a new commit, Would be nice to get this merged and update |
This work appears to have stalled? Is assistance needed to get it completed? |
@dackroyd Yup, a lot of the work was done, but I'm sure everyone is dealing with life 😄. |
I've made a few changes to this PR.
This PR at commit 700e76b contains all these changes. @zbindenren @bombsimon @pavelnikolov @ldez You all left comments about this feature. Would any of you be up for taking a last look at this change, and possibly trying it on your codebases to see if there are any edge cases we might be missing? If nobody sees any issues, I'll merge this and cut a release. |
I pushed one more change, removing the This is also the same reason why the checker doesn't need to handle the case where a go embed comment is placed on a var group. The Go compiler will also error on that. |
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.
Awesome, thanks for finally taking a stab at this! ⭐
This looks great to me but I can think of a few use cases that might be worth adding tests for (and also ensure working):
/*
This is a long comment
Spanning over multiple lines
*/
//go:embed file.txt
var f string
And the opposite:
//go:embed file.txt
/*
This is a long comment
Spanning over multiple lines
*/
var f string
And I don't know why/if anyone would do this, but this does work as well so if possible maybe should be valid just like we discussed with empty lines between comment and declaration:
/*
Comment 1
*/
//go:embed foo.txt
/*
Comment 2
*/
var s string
@bombsimon Nice additional test cases! Added! All pass! 🎉 |
This should fix #21.