It doesn't really matter if you want to declare a function with or without a receiver: Go nesting functions are not allowed.
Although you can use function literals to achieve something like this:
func f() { foo := func(s string) { fmt.Println(s) } foo("Hello World!") }
Here we have created the variable foo , which has the type of the function and is divided inside another function f . Calling the "external" function f outputs: "Hello World!" , as was expected.
Try it on the go playground .
source share