Advertisement
Guest User

Untitled

a guest
Dec 22nd, 2014
345
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Go 1.30 KB | None | 0 0
  1. package main
  2.  
  3. import "fmt"
  4.  
  5. //go:generate echo one
  6. //go:generate printf %s\n two
  7.  
  8. func main() {
  9.     fmt.Println(`This is a program showing how go generate is a half-assed tool.
  10.  
  11. First of all, you might include in a multi-line string (like this one. It's a string, not a comment), the text
  12. //go:generate example of using go:generate.
  13. But, if you were to do the above, you'd be sorely disappointed to learn that running "go generate" on the file would result in an error. 'example not found'... yup, it doesn't feel like parsing the language, it just does dumb "split into lines, line starts with".... Yeah, wow.
  14.  
  15. This program also shows another issue with go generate. On your shiny release version of go 1.4 (no, not beta. Release) run
  16. "go generate -help". You'll notice it prints out usage for one flag... -run=""
  17. Read that. Notice that at the beginning of this I have a "go:generate echo" and a "go:generate printf".
  18. Just try to use go generate -run to make it print "one" but not "two". Good luck.
  19. Don't bang your head against the above problem too much though; I'll let you in on a secret. The single documented useful flag in go-generate does not in fact work. It's not implemented. At all. They define it and then never use it. Feel free to read the source code like I did after losing a week to this.
  20. `)
  21. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement