MCPcopy Create free account
hub / github.com/derekbanas/Go-Tutorial / getQuotient

Function getQuotient

hellogo.go:48–57  ·  view source on GitHub ↗

Return potential error

(x float64, y float64)

Source from the content-addressed store, hash-verified

46
47// Return potential error
48func getQuotient(x float64, y float64) (ans float64, err error) {
49 if y == 0 {
50 // Define error message returned with dummy value
51 // for ans
52 return 0, fmt.Errorf("You can't divide by zero")
53 } else {
54 // If no error return nil
55 return x / y, nil
56 }
57}
58
59// Variadic function
60func getSum2(nums ...int) int {

Callers 1

mainFunction · 0.85

Calls

no outgoing calls

Tested by

no test coverage detected