diff options
Diffstat (limited to 'cmd')
-rw-r--r-- | cmd/generate/httpcache.go | 8 |
1 files changed, 8 insertions, 0 deletions
diff --git a/cmd/generate/httpcache.go b/cmd/generate/httpcache.go index 7debd0a..87d2fb5 100644 --- a/cmd/generate/httpcache.go +++ b/cmd/generate/httpcache.go @@ -10,17 +10,25 @@ import ( var httpCache = map[string]string{} func httpGet(u string) (string, error) { + if cache, ok := httpCache[u]; ok { + return cache, nil + } + fmt.Printf("GET %q...", u) resp, err := http.Get(u) if err != nil { + fmt.Printf(" err\n") return "", err } if resp.StatusCode != http.StatusOK { + fmt.Printf(" err\n") return "", fmt.Errorf("unexpected HTTP status: %v", resp.Status) } bs, err := io.ReadAll(resp.Body) if err != nil { + fmt.Printf(" err\n") return "", err } + fmt.Printf(" ok\n") httpCache[u] = string(bs) return httpCache[u], nil } |