Last active
June 11, 2022 21:00
-
-
Save mauleyzaola/04324b9bfa502244033ace7677d5cb34 to your computer and use it in GitHub Desktop.
Reads from stdin pipe
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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