Skip to content

Commit

Permalink
Merge pull request #70 from testwill/ioutil
Browse files Browse the repository at this point in the history
chore: remove refs to deprecated io/ioutil
  • Loading branch information
nikepan authored Nov 17, 2023
2 parents 362e707 + b344027 commit 9251c58
Show file tree
Hide file tree
Showing 4 changed files with 10 additions and 11 deletions.
4 changes: 2 additions & 2 deletions clickhouse.go
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ import (
"crypto/tls"
"errors"
"fmt"
"io/ioutil"
"io"
"log"
"net/http"
"strings"
Expand Down Expand Up @@ -205,7 +205,7 @@ func (srv *ClickhouseServer) SendQuery(r *ClickhouseRequest) (response string, s
if r.isInsert && srv.LogQueries {
log.Printf("INFO: sent %+v rows to %+v of %+v\n", r.Count, srv.URL, r.Query)
}
buf, _ := ioutil.ReadAll(resp.Body)
buf, _ := io.ReadAll(resp.Body)
s := string(buf)
if resp.StatusCode >= 502 {
srv.Bad = true
Expand Down
7 changes: 3 additions & 4 deletions dump.go
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,6 @@ package main
import (
"errors"
"fmt"
"io/ioutil"
"log"
"os"
"path"
Expand Down Expand Up @@ -75,7 +74,7 @@ func (d *FileDumper) Dump(params string, content string, response string, prefix
}
d.DumpNum++
file_path := path.Join(d.Path, d.dumpName(d.DumpNum, prefix, status))
err = ioutil.WriteFile(file_path, []byte(data), 0644)
err = os.WriteFile(file_path, []byte(data), 0644)
if err != nil {
log.Printf("ERROR: dump to file: %+v\n", err)
} else {
Expand All @@ -94,7 +93,7 @@ func (d *FileDumper) GetDump() (string, error) {
return "", err
}

files, err := ioutil.ReadDir(d.Path)
files, err := os.ReadDir(d.Path)
if err != nil {
log.Fatal(err)
}
Expand All @@ -120,7 +119,7 @@ func (d *FileDumper) GetDump() (string, error) {
// GetDumpData - get dump data from filesystem
func (d *FileDumper) GetDumpData(id string) (data string, response string, err error) {
path := d.makePath(id)
s, err := ioutil.ReadFile(path)
s, err := os.ReadFile(path)
items := strings.Split(string(s), dumpResponseMark)
if len(items) > 1 {
return items[0], items[1], err
Expand Down
4 changes: 2 additions & 2 deletions server.go
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ package main

import (
"context"
"io/ioutil"
"io"
"log"
"net/http"
"os"
Expand Down Expand Up @@ -42,7 +42,7 @@ func NewServer(listen string, collector *Collector, debug bool, logQueries bool)
}

func (server *Server) writeHandler(c echo.Context) error {
q, _ := ioutil.ReadAll(c.Request().Body)
q, _ := io.ReadAll(c.Request().Body)
s := string(q)

if server.Debug {
Expand Down
6 changes: 3 additions & 3 deletions server_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ package main
import (
"context"
"fmt"
"io/ioutil"
"io"
"net/http"
"net/http/httptest"
"os"
Expand Down Expand Up @@ -90,7 +90,7 @@ func TestServer_MultiServer(t *testing.T) {

s1 := httptest.NewServer(http.HandlerFunc(func(w http.ResponseWriter, r *http.Request) {
fmt.Fprintln(w, "")
req, _ := ioutil.ReadAll(r.Body)
req, _ := io.ReadAll(r.Body)
mu.Lock()
defer mu.Unlock()
received = append(received, string(req))
Expand All @@ -99,7 +99,7 @@ func TestServer_MultiServer(t *testing.T) {

s2 := httptest.NewServer(http.HandlerFunc(func(w http.ResponseWriter, r *http.Request) {
fmt.Fprintln(w, "")
req, _ := ioutil.ReadAll(r.Body)
req, _ := io.ReadAll(r.Body)
mu.Lock()
defer mu.Unlock()
received = append(received, string(req))
Expand Down

0 comments on commit 9251c58

Please sign in to comment.