From e28285b9cee9652f1e50527847697b29463f17fd Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=C5=81ukasz=20Mierzwa?= Date: Fri, 13 Jan 2023 13:03:03 +0000 Subject: [PATCH] Fix panics with basic auth Fixes #449 --- cmd/kthxbye/am.go | 4 ++-- go.mod | 2 +- tools/golangci-lint/go.mod | 2 +- 3 files changed, 4 insertions(+), 4 deletions(-) diff --git a/cmd/kthxbye/am.go b/cmd/kthxbye/am.go index d880579..3492da6 100644 --- a/cmd/kthxbye/am.go +++ b/cmd/kthxbye/am.go @@ -27,10 +27,10 @@ func (art *authRoundTripper) RoundTrip(r *http.Request) (*http.Response, error) } func newAMClient(uri string) http.Client { - client := http.Client{} + client := http.Client{Transport: http.DefaultTransport} u, _ := url.Parse(uri) - if u.User.Username() != "" { + if u.User != nil && u.User.Username() != "" { username := u.User.Username() password, _ := u.User.Password() client.Transport = setAuth(client.Transport, username, password) diff --git a/go.mod b/go.mod index ac028b4..3ab9e71 100644 --- a/go.mod +++ b/go.mod @@ -1,6 +1,6 @@ module github.com/prymitive/kthxbye -go 1.18 +go 1.19 require ( github.com/prometheus/client_golang v1.14.0 diff --git a/tools/golangci-lint/go.mod b/tools/golangci-lint/go.mod index 73a5427..57412f1 100644 --- a/tools/golangci-lint/go.mod +++ b/tools/golangci-lint/go.mod @@ -1,6 +1,6 @@ module _ -go 1.18 +go 1.19 require github.com/golangci/golangci-lint v1.50.1