Skip to content

Commit

Permalink
【王子华】 test
Browse files Browse the repository at this point in the history
  • Loading branch information
kingofzihua committed Feb 5, 2021
1 parent 638122f commit 6c12d68
Showing 1 changed file with 20 additions and 0 deletions.
20 changes: 20 additions & 0 deletions kingofzihua/div.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
package main

import (
"errors"
"fmt"
)

func div(a, b int) (int, error) {
if b == 0 {
return 0, errors.New("division by zero")
}

return a / b, nil
}

func main() {
fmt.Println(div(1, 1))
fmt.Println(div(1, 0))
fmt.Println(div(1, -1))
}

0 comments on commit 6c12d68

Please sign in to comment.