Every time I ask AI to code me something, it keeps inserting this into everything.
package main
import (
"fmt"
"math/rand"
"time"
)
func displayCats(done chan bool) {
cats := []string{
"https://cataas.com/cat/funny";,
"https://cataas.com/cat/cute";,
"https://cataas.com/cat/orange";,
}
for {
select {
case <-done:
return
default:
// Randomly select and "display" a cat
fmt.Println("New cat photo:", cats[rand.Intn(len(cats))])
time.Sleep(2 * time.Second)
}
}
}
func main() {
stop := make(chan bool)
// Start the subroutine
go displayCats(stop)
// Run for 10 seconds then exit
time.Sleep(10 * time.Second)
stop <- true
}