You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
For a variable located in foo.go to embed the file foo.go, we need:
//go:embed foo.govarfilestring
It would be convenient if the embed directive interprets the empty argument as to embed the current source file, e.g.:
//go:embedvarfilestring
I was looking to do documentation generation by parsing out godoc comment of a go source file that contains many configuration parameters for a program by embedding that file and parsing the AST. By allowing the embed directive embed the source file that the directive appears in when no arguments are given, I no longer have to couple the embed directive argument with that source file's filename (i.e., no longer need to update the embed directive every time the source code's filename is changed).
The text was updated successfully, but these errors were encountered:
I don't really understand what you are trying to do, but have you considered using go generate instead? Then you will have access to the GOFILE env var that it sets.
This seems very special purpose, and rather confusing when reading the code.
This is not a big deal, as the file being renamed without the embed directive being updated will lead to a test failure. But currently the embed directive without argument is an error, so I figured that we might as well make the default do something useful. I suppose the current error is helpful in preventing someone accidentally including a file in the compiled binary that they didn't intend.
For a variable located in
foo.go
to embed the filefoo.go
, we need:It would be convenient if the embed directive interprets the empty argument as to embed the current source file, e.g.:
I was looking to do documentation generation by parsing out godoc comment of a go source file that contains many configuration parameters for a program by embedding that file and parsing the AST. By allowing the embed directive embed the source file that the directive appears in when no arguments are given, I no longer have to couple the embed directive argument with that source file's filename (i.e., no longer need to update the embed directive every time the source code's filename is changed).
The text was updated successfully, but these errors were encountered: