Skip to content

Commit

Permalink
ioutil deprecated as of go 1.16. use io.Discard instead.
Browse files Browse the repository at this point in the history
  • Loading branch information
dropwhile committed Aug 16, 2023
1 parent 6d12b0a commit 9a7b05d
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 14 deletions.
18 changes: 9 additions & 9 deletions formatwriter_json_bench_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -5,12 +5,12 @@
package mlog

import (
"io/ioutil"
"io"
"testing"
)

func BenchmarkFormatWriterJSONBase(b *testing.B) {
logger := New(ioutil.Discard, 0)
logger := New(io.Discard, 0)
logWriter := &FormatWriterJSON{}
b.ResetTimer()
for i := 0; i < b.N; i++ {
Expand All @@ -19,7 +19,7 @@ func BenchmarkFormatWriterJSONBase(b *testing.B) {
}

func BenchmarkFormatWriterJSONStd(b *testing.B) {
logger := New(ioutil.Discard, Lstd)
logger := New(io.Discard, Lstd)
logWriter := &FormatWriterJSON{}
b.ResetTimer()
for i := 0; i < b.N; i++ {
Expand All @@ -28,7 +28,7 @@ func BenchmarkFormatWriterJSONStd(b *testing.B) {
}

func BenchmarkFormatWriterJSONTime(b *testing.B) {
logger := New(ioutil.Discard, Ltimestamp)
logger := New(io.Discard, Ltimestamp)
logWriter := &FormatWriterJSON{}
b.ResetTimer()
for i := 0; i < b.N; i++ {
Expand All @@ -37,7 +37,7 @@ func BenchmarkFormatWriterJSONTime(b *testing.B) {
}

func BenchmarkFormatWriterJSONTimeTAI64N(b *testing.B) {
logger := New(ioutil.Discard, Ltai64n)
logger := New(io.Discard, Ltai64n)
logWriter := &FormatWriterJSON{}
b.ResetTimer()
for i := 0; i < b.N; i++ {
Expand All @@ -46,7 +46,7 @@ func BenchmarkFormatWriterJSONTimeTAI64N(b *testing.B) {
}

func BenchmarkFormatWriterJSONShortfile(b *testing.B) {
logger := New(ioutil.Discard, Lshortfile)
logger := New(io.Discard, Lshortfile)
logWriter := &FormatWriterJSON{}
b.ResetTimer()
for i := 0; i < b.N; i++ {
Expand All @@ -55,7 +55,7 @@ func BenchmarkFormatWriterJSONShortfile(b *testing.B) {
}

func BenchmarkFormatWriterJSONLongfile(b *testing.B) {
logger := New(ioutil.Discard, Llongfile)
logger := New(io.Discard, Llongfile)
logWriter := &FormatWriterJSON{}
b.ResetTimer()
for i := 0; i < b.N; i++ {
Expand All @@ -64,7 +64,7 @@ func BenchmarkFormatWriterJSONLongfile(b *testing.B) {
}

func BenchmarkFormatWriterJSONMap(b *testing.B) {
logger := New(ioutil.Discard, 0)
logger := New(io.Discard, 0)
logWriter := &FormatWriterJSON{}
m := Map{"x": 42}
b.ResetTimer()
Expand All @@ -74,7 +74,7 @@ func BenchmarkFormatWriterJSONMap(b *testing.B) {
}

func BenchmarkFormatWriterJSONHugeMap(b *testing.B) {
logger := New(ioutil.Discard, 0)
logger := New(io.Discard, 0)
logWriter := &FormatWriterJSON{}
m := Map{}
for i := 1; i <= 100; i++ {
Expand Down
5 changes: 0 additions & 5 deletions formatwriter_json_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -13,11 +13,6 @@ import (
is "gotest.tools/v3/assert/cmp"
)

func testEncodeString(e byteSliceWriter, s string) {
encoder := json.NewEncoder(e)
encoder.Encode(s)
}

func TestFormatWriterJSONEncodeString(t *testing.T) {
var jsonStringTests = map[string]string{
"generic": `test`,
Expand Down

0 comments on commit 9a7b05d

Please sign in to comment.