Fix Golint

This commit is contained in:
TwinProduction
2020-10-23 16:29:20 -04:00
parent 0b1f20d0de
commit 77ad91a297
66 changed files with 367 additions and 340 deletions

View File

@ -8,15 +8,15 @@ import (
)
var (
secureHttpClient *http.Client
insecureHttpClient *http.Client
secureHTTPClient *http.Client
insecureHTTPClient *http.Client
)
// GetHttpClient returns the shared HTTP client
func GetHttpClient(insecure bool) *http.Client {
// GetHTTPClient returns the shared HTTP client
func GetHTTPClient(insecure bool) *http.Client {
if insecure {
if insecureHttpClient == nil {
insecureHttpClient = &http.Client{
if insecureHTTPClient == nil {
insecureHTTPClient = &http.Client{
Timeout: time.Second * 10,
Transport: &http.Transport{
TLSClientConfig: &tls.Config{
@ -25,19 +25,18 @@ func GetHttpClient(insecure bool) *http.Client {
},
}
}
return insecureHttpClient
} else {
if secureHttpClient == nil {
secureHttpClient = &http.Client{
Timeout: time.Second * 10,
}
}
return secureHttpClient
return insecureHTTPClient
}
if secureHTTPClient == nil {
secureHTTPClient = &http.Client{
Timeout: time.Second * 10,
}
}
return secureHTTPClient
}
// CanCreateConnectionToTcpService checks whether a connection can be established with a TCP service
func CanCreateConnectionToTcpService(address string) bool {
// CanCreateConnectionToTCPService checks whether a connection can be established with a TCP service
func CanCreateConnectionToTCPService(address string) bool {
conn, err := net.DialTimeout("tcp", address, 5*time.Second)
if err != nil {
return false

View File

@ -5,24 +5,24 @@ import (
)
func TestGetHttpClient(t *testing.T) {
if secureHttpClient != nil {
t.Error("secureHttpClient should've been nil since it hasn't been called a single time yet")
if secureHTTPClient != nil {
t.Error("secureHTTPClient should've been nil since it hasn't been called a single time yet")
}
if insecureHttpClient != nil {
t.Error("insecureHttpClient should've been nil since it hasn't been called a single time yet")
if insecureHTTPClient != nil {
t.Error("insecureHTTPClient should've been nil since it hasn't been called a single time yet")
}
_ = GetHttpClient(false)
if secureHttpClient == nil {
t.Error("secureHttpClient shouldn't have been nil, since it has been called once")
_ = GetHTTPClient(false)
if secureHTTPClient == nil {
t.Error("secureHTTPClient shouldn't have been nil, since it has been called once")
}
if insecureHttpClient != nil {
t.Error("insecureHttpClient should've been nil since it hasn't been called a single time yet")
if insecureHTTPClient != nil {
t.Error("insecureHTTPClient should've been nil since it hasn't been called a single time yet")
}
_ = GetHttpClient(true)
if secureHttpClient == nil {
t.Error("secureHttpClient shouldn't have been nil, since it has been called once")
_ = GetHTTPClient(true)
if secureHTTPClient == nil {
t.Error("secureHTTPClient shouldn't have been nil, since it has been called once")
}
if insecureHttpClient == nil {
t.Error("insecureHttpClient shouldn't have been nil, since it has been called once")
if insecureHTTPClient == nil {
t.Error("insecureHTTPClient shouldn't have been nil, since it has been called once")
}
}