feat: cache http client

main
sudo pacman -Syu 2024-07-10 10:12:55 +07:00
parent 9c4aa6b7f3
commit b2034c8360
1 changed files with 3 additions and 1 deletions

View File

@ -197,6 +197,8 @@ func (c *cfg) Download(appNames ...string) error {
URL: p.URL, URL: p.URL,
} }
httpClient := &http.Client{}
eg.Go(func() error { eg.Go(func() error {
if c.isDryRun { if c.isDryRun {
fmt.Printf("Download [%s] -> [%s]\n", p.URL, p.Internal) fmt.Printf("Download [%s] -> [%s]\n", p.URL, p.Internal)
@ -204,7 +206,7 @@ func (c *cfg) Download(appNames ...string) error {
} }
// nolint:noctx,gosec // nolint:noctx,gosec
httpRsp, err := http.Get(p.URL) httpRsp, err := httpClient.Get(p.URL)
if err != nil { if err != nil {
return fmt.Errorf("http client: failed to get: %w", err) return fmt.Errorf("http client: failed to get: %w", err)
} }