Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix deprecation warning #5

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
10 changes: 5 additions & 5 deletions cmd/gofmtmd/main.go
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ package main

import (
"fmt"
"io/ioutil"
"io"
"log"
"os"

Expand All @@ -28,9 +28,9 @@ var rootCmd = &cobra.Command{
var md []byte
var err error
if filename != "" {
md, err = ioutil.ReadFile(filename)
md, err = os.ReadFile(filename)
} else {
md, err = ioutil.ReadAll(os.Stdin)
md, err = io.ReadAll(os.Stdin)
}
if err != nil {
log.Fatalf("[gofmtmd] failed to read bytes from %v: %v", filename, err)
Expand All @@ -42,15 +42,15 @@ var rootCmd = &cobra.Command{

if filename != "" {
if replace {
err = ioutil.WriteFile(filename, out, 0644)
err = os.WriteFile(filename, out, 0644)
if err != nil {
log.Fatalf("[gofmtmd] failed to writes to %v: %v", filename, err)
}
return
}
}
if outputfile != "" {
err := ioutil.WriteFile(outputfile, out, 0644)
err := os.WriteFile(outputfile, out, 0644)
if err != nil {
log.Fatalf("[gofmtmd] failed to writes to %v: %v", outputfile, err)
}
Expand Down
6 changes: 3 additions & 3 deletions gofmtmd_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ package gofmtmd_test
import (
"bytes"
"fmt"
"io/ioutil"
"os"
"testing"

"github.com/po3rin/gofmtmd"
Expand Down Expand Up @@ -32,11 +32,11 @@ func TestFmtGoCodeInMarkdown(t *testing.T) {
tt := tt
t.Run(tt.name, func(t *testing.T) {
t.Parallel()
md, err := ioutil.ReadFile(tt.inputfile)
md, err := os.ReadFile(tt.inputfile)
if err != nil {
t.Fatalf("failed to read bytes from %v: ", tt.inputfile)
}
want, err := ioutil.ReadFile(tt.goldenfile)
want, err := os.ReadFile(tt.goldenfile)
if err != nil {
t.Fatalf("failed to read bytes from %v: ", tt.inputfile)
}
Expand Down