Module 01 Β· Go Basics β Lesson 2 of 3 Β· ~12 min
Functions
func, with types after the names
A Go function starts with func, then the name, then parameters, then the return type. The twist coming from Swift: the type comes after the name, both for parameters and for the return.
- Swift:
func greet(name: String) -> String - Go:
func greet(name string) string
No ->, no argument labels, no String with a capital S. Just name string, then the return type sitting bare after the parameter list.