From 9ac6b5d43ad4199abc6b28fb199ada4ed4c0dddb Mon Sep 17 00:00:00 2001 From: yinebebt Date: Thu, 21 Nov 2024 03:01:44 +0300 Subject: [PATCH] chore: add go-mod file and update deprecated methods --- client.go | 4 ++-- client_test.go | 12 ++++++------ go.mod | 3 +++ main.go | 5 ++--- master_node.go | 4 ++-- 5 files changed, 15 insertions(+), 13 deletions(-) create mode 100644 go.mod diff --git a/client.go b/client.go index 1e52c4f..683495b 100644 --- a/client.go +++ b/client.go @@ -7,6 +7,7 @@ import ( "log" "net/http" "net/url" + "os" "strings" "sync" ) @@ -32,7 +33,7 @@ func StartClient(url_, heads, requestBody string, meth string, dka bool, respons } // Load CA cert - caCert, err := ioutil.ReadFile(*caFile) + caCert, err := os.ReadFile(*caFile) if err != nil { log.Fatal(err) } @@ -44,7 +45,6 @@ func StartClient(url_, heads, requestBody string, meth string, dka bool, respons Certificates: []tls.Certificate{cert}, RootCAs: caCertPool, } - tlsConfig.BuildNameToCertificate() } tr = &http.Transport{TLSClientConfig: tlsConfig, DisableKeepAlives: dka} diff --git a/client_test.go b/client_test.go index ece5821..face2b9 100644 --- a/client_test.go +++ b/client_test.go @@ -16,21 +16,21 @@ func TestBuildHeaders(t *testing.T) { { "User-Agent:go-wrk 0.1 bechmark\nContent-Type:text/html;", map[string][]string{ - "User-Agent": []string{"go-wrk 0.1 bechmark"}, - "Content-Type": []string{"text/html;"}, + "User-Agent": {"go-wrk 0.1 bechmark"}, + "Content-Type": {"text/html;"}, }, }, { "Key:Value", map[string][]string{ - "Key": []string{"Value"}, + "Key": {"Value"}, }, }, { "Key1:Value1\nKey2:Value2", map[string][]string{ - "Key1": []string{"Value1"}, - "Key2": []string{"Value2"}, + "Key1": {"Value1"}, + "Key2": {"Value2"}, }, }, { @@ -38,7 +38,7 @@ func TestBuildHeaders(t *testing.T) { // are replaced. "Key1:Value1A\nKey1:Value1B", map[string][]string{ - "Key1": []string{"Value1B"}, + "Key1": {"Value1B"}, }, }, { diff --git a/go.mod b/go.mod new file mode 100644 index 0000000..4c98ba0 --- /dev/null +++ b/go.mod @@ -0,0 +1,3 @@ +module github.com/adjust/go-wrk + +go 1.23.2 diff --git a/main.go b/main.go index 85680c8..1908c94 100644 --- a/main.go +++ b/main.go @@ -4,7 +4,6 @@ import ( "encoding/json" "flag" "fmt" - "io/ioutil" "os" "runtime" ) @@ -45,7 +44,7 @@ func init() { } func readConfig() { - configData, err := ioutil.ReadFile(*configFile) + configData, err := os.ReadFile(*configFile) if err != nil { fmt.Println(err) panic(err) @@ -68,7 +67,7 @@ func setRequestBody() { } // requestBodyFile has been setup - data, err := ioutil.ReadFile(*requestBodyFile) + data, err := os.ReadFile(*requestBodyFile) if err != nil { fmt.Println(err) panic(err) diff --git a/master_node.go b/master_node.go index 3d15131..257a07a 100644 --- a/master_node.go +++ b/master_node.go @@ -2,7 +2,7 @@ package main import ( "fmt" - "io/ioutil" + "io" "net/http" "net/url" "sync" @@ -38,7 +38,7 @@ func runChild(distChan chan string, wg *sync.WaitGroup, node string) { return } defer resp.Body.Close() - body, err := ioutil.ReadAll(resp.Body) + body, err := io.ReadAll(resp.Body) if err != nil { fmt.Println(err) }