Skip to content

Commit

Permalink
Replace deprecated io/ioutils (#230)
Browse files Browse the repository at this point in the history
  • Loading branch information
mrueg authored Jan 3, 2023
1 parent f4bbbb1 commit 3e558ac
Show file tree
Hide file tree
Showing 8 changed files with 17 additions and 20 deletions.
1 change: 0 additions & 1 deletion Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -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
6 changes: 3 additions & 3 deletions auth.go
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ package main

import (
"errors"
"io/ioutil"
"io"
"net/url"
"os"
"strings"
Expand Down Expand Up @@ -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",
Expand All @@ -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,
Expand Down
3 changes: 1 addition & 2 deletions main.go
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,6 @@ package main
import (
"bytes"
"fmt"
"io/ioutil"
"os"
"path/filepath"
"time"
Expand Down Expand Up @@ -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)
}
Expand Down
3 changes: 1 addition & 2 deletions pkg/confluence/api.go
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,6 @@ import (
"errors"
"fmt"
"io"
"io/ioutil"
"mime/multipart"
"net/http"
"os"
Expand Down Expand Up @@ -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(
Expand Down
4 changes: 2 additions & 2 deletions pkg/mark/attachment.go
Original file line number Diff line number Diff line change
Expand Up @@ -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(
Expand Down Expand Up @@ -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)
}

Expand Down
9 changes: 5 additions & 4 deletions pkg/mark/includes/templates.go
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ package includes
import (
"bytes"
"fmt"
"io/ioutil"
"os"
"path/filepath"
"regexp"
"strings"
Expand All @@ -16,8 +16,9 @@ import (
)

// <!-- Include: <template path>
// (Delims: (none | "<left>","<right>"))?
// <optional yaml data> -->
//
// (Delims: (none | "<left>","<right>"))?
// <optional yaml data> -->
var reIncludeDirective = regexp.MustCompile(
`(?s)` +
`<!--\s*Include:\s*(?P<template>.+?)\s*` +
Expand All @@ -43,7 +44,7 @@ func LoadTemplate(

var body []byte

body, err := ioutil.ReadFile(filepath.Join(base, path))
body, err := os.ReadFile(filepath.Join(base, path))
if err != nil {
err = facts.Format(
err,
Expand Down
3 changes: 1 addition & 2 deletions pkg/mark/link.go
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,6 @@ package mark
import (
"bytes"
"fmt"
"io/ioutil"
"net/url"
"os"
"path/filepath"
Expand Down Expand Up @@ -80,7 +79,7 @@ func resolveLink(
return "", nil
}

linkContents, err := ioutil.ReadFile(filepath)
linkContents, err := os.ReadFile(filepath)
if err != nil {
return "", karma.Format(err, "read file: %s", filepath)
}
Expand Down
8 changes: 4 additions & 4 deletions pkg/mark/markdown_test.go
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
package mark

import (
"io/ioutil"
"os"
"path/filepath"
"strings"
"testing"
Expand Down Expand Up @@ -31,11 +31,11 @@ func TestCompileMarkdown(t *testing.T) {
testname := strings.TrimSuffix(basename, ".md")
htmlname := filepath.Join(filepath.Dir(filename), testname+".html")

markdown, err := ioutil.ReadFile(filename)
markdown, err := os.ReadFile(filename)
if err != nil {
panic(err)
}
html, err := ioutil.ReadFile(htmlname)
html, err := os.ReadFile(htmlname)
if err != nil {
panic(err)
}
Expand All @@ -52,7 +52,7 @@ func TestCompileMarkdown(t *testing.T) {
func TestExtractDocumentLeadingH1(t *testing.T) {
filename := "testdata/header.md"

markdown, err := ioutil.ReadFile(filename)
markdown, err := os.ReadFile(filename)
if err != nil {
panic(err)
}
Expand Down

0 comments on commit 3e558ac

Please sign in to comment.