You cannot access Function2 inside it if it is in the line where you declare it. The reason is that you are not referring to a function, but to a variable (whose type is a function), and it will be available only after the declaration.
First declare a Function2 variable, so you can refer to it from a function literal :
func Function1(n int) int { a := 10 var Function2 func(m int) int Function2 = func(m int) int { if m <= a { return a } return Function2(m - 1) } return Function2(n) }
Try it on the go playground .
source share