Skip to content

Instantly share code, notes, and snippets.

@joerx
Created March 29, 2018 01: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 joerx/10e75f6eba6cddf785d505f03486827a to your computer and use it in GitHub Desktop.
Save joerx/10e75f6eba6cddf785d505f03486827a to your computer and use it in GitHub Desktop.
Read data from stdin in go
package main
import (
"bufio"
"fmt"
"os"
)
func main() {
in := os.Stdin
r := bufio.NewReader(in)
for {
line, err := r.ReadString('\n')
if err != nil {
break
}
fmt.Printf("> %s", line)
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment