(ctx context.Context, results <-chan *compileUpdateNotification, timeout time.Duration)
| 130 | } |
| 131 | |
| 132 | func waitForCompileUpdateNotification(ctx context.Context, results <-chan *compileUpdateNotification, timeout time.Duration) *compileUpdateNotification { |
| 133 | if results == nil { |
| 134 | return nil |
| 135 | } |
| 136 | |
| 137 | if timeout <= 0 { |
| 138 | select { |
| 139 | case result, ok := <-results: |
| 140 | if !ok { |
| 141 | return nil |
| 142 | } |
| 143 | return result |
| 144 | default: |
| 145 | return nil |
| 146 | } |
| 147 | } |
| 148 | |
| 149 | timer := time.NewTimer(timeout) |
| 150 | defer timer.Stop() |
| 151 | |
| 152 | select { |
| 153 | case result, ok := <-results: |
| 154 | if !ok { |
| 155 | return nil |
| 156 | } |
| 157 | return result |
| 158 | case <-timer.C: |
| 159 | return nil |
| 160 | case <-ctx.Done(): |
| 161 | return nil |
| 162 | } |
| 163 | } |
| 164 | |
| 165 | func runCompileUpdateCheck(ctx context.Context, client *http.Client) (*compileUpdateNotification, error) { |
| 166 | currentVersion := GetVersion() |
no test coverage detected