dmitri.shuralyov.com/scratch/...

quine: add package quine

Quines are fun

Change-Id: I3dffaf514ac2a04046fb54b6179cd1677053c5c7
Reviewed-On: https://dmitri.shuralyov.com/scratch/...$changes/2
Johan Brandhorst-Satzkorn committed 8 months ago commit ed302c9ae10219a542d1a6d2d1293e1b7742b65a
Collapse all
quine/LICENSE
@@ -0,0 +1,23 @@
The quine was sourced from https://github.com/alangpierce/golang-quine under the MIT license:

The MIT License (MIT)

Copyright (c) 2016 Alan Pierce

Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
in the Software without restriction, including without limitation the rights
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
copies of the Software, and to permit persons to whom the Software is
furnished to do so, subject to the following conditions:

The above copyright notice and this permission notice shall be included in all
copies or substantial portions of the Software.

THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
SOFTWARE.
quine/quine.go
@@ -0,0 +1,16 @@
package main

import "fmt"

func main() {
	code := `package main

import "fmt"

func main() {
	code :=
	fmt.Print(code[:51] + "\u0060" + code + "\u0060" + code[51:])
}
`
	fmt.Print(code[:51] + "\u0060" + code + "\u0060" + code[51:])
}