Replace deprecated ioutil with io and os

https://pkg.go.dev/io/ioutil is deprecated since Go 1.16.
This commit is contained in:
Oleksandr Redko
2023-02-19 00:43:26 +02:00
committed by Bjørn Erik Pedersen
parent 97b010f521
commit d453c12742
36 changed files with 112 additions and 191 deletions

View File

@@ -16,7 +16,6 @@ package herrors
import (
"io"
"io/ioutil"
"path/filepath"
"strings"
@@ -114,7 +113,7 @@ func locateError(r io.Reader, le FileError, matches LineMatcherFn) *ErrorContext
ectx := &ErrorContext{LinesPos: -1, Position: text.Position{Offset: -1}}
b, err := ioutil.ReadAll(r)
b, err := io.ReadAll(r)
if err != nil {
return ectx
}

View File

@@ -15,7 +15,6 @@ package hugio
import (
"io"
"io/ioutil"
)
// As implemented by strings.Builder.
@@ -63,7 +62,7 @@ func ToWriteCloser(w io.Writer) io.WriteCloser {
io.Closer
}{
w,
ioutil.NopCloser(nil),
io.NopCloser(nil),
}
}
@@ -79,6 +78,6 @@ func ToReadCloser(r io.Reader) io.ReadCloser {
io.Closer
}{
r,
ioutil.NopCloser(nil),
io.NopCloser(nil),
}
}

View File

@@ -17,7 +17,6 @@ import (
"bytes"
"fmt"
"io"
"io/ioutil"
"log"
"os"
"regexp"
@@ -92,7 +91,7 @@ type logger struct {
*jww.Notepad
// The writer that represents stdout.
// Will be ioutil.Discard when in quiet mode.
// Will be io.Discard when in quiet mode.
out io.Writer
logCounters *LogCounters
@@ -232,12 +231,12 @@ func NewErrorLogger() Logger {
// NewBasicLogger creates a new basic logger writing to Stdout.
func NewBasicLogger(t jww.Threshold) Logger {
return newLogger(t, jww.LevelError, os.Stdout, ioutil.Discard, false)
return newLogger(t, jww.LevelError, os.Stdout, io.Discard, false)
}
// NewBasicLoggerForWriter creates a new basic logger writing to w.
func NewBasicLoggerForWriter(t jww.Threshold, w io.Writer) Logger {
return newLogger(t, jww.LevelError, w, ioutil.Discard, false)
return newLogger(t, jww.LevelError, w, io.Discard, false)
}
// RemoveANSIColours removes all ANSI colours from the given string.
@@ -291,7 +290,7 @@ func InitGlobalLogger(stdoutThreshold, logThreshold jww.Threshold, outHandle, lo
func getLogWriters(outHandle, logHandle io.Writer) (io.Writer, io.Writer) {
isTerm := terminal.PrintANSIColors(os.Stdout)
if logHandle != ioutil.Discard && isTerm {
if logHandle != io.Discard && isTerm {
// Remove any Ansi coloring from log output
logHandle = ansiCleaner{w: logHandle}
}