Created
June 11, 2022 21:03
-
-
Save mauleyzaola/7fc511628a65e57b6543f002eef70043 to your computer and use it in GitHub Desktop.
Checks the file exists and opens it
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 ReadFromFile(filename string) (io.ReadCloser, error) { | |
_, err := os.Stat(filename) | |
if err != nil { | |
return nil, err | |
} | |
return os.Open(filename) | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment