Skip to content

Commit

Permalink
chore: drop usage of deprecated io/ioutil package
Browse files Browse the repository at this point in the history
  • Loading branch information
radhus committed Sep 1, 2022
1 parent c141fcc commit 9e63a1d
Show file tree
Hide file tree
Showing 8 changed files with 14 additions and 17 deletions.
4 changes: 2 additions & 2 deletions internal/codegen/databasecodegen/goldenfile_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ package databasecodegen

import (
"fmt"
"io/ioutil"
"os"
"os/exec"
"path/filepath"
"strings"
Expand All @@ -23,7 +23,7 @@ func runGoldenFileTest(t *testing.T, name string, fn func(*spanddl.Database, *co
testdataFile := testdataFile
t.Run(fmt.Sprintf("%s/%s", name, testdataFile), func(t *testing.T) {
t.Parallel()
testdata, err := ioutil.ReadFile(testdataFile)
testdata, err := os.ReadFile(testdataFile)
assert.NilError(t, err)
ddl, err := spansql.ParseDDL(testdataFile, string(testdata))
assert.NilError(t, err)
Expand Down
4 changes: 2 additions & 2 deletions internal/codegen/descriptorcodegen/goldenfile_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ package descriptorcodegen

import (
"fmt"
"io/ioutil"
"os"
"os/exec"
"path/filepath"
"strings"
Expand All @@ -23,7 +23,7 @@ func runGoldenFileTest(t *testing.T, name string, fn func(*spanddl.Database, *co
testdataFile := testdataFile
t.Run(fmt.Sprintf("%s/%s", name, testdataFile), func(t *testing.T) {
t.Parallel()
testdata, err := ioutil.ReadFile(testdataFile)
testdata, err := os.ReadFile(testdataFile)
assert.NilError(t, err)
ddl, err := spansql.ParseDDL(testdataFile, string(testdata))
assert.NilError(t, err)
Expand Down
4 changes: 2 additions & 2 deletions internal/config/database.go
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ package config

import (
"fmt"
"io/ioutil"
"os"
"path/filepath"

"cloud.google.com/go/spanner/spansql"
Expand Down Expand Up @@ -30,7 +30,7 @@ func (c *DatabaseConfig) LoadDatabase() (*spanddl.Database, error) {
return nil, fmt.Errorf("load database %s: %w", c.Name, err)
}
for _, schemaFile := range schemaFiles {
schema, err := ioutil.ReadFile(schemaFile)
schema, err := os.ReadFile(schemaFile)
if err != nil {
return nil, fmt.Errorf("load database %s: %w", c.Name, err)
}
Expand Down
3 changes: 1 addition & 2 deletions internal/protoloader/loader.go
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,6 @@ import (
"bytes"
"encoding/base64"
"fmt"
"io/ioutil"
"os"
"os/exec"
"path/filepath"
Expand All @@ -17,7 +16,7 @@ import (
)

func LoadFilesFromGoPackage(goPackage string) (*protoregistry.Files, error) {
tmpDir, err := ioutil.TempDir(".", "protoloader*")
tmpDir, err := os.MkdirTemp(".", "protoloader*")
if err != nil {
return nil, fmt.Errorf("load proto files from Go package %s: %w", goPackage, err)
}
Expand Down
5 changes: 2 additions & 3 deletions main.go
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,6 @@ package main

import (
"flag"
"io/ioutil"
"log"
"os"
"path/filepath"
Expand Down Expand Up @@ -70,7 +69,7 @@ func main() {
if err != nil {
log.Panic(err)
}
if err := ioutil.WriteFile(filename, content, 0o600); err != nil {
if err := os.WriteFile(filename, content, 0o600); err != nil {
log.Panic(err)
}
log.Println("wrote:", filename)
Expand All @@ -86,7 +85,7 @@ func main() {
if err != nil {
log.Panic(err)
}
if err := ioutil.WriteFile(filename, content, 0o600); err != nil {
if err := os.WriteFile(filename, content, 0o600); err != nil {
log.Panic(err)
}
log.Println("wrote:", filename)
Expand Down
4 changes: 2 additions & 2 deletions spanddl/database_example_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ package spanddl_test

import (
"fmt"
"io/ioutil"
"os"
"path/filepath"

"cloud.google.com/go/spanner/spansql"
Expand All @@ -16,7 +16,7 @@ func ExampleDatabase() {
panic(err) // TODO: Handle error.
}
for _, file := range files {
fileContent, err := ioutil.ReadFile(file)
fileContent, err := os.ReadFile(file)
if err != nil {
panic(err) // TODO: Handle error.
}
Expand Down
3 changes: 1 addition & 2 deletions spantest/emulator.go
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,6 @@ import (
"encoding/base32"
"encoding/json"
"fmt"
"io/ioutil"
"net"
"os"
"os/exec"
Expand Down Expand Up @@ -131,7 +130,7 @@ func (fx *EmulatorFixture) NewDatabaseFromDDLFiles(t *testing.T, globs ...string
}
var statements []string
for _, file := range files {
content, err := ioutil.ReadFile(file)
content, err := os.ReadFile(file)
assert.NilError(t, err)
ddl, err := spansql.ParseDDL(file, string(content))
assert.NilError(t, err)
Expand Down
4 changes: 2 additions & 2 deletions spantest/inmemory.go
Original file line number Diff line number Diff line change
Expand Up @@ -3,8 +3,8 @@ package spantest
import (
"context"
"fmt"
"io/ioutil"
"math/rand"
"os"
"path/filepath"
"strconv"
"testing"
Expand Down Expand Up @@ -46,7 +46,7 @@ func (fx *InMemoryFixture) NewDatabaseFromDDLFiles(t *testing.T, globs ...string
}
var statements []string
for _, file := range files {
content, err := ioutil.ReadFile(file)
content, err := os.ReadFile(file)
assert.NilError(t, err)
ddl, err := spansql.ParseDDL(file, string(content))
assert.NilError(t, err)
Expand Down

0 comments on commit 9e63a1d

Please sign in to comment.