“ensure” in ruby • Panic / recover are similar to exception, but only should be used for internal APIs, never for external APIs. • Panic is used for runtime errors, like array out of bound
func PanicFunction() { defer func() { if e := recover(); e != nil { fmt.Printf("Recovered from %s \n", e) } }() panic("PANIC PANIC PANIC") fmt.Println("This will not be printed") }
:= make(chan ChannelResult, number_of_connections) ! // Start the request in a new goroutine go makeRequest(address, start_byte, end_byte, out, channels) ! //Wait for the result of the goroutine in the channel for(loop_var < number_of_connections) { chan_res := <-channels // Process the result and save to the file }
a few new options • Don’t come with assertions / macros • Tests have the same package as the application code • Tests stay in the same directory of the application code