Is it reasonable to use a function like "Assert" below to do validation 
checking in Go?  If not, why not?

func Assert(t bool, msg string) {
if !t {
debug.SetTraceback("all")
debug.PrintStack()
log.Fatal("Assertion failed: " + msg)
}
}

func Divide(a float64, b float64) float64 {
Assert(b != 0, "divide by 0")
return a / b
}

func main() {
fmt.Println(Divide(10, 5))
}

Thanks,
-Tristan

-- 
You received this message because you are subscribed to the Google Groups 
"golang-nuts" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to golang-nuts+unsubscr...@googlegroups.com.
For more options, visit https://groups.google.com/d/optout.

Reply via email to