From 2ef1c8ccb47de30fd187cfad67748631ce2f8c25 Mon Sep 17 00:00:00 2001 From: Pulkit Kathuria Date: Tue, 12 Dec 2023 11:18:49 +0900 Subject: [PATCH 1/2] work behind proxy --- cmd/gobrew/main.go | 6 ++++++ helpers.go | 1 + 2 files changed, 7 insertions(+) diff --git a/cmd/gobrew/main.go b/cmd/gobrew/main.go index 172967e..09a0a91 100644 --- a/cmd/gobrew/main.go +++ b/cmd/gobrew/main.go @@ -142,6 +142,12 @@ func Find(slice []string, val string) (int, bool) { } func usage() string { + usageMsg := + ` +# Add gobrew to your ~/.bashrc or ~/.zshrc +export PATH="$HOME/.gobrew/current/bin:$HOME/.gobrew/bin:$PATH" +export GOROOT="$HOME/.gobrew/current/go" +` msg := ` gobrew ` + version + ` diff --git a/helpers.go b/helpers.go index 88d1ab6..e280a69 100644 --- a/helpers.go +++ b/helpers.go @@ -410,6 +410,7 @@ func (gb *GoBrew) getGolangVersions() (result []string) { func doRequest(url string) (data []byte) { client := &http.Client{ Transport: &http.Transport{ + Proxy: http.ProxyFromEnvironment, Dial: (&net.Dialer{ Timeout: 5 * time.Second, }).Dial, From 048a473a4d5de5fa97b77f1ea8988b39c8a5de2b Mon Sep 17 00:00:00 2001 From: Pulkit Kathuria Date: Tue, 12 Dec 2023 11:29:02 +0900 Subject: [PATCH 2/2] work behind proxy --- helpers.go | 13 +------------ 1 file changed, 1 insertion(+), 12 deletions(-) diff --git a/helpers.go b/helpers.go index e280a69..28561c6 100644 --- a/helpers.go +++ b/helpers.go @@ -6,7 +6,6 @@ import ( "fmt" "io" "log" - "net" "net/http" "os" "path/filepath" @@ -14,7 +13,6 @@ import ( "runtime" "sort" "strings" - "time" "github.com/Masterminds/semver" "github.com/c4milo/unpackit" @@ -408,16 +406,7 @@ func (gb *GoBrew) getGolangVersions() (result []string) { } func doRequest(url string) (data []byte) { - client := &http.Client{ - Transport: &http.Transport{ - Proxy: http.ProxyFromEnvironment, - Dial: (&net.Dialer{ - Timeout: 5 * time.Second, - }).Dial, - TLSHandshakeTimeout: 5 * time.Second, - }, - Timeout: 10 * time.Second, - } + client := &http.Client{} request, err := http.NewRequest("GET", url, nil) utils.CheckError(err, "==> [Error] Cannot create request")