Skip to content

Commit

Permalink
Don't use deprecated ioutil package (#425)
Browse files Browse the repository at this point in the history
`ioutil` package is deprecated since Go 1.16.
https://pkg.go.dev/io/ioutil#pkg-overview

This fixes not to use a function of `ioutil`.
  • Loading branch information
y-yagi authored Jul 20, 2023
1 parent 3688174 commit c632d5e
Show file tree
Hide file tree
Showing 6 changed files with 13 additions and 13 deletions.
4 changes: 2 additions & 2 deletions cmd/testutils/testutils.go
Original file line number Diff line number Diff line change
Expand Up @@ -3,8 +3,8 @@ package testutils

import (
"fmt"
"io/ioutil"
"log"
"os"
"os/exec"
"path/filepath"
"strconv"
Expand Down Expand Up @@ -35,7 +35,7 @@ func ReadTests(pattern string) (map[string]TestCase, error) {
for _, file := range files {
var tests map[string]*TestCase

buf, err := ioutil.ReadFile(file)
buf, err := os.ReadFile(file)
if err != nil {
return nil, err
}
Expand Down
4 changes: 2 additions & 2 deletions database/database.go
Original file line number Diff line number Diff line change
Expand Up @@ -4,8 +4,8 @@ package database
import (
"database/sql"
"fmt"
"io/ioutil"
"log"
"os"
"strings"

"gopkg.in/yaml.v2"
Expand Down Expand Up @@ -83,7 +83,7 @@ func ParseGeneratorConfig(configFile string) GeneratorConfig {
return GeneratorConfig{}
}

buf, err := ioutil.ReadFile(configFile)
buf, err := os.ReadFile(configFile)
if err != nil {
log.Fatal(err)
}
Expand Down
4 changes: 2 additions & 2 deletions database/mssql/parser_test.go
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
package mssql

import (
"io/ioutil"
"os"
"testing"

"gopkg.in/yaml.v2"
Expand All @@ -25,7 +25,7 @@ func TestParse(t *testing.T) {
}

func readTests(file string) (map[string]string, error) {
buf, err := ioutil.ReadFile(file)
buf, err := os.ReadFile(file)
if err != nil {
return nil, err
}
Expand Down
4 changes: 2 additions & 2 deletions database/mysql/database.go
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ import (
"crypto/x509"
"database/sql"
"fmt"
"io/ioutil"
"os"
"strings"

driver "github.com/go-sql-driver/mysql"
Expand Down Expand Up @@ -174,7 +174,7 @@ func mysqlBuildDSN(config database.Config) string {

func registerTLSConfig(pemPath string) error {
rootCertPool := x509.NewCertPool()
pem, err := ioutil.ReadFile(pemPath)
pem, err := os.ReadFile(pemPath)
if err != nil {
return err
}
Expand Down
4 changes: 2 additions & 2 deletions database/postgres/parser_test.go
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
package postgres

import (
"io/ioutil"
"os"
"testing"

"github.com/k0kubun/sqldef/database"
Expand Down Expand Up @@ -46,7 +46,7 @@ type TestCase struct {
}

func readTests(file string) (map[string]TestCase, error) {
buf, err := ioutil.ReadFile(file)
buf, err := os.ReadFile(file)
if err != nil {
return nil, err
}
Expand Down
6 changes: 3 additions & 3 deletions sqldef.go
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ package sqldef

import (
"fmt"
"io/ioutil"
"io"
"log"
"os"
"strings"
Expand Down Expand Up @@ -118,9 +118,9 @@ func ReadFile(filepath string) (string, error) {
return "", fmt.Errorf("stdin is not piped")
}

buf, err = ioutil.ReadAll(os.Stdin)
buf, err = io.ReadAll(os.Stdin)
} else {
buf, err = ioutil.ReadFile(filepath)
buf, err = os.ReadFile(filepath)
}

if err != nil {
Expand Down

0 comments on commit c632d5e

Please sign in to comment.