Created
November 24, 2019 04:59
-
-
Save ivancorrales/252fe43be37a1ba9d8cedd3b323b0eee 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 ( | |
"errors" | |
"fmt" | |
"time" | |
) | |
var times = map[string]float32{ | |
"very-slow": 4, | |
"slow": 3, | |
"medium": 2, | |
"fast": 1, | |
"very-fast": 0.5, | |
} | |
func myFunction(msg string, returnError bool) error { | |
fmt.Println(msg) | |
time.Sleep(time.Duration(times[msg]) * time.Second) | |
if returnError { | |
return errors.New("unexpected error") | |
} | |
return nil | |
} | |
type myType struct { | |
} | |
func (t *myType) myMethod(msg string, returnError bool) error { | |
fmt.Println(msg) | |
time.Sleep(time.Duration(times[msg]) * time.Second) | |
if returnError { | |
return errors.New("unexpected error") | |
} | |
return nil | |
} | |
func main() { | |
myFunction("very-slow", false) | |
myFunction("slow", false) | |
myFunction("normal", false) | |
myFunction("fast", false) | |
myFunction("very-fast", false) | |
myFunction("Stop testing on Animals", false) | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment