Skip to content

Instantly share code, notes, and snippets.

@agusrichard
Last active September 18, 2021 17:21
Show Gist options
  • Select an option

  • Save agusrichard/b352ee63086b28c82c901b4b592be6a2 to your computer and use it in GitHub Desktop.

Select an option

Save agusrichard/b352ee63086b28c82c901b4b592be6a2 to your computer and use it in GitHub Desktop.
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