Skip to content

Instantly share code, notes, and snippets.

@samnm
Created December 11, 2012 22:24
Show Gist options
  • Save samnm/4262886 to your computer and use it in GitHub Desktop.
Save samnm/4262886 to your computer and use it in GitHub Desktop.
A super simple quine written in Go. This takes advantage of the '%q' format verb to print strings as they are represented in source. Run `go run quine.go | diff quine.go -` to diff the output and source.
package main
import "fmt"
func main() {
s0 := "package main\n\nimport \"fmt\"\n\nfunc main() {\n\ts0 := %q\n\tfmt.Printf(s0, s0)\n}\n"
fmt.Printf(s0, s0)
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment