Skip to content

Instantly share code, notes, and snippets.

@alexballas
Last active November 29, 2021 20:54
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save alexballas/cc33832b3b07619d3868f82fc1a67392 to your computer and use it in GitHub Desktop.
Save alexballas/cc33832b3b07619d3868f82fc1a67392 to your computer and use it in GitHub Desktop.
An io.Reader that generates an infinite number of Rick Roll lyrics
package main
import (
"io"
)
var rr = `We're no strangers to love
You know the rules and so do I
A full commitment's what I'm thinking of
You wouldn't get this from any other guy
I just wanna tell you how I'm feeling
Gotta make you understand
Never gonna give you up
Never gonna let you down
Never gonna run around and desert you
Never gonna make you cry
Never gonna say goodbye
Never gonna tell a lie and hurt you
We've known each other for so long
Your heart's been aching but you're too shy to say it
Inside we both know what's been going on
We know the game and we're gonna play it
And if you ask me how I'm feeling
Don't tell me you're too blind to see
Never gonna give you up
Never gonna let you down
Never gonna run around and desert you
Never gonna make you cry
Never gonna say goodbye
Never gonna tell a lie and hurt you
Never gonna give you up
Never gonna let you down
Never gonna run around and desert you
Never gonna make you cry
Never gonna say goodbye
Never gonna tell a lie and hurt you
Never gonna give, never gonna give
(Give you up)
We've known each other for so long
Your heart's been aching but you're too shy to say it
Inside we both know what's been going on
We know the game and we're gonna play it
I just wanna tell you how I'm feeling
Gotta make you understand
Never gonna give you up
Never gonna let you down
Never gonna run around and desert you
Never gonna make you cry
Never gonna say goodbye
Never gonna tell a lie and hurt you
Never gonna give you up
Never gonna let you down
Never gonna run around and desert you
Never gonna make you cry
Never gonna say goodbye
Never gonna tell a lie and hurt you
Never gonna give you up
Never gonna let you down
Never gonna run around and desert you
Never gonna make you cry
Never gonna say goodbye
`
type rickRollReader struct {
index int
}
func New() io.Reader {
return &rickRollReader{}
}
func (r *rickRollReader) Read(p []byte) (int, error) {
for n := range p {
p[n] = rr[r.index]
r.index++
if r.index == len(rr) {
r.index = 0
}
}
return len(p), nil
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment