How do you get spaces in flag values when using directives?
Context
The flag package receives and/or handles flags with spaces differently depending on how Go is called. Quoting the flag value works from the command-line but not with a directive, such as go generate, for example.
In other words, called from the command line, Flag1 will receive the correct value (i.e., 4 words, 3 spaces).
Works
% go run -tags generate main.go -Flag1="flag value with spaces"
Doesn't Work
However, calling the exact same command in a directive file, e.g., with go generate ./..., Flag1 will not receive the correct value. Take a directive file (e.g., generate.go) with this line in it:
//go:generate go run -tags generate main.go -Flag1="flag value with spaces" -Flag2=next
Flag1 is not set correctly and Flag2 is not set at all.
Extrapolating from an old, related, but not the same question, enclose the entire flag key, dash, and value in quotes.
This syntax has the advantage of working on the command line or in directive files.
None of the current documentation (that I could find) provides a clear answer:
flagdocumentation does not mention flag values with spaces.