I'm writing something that reads lines from os.Stdin using a bufio.Scanner like:
for s.scanner.Scan() {
line := s.scanner.Text()
// process line
}
This is running in a goroutine and I want to be able to stop it when a chan struct{} closes. However as Scan blocks until there is another line, I'm at a loss as how to stop it, if there is no more input, it'll block indefinitely.
Can anyone point me in the right direction here?