Skip to content

Instantly share code, notes, and snippets.

@ivancorrales
Created November 24, 2019 04:59
Show Gist options
  • Save ivancorrales/252fe43be37a1ba9d8cedd3b323b0eee to your computer and use it in GitHub Desktop.
Save ivancorrales/252fe43be37a1ba9d8cedd3b323b0eee to your computer and use it in GitHub Desktop.
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