mirror of
https://github.com/JanDeDobbeleer/oh-my-posh.git
synced 2025-01-28 11:31:04 -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"
|
"path/filepath"
|
||||||
"runtime"
|
"runtime"
|
||||||
"strings"
|
"strings"
|
||||||
|
"time"
|
||||||
|
|
||||||
"github.com/distatus/battery"
|
"github.com/distatus/battery"
|
||||||
"github.com/shirou/gopsutil/host"
|
"github.com/shirou/gopsutil/host"
|
||||||
|
@ -264,7 +265,9 @@ func (env *environment) getShellName() string {
|
||||||
}
|
}
|
||||||
|
|
||||||
func (env *environment) doGet(url string) ([]byte, error) {
|
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 {
|
if err != nil {
|
||||||
return nil, err
|
return nil, err
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in a new issue