Skip to content

Instantly share code, notes, and snippets.

@mauleyzaola
Created June 11, 2022 21:03
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/7fc511628a65e57b6543f002eef70043 to your computer and use it in GitHub Desktop.
Save mauleyzaola/7fc511628a65e57b6543f002eef70043 to your computer and use it in GitHub Desktop.
Checks the file exists and opens it
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