From 3e558ac2e3ed1d282d590564233b376a46cd09c1 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Manuel=20R=C3=BCger?= Date: Tue, 3 Jan 2023 18:54:04 +0100 Subject: [PATCH] Replace deprecated io/ioutils (#230) --- Dockerfile | 1 - auth.go | 6 +++--- main.go | 3 +-- pkg/confluence/api.go | 3 +-- pkg/mark/attachment.go | 4 ++-- pkg/mark/includes/templates.go | 9 +++++---- pkg/mark/link.go | 3 +-- pkg/mark/markdown_test.go | 8 ++++---- 8 files changed, 17 insertions(+), 20 deletions(-) diff --git a/Dockerfile b/Dockerfile index f5d8f23..478388f 100644 --- a/Dockerfile +++ b/Dockerfile @@ -8,5 +8,4 @@ RUN make build FROM alpine:latest RUN apk --no-cache add ca-certificates bash git COPY --from=0 /go/src/github.com/kovetskiy/mark/mark /bin/ -RUN mkdir -p /docs WORKDIR /docs diff --git a/auth.go b/auth.go index 8731ab4..d45eb1f 100644 --- a/auth.go +++ b/auth.go @@ -2,7 +2,7 @@ package main import ( "errors" - "io/ioutil" + "io" "net/url" "os" "strings" @@ -36,7 +36,7 @@ func GetCredentials( if password == "" { password = config.Password if password == "" { - if ! flags.CompileOnly { + if !flags.CompileOnly { return nil, errors.New( "Confluence password should be specified using -p " + "flag or be stored in configuration file", @@ -47,7 +47,7 @@ func GetCredentials( } if password == "-" { - stdin, err := ioutil.ReadAll(os.Stdin) + stdin, err := io.ReadAll(os.Stdin) if err != nil { return nil, karma.Format( err, diff --git a/main.go b/main.go index fe6418a..7dfb1ae 100644 --- a/main.go +++ b/main.go @@ -3,7 +3,6 @@ package main import ( "bytes" "fmt" - "io/ioutil" "os" "path/filepath" "time" @@ -175,7 +174,7 @@ func processFile( pageID string, username string, ) *confluence.PageInfo { - markdown, err := ioutil.ReadFile(file) + markdown, err := os.ReadFile(file) if err != nil { log.Fatal(err) } diff --git a/pkg/confluence/api.go b/pkg/confluence/api.go index 462d12d..f5465d6 100644 --- a/pkg/confluence/api.go +++ b/pkg/confluence/api.go @@ -6,7 +6,6 @@ import ( "errors" "fmt" "io" - "io/ioutil" "mime/multipart" "net/http" "os" @@ -727,7 +726,7 @@ func newErrorStatusNotOK(request *gopencils.Resource) error { ) } - output, _ := ioutil.ReadAll(request.Raw.Body) + output, _ := io.ReadAll(request.Raw.Body) defer request.Raw.Body.Close() return fmt.Errorf( diff --git a/pkg/mark/attachment.go b/pkg/mark/attachment.go index d2db8da..ef670d2 100644 --- a/pkg/mark/attachment.go +++ b/pkg/mark/attachment.go @@ -42,7 +42,7 @@ func ResolveAttachments( return nil, err } - for i, _ := range attaches { + for i := range attaches { checksum, err := getChecksum(attaches[i].Path) if err != nil { return nil, karma.Format( @@ -147,7 +147,7 @@ func ResolveAttachments( updating[i] = attach } - for i, _ := range existing { + for i := range existing { log.Infof(nil, "keeping unmodified attachment: %q", attaches[i].Name) } diff --git a/pkg/mark/includes/templates.go b/pkg/mark/includes/templates.go index 6fac980..3cb4905 100644 --- a/pkg/mark/includes/templates.go +++ b/pkg/mark/includes/templates.go @@ -3,7 +3,7 @@ package includes import ( "bytes" "fmt" - "io/ioutil" + "os" "path/filepath" "regexp" "strings" @@ -16,8 +16,9 @@ import ( ) // +// +// (Delims: (none | "",""))? +// --> var reIncludeDirective = regexp.MustCompile( `(?s)` + `