mirror of
https://github.com/JanDeDobbeleer/oh-my-posh.git
synced 2024-11-10 04:54:03 -08:00
fix: add timeout to http requests
this caused a serious delay on windows
This commit is contained in:
parent
5fa33f4c4f
commit
4c771d3e15
|
@ -13,6 +13,7 @@ import (
|
|||
"path/filepath"
|
||||
"runtime"
|
||||
"strings"
|
||||
"time"
|
||||
|
||||
"github.com/distatus/battery"
|
||||
"github.com/shirou/gopsutil/host"
|
||||
|
@ -264,7 +265,9 @@ func (env *environment) getShellName() string {
|
|||
}
|
||||
|
||||
func (env *environment) doGet(url string) ([]byte, error) {
|
||||
request, err := http.NewRequestWithContext(context.Background(), http.MethodGet, url, nil)
|
||||
ctx, cncl := context.WithTimeout(context.Background(), time.Millisecond*20)
|
||||
defer cncl()
|
||||
request, err := http.NewRequestWithContext(ctx, http.MethodGet, url, nil)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue