It seems there are two different ways to declare a function in Golang, like this:
package main
import "fmt"
var someFunc = func(arg string) {
fmt.Println(arg)
}
func main() {
someFunc("Hello")
}
The above works. However, the below does not work:
package main
import "fmt"
var someFunc = func(arg string) {
fmt.Println(arg)
}
var main = func() {
someFunc("Hello")
}
It will complain:
runtime.main: undefined: main.main
So what's the difference between func someFunc() and var someFunc = func()?
The reason I found this is probably because of I code a lot of Javascript, too. It seems in Go, I rarely see people declaring a function like var someFunc=func(). Of these two, can we say which one is more correct than the other one?