github.com/emc-advanced-dev/unik@v0.0.0-20190717152701-a58d3e8e33b7/pkg/util/retry.go (about) 1 package util 2 3 import ( 4 "time" 5 ) 6 7 func Retry(retries int, sleep time.Duration, action func() error) error { 8 if err := action(); err != nil { 9 if retries < 1 { 10 return err 11 } 12 time.Sleep(sleep) 13 return Retry(retries-1, sleep, action) 14 } 15 return nil 16 }