Skip to content

Instantly share code, notes, and snippets.

@maniankara
Created February 19, 2017 13:59
Show Gist options
  • Save maniankara/21cebdc3ef2001e0892ce62c4943615c to your computer and use it in GitHub Desktop.
Save maniankara/21cebdc3ef2001e0892ce62c4943615c to your computer and use it in GitHub Desktop.
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