| 50 | } |
| 51 | |
| 52 | func WaitForServer(url string, timeout time.Duration) error { |
| 53 | ctx, cancelFunc := context.WithTimeout(context.Background(), timeout) |
| 54 | defer cancelFunc() |
| 55 | for { |
| 56 | select { |
| 57 | case <-ctx.Done(): |
| 58 | return errors.New("reach server timed out: " + url) |
| 59 | default: |
| 60 | if _, err := http.Get(url); err == nil { |
| 61 | return nil |
| 62 | } |
| 63 | time.Sleep(100 * time.Millisecond) |
| 64 | } |
| 65 | } |
| 66 | } |
| 67 | |
| 68 | // Just like os.ReadDir but ignores hidden files starting with '.' such as macOS '.DS_Store'. |
| 69 | func RemoveHiddenDirs(dirs []os.DirEntry) []os.DirEntry { |