diff options
author | Oleksandr Redko <oleksandr.red+github@gmail.com> | 2023-02-19 00:43:26 +0200 |
---|---|---|
committer | Bjørn Erik Pedersen <bjorn.erik.pedersen@gmail.com> | 2023-03-01 16:28:43 +0100 |
commit | d453c12742e992d672fcf3e61b7a5ed35391c4b0 (patch) | |
tree | 1299a1f5a44bda1cf6449a8257f393350b2cc012 /common | |
parent | 97b010f521e592b5fc29daace225476b64543643 (diff) |
Replace deprecated ioutil with io and os
https://pkg.go.dev/io/ioutil is deprecated since Go 1.16.
Diffstat (limited to 'common')
-rw-r--r-- | common/herrors/error_locator.go | 3 | ||||
-rw-r--r-- | common/hugio/writers.go | 5 | ||||
-rw-r--r-- | common/loggers/loggers.go | 9 |
3 files changed, 7 insertions, 10 deletions
diff --git a/common/herrors/error_locator.go b/common/herrors/error_locator.go index 18c21e51b..c7e2d2f06 100644 --- a/common/herrors/error_locator.go +++ b/common/herrors/error_locator.go @@ -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 } diff --git a/common/hugio/writers.go b/common/hugio/writers.go index e600c1ebb..729b21715 100644 --- a/common/hugio/writers.go +++ b/common/hugio/writers.go @@ -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), } } diff --git a/common/loggers/loggers.go b/common/loggers/loggers.go index 308635fe9..2c331352a 100644 --- a/common/loggers/loggers.go +++ b/common/loggers/loggers.go @@ -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} } |