Skip to content

Instantly share code, notes, and snippets.

@mauleyzaola
Last active June 11, 2022 21:00
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 mauleyzaola/04324b9bfa502244033ace7677d5cb34 to your computer and use it in GitHub Desktop.
Save mauleyzaola/04324b9bfa502244033ace7677d5cb34 to your computer and use it in GitHub Desktop.
Reads from stdin pipe
func ReadFromStdIN() (io.ReadCloser, error) {
info, err := os.Stdin.Stat()
if err != nil {
return nil, err
}
if info.Mode()&os.ModeNamedPipe == 0 {
return nil, fmt.Errorf("no pipe")
}
return os.Stdin, nil
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment