The first function in a GO program to be called is the function main located in package main.
Symbolic:
func name(arguments) returntype {
// do something
}
Example:
func say(name string) boolean {
fmt.Println(name)
return true
}
If you have multiple return types, the declaration is:
func name(arguments) (returntypes) {
// do something
}
A function within the same package can be called directly.
(not runnable code)
func main(){
say("Bob")
}
func say(name string){
fmt.Println(name)
}
A function from an imported package must be:
import "fmt"
func main(){
fmt.Println("Bob")
}
Next: Function Arguments