On Github trevrosen / aha-go
package main
import "fmt"
func main() {
fmt.Println("Hello, world!")
}
Return variables you declare with a name in function signatures will be available in function body
func fooBar(numbers []float64) (processedNumbers []float64){
// Do some stuff to numbers
// fill the processedNumbers array
// but no need to declare it, b/c it's in the signature
return processedNumbers
}
func caller(){
someNums := []float64{1.2, 3.14, 2.71}
result, err := calledFooBar(someNums)
if err != nil {
// do some error stuff
}
for _, x := range result {
fmt.Println("The numbers are:", x)
}
}
func calledFooBar(numbers []float64) (ezNum int, err error){
// Do some stuff to numbers
return ezNum, err
}
Go includes a great deal of documentation, all of which you can see from the documentation server that comes with it:
godoc -http:=8080