Skip to content

Instantly share code, notes, and snippets.

Show Gist options
  • Star 4 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save ikrauchanka/ddc076308f1297e5a5e8c969a4df1c8e to your computer and use it in GitHub Desktop.
Save ikrauchanka/ddc076308f1297e5a5e8c969a4df1c8e to your computer and use it in GitHub Desktop.
golang return function in function
package main
import (
"fmt"
)
func makeFunction(name string) func() {
return func() {
fmt.Printf("Hello %s", name)
}
}
func main() {
f := makeFunction("Ilja")
f()
}
@karl-gustav
Copy link

@blinkinglight
Copy link

blinkinglight commented Jul 17, 2019

makeFunction("Ilja")() https://play.golang.org/p/-pBuVhqKqZf

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment