Skip to content

Instantly share code, notes, and snippets.

Embed
What would you like to do?
simple firstclass function: assigning function to variable
package fragments
import "os"
func dummy() {
// define
createFile := func (path string) *os.File {
tmpfn, err := os.Create(path)
if err != nil {
"Error while creating file: ", path
}
return tmpfn
}
// invoke file creation
createFile()
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment