Skip to content

Instantly share code, notes, and snippets.

@codahale
Created May 27, 2025 19:29
Show Gist options
  • Save codahale/7b236a6743c1ae409e2daec38a2c3762 to your computer and use it in GitHub Desktop.
Save codahale/7b236a6743c1ae409e2daec38a2c3762 to your computer and use it in GitHub Desktop.
// createFile creates a file in the given root and returns it with a defer to close it
func createFile(root *os.Root, filename string) (*os.File, error) {
f, err := root.Create(filename)
if err != nil {
return nil, err
}
return f, nil
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment