Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

chore: add go-mod file and update deprecated methods #39

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
chore: add go-mod file and update deprecated methods
yinebebt committed Nov 21, 2024
commit 9ac6b5d43ad4199abc6b28fb199ada4ed4c0dddb
4 changes: 2 additions & 2 deletions client.go
Original file line number Diff line number Diff line change
@@ -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}
12 changes: 6 additions & 6 deletions client_test.go
Original file line number Diff line number Diff line change
@@ -16,29 +16,29 @@ 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"},
},
},
{
// the headers are set (not added) thus same key values
// are replaced.
"Key1:Value1A\nKey1:Value1B",
map[string][]string{
"Key1": []string{"Value1B"},
"Key1": {"Value1B"},
},
},
{
3 changes: 3 additions & 0 deletions go.mod
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
module github.com/adjust/go-wrk

go 1.23.2
5 changes: 2 additions & 3 deletions main.go
Original file line number Diff line number Diff line change
@@ -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)
4 changes: 2 additions & 2 deletions master_node.go
Original file line number Diff line number Diff line change
@@ -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)
}