Last active
September 18, 2021 17:21
-
-
Save agusrichard/b352ee63086b28c82c901b4b592be6a2 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| package main | |
| import ( | |
| "fmt" | |
| "math/rand" | |
| "time" | |
| ) | |
| func Calculate(x, y int64) int64 { | |
| // get random integer between 0 and 100 | |
| n := rand.Intn(100) | |
| // sleep for a random duration between 0 and 100 milliseconds | |
| time.Sleep(time.Duration(n) * time.Millisecond) | |
| return x + y | |
| } | |
| func main() { | |
| fmt.Println(Calculate(1, 2)) | |
| } |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment