Skip to content

Commit

Permalink
upgrade golang to 1.17 and replace iouitl with io and os (etcd-io#297)
Browse files Browse the repository at this point in the history
  • Loading branch information
ahrtr authored Jan 30, 2022
1 parent 7d9f2ec commit d5db64b
Show file tree
Hide file tree
Showing 18 changed files with 24 additions and 15 deletions.
1 change: 1 addition & 0 deletions bolt_arm64.go
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
//go:build arm64
// +build arm64

package bbolt
Expand Down
1 change: 1 addition & 0 deletions bolt_mips64x.go
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
//go:build mips64 || mips64le
// +build mips64 mips64le

package bbolt
Expand Down
1 change: 1 addition & 0 deletions bolt_mipsx.go
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
//go:build mips || mipsle
// +build mips mipsle

package bbolt
Expand Down
1 change: 1 addition & 0 deletions bolt_ppc.go
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
//go:build ppc
// +build ppc

package bbolt
Expand Down
1 change: 1 addition & 0 deletions bolt_ppc64.go
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
//go:build ppc64
// +build ppc64

package bbolt
Expand Down
1 change: 1 addition & 0 deletions bolt_ppc64le.go
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
//go:build ppc64le
// +build ppc64le

package bbolt
Expand Down
1 change: 1 addition & 0 deletions bolt_riscv64.go
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
//go:build riscv64
// +build riscv64

package bbolt
Expand Down
1 change: 1 addition & 0 deletions bolt_s390x.go
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
//go:build s390x
// +build s390x

package bbolt
Expand Down
1 change: 1 addition & 0 deletions bolt_unix.go
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
//go:build !windows && !plan9 && !solaris && !aix
// +build !windows,!plan9,!solaris,!aix

package bbolt
Expand Down
1 change: 1 addition & 0 deletions bolt_unix_aix.go
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
//go:build aix
// +build aix

package bbolt
Expand Down
1 change: 1 addition & 0 deletions boltsync_unix.go
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
//go:build !windows && !plan9 && !linux && !openbsd
// +build !windows,!plan9,!linux,!openbsd

package bbolt
Expand Down
5 changes: 2 additions & 3 deletions cmd/bbolt/main.go
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,6 @@ import (
"flag"
"fmt"
"io"
"io/ioutil"
"math/rand"
"os"
"runtime"
Expand Down Expand Up @@ -1364,7 +1363,7 @@ func (cmd *BenchCommand) ParseFlags(args []string) (*BenchOptions, error) {

// Generate temp path if one is not passed in.
if options.Path == "" {
f, err := ioutil.TempFile("", "bolt-bench-")
f, err := os.CreateTemp("", "bolt-bench-")
if err != nil {
return nil, fmt.Errorf("temp file: %s", err)
}
Expand Down Expand Up @@ -1951,7 +1950,7 @@ func newCompactCommand(m *Main) *CompactCommand {
func (cmd *CompactCommand) Run(args ...string) (err error) {
// Parse flags.
fs := flag.NewFlagSet("", flag.ContinueOnError)
fs.SetOutput(ioutil.Discard)
fs.SetOutput(io.Discard)
fs.StringVar(&cmd.DstPath, "o", "", "")
fs.Int64Var(&cmd.TxMaxSize, "tx-max-size", 65536, "")
if err := fs.Parse(args); err == flag.ErrHelp {
Expand Down
3 changes: 1 addition & 2 deletions cmd/bbolt/main_test
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,6 @@ import (
"encoding/binary"
"fmt"
"io"
"io/ioutil"
"math/rand"
"os"
"strconv"
Expand Down Expand Up @@ -265,7 +264,7 @@ func NewMain() *Main {
// MustOpen creates a Bolt database in a temporary location.
func MustOpen(mode os.FileMode, options *bolt.Options) *DB {
// Create temporary path.
f, _ := ioutil.TempFile("", "bolt-")
f, _ := os.CreateTemp("", "bolt-")
f.Close()
os.Remove(f.Name())

Expand Down
13 changes: 6 additions & 7 deletions db_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,6 @@ import (
"flag"
"fmt"
"hash/fnv"
"io/ioutil"
"log"
"math/rand"
"os"
Expand Down Expand Up @@ -158,7 +157,7 @@ func TestOpen_ErrVersionMismatch(t *testing.T) {
}

// Read data file.
buf, err := ioutil.ReadFile(path)
buf, err := os.ReadFile(path)
if err != nil {
t.Fatal(err)
}
Expand All @@ -168,7 +167,7 @@ func TestOpen_ErrVersionMismatch(t *testing.T) {
meta0.version++
meta1 := (*meta)(unsafe.Pointer(&buf[pageSize+pageHeaderSize]))
meta1.version++
if err := ioutil.WriteFile(path, buf, 0666); err != nil {
if err := os.WriteFile(path, buf, 0666); err != nil {
t.Fatal(err)
}

Expand All @@ -195,7 +194,7 @@ func TestOpen_ErrChecksum(t *testing.T) {
}

// Read data file.
buf, err := ioutil.ReadFile(path)
buf, err := os.ReadFile(path)
if err != nil {
t.Fatal(err)
}
Expand All @@ -205,7 +204,7 @@ func TestOpen_ErrChecksum(t *testing.T) {
meta0.pgid++
meta1 := (*meta)(unsafe.Pointer(&buf[pageSize+pageHeaderSize]))
meta1.pgid++
if err := ioutil.WriteFile(path, buf, 0666); err != nil {
if err := os.WriteFile(path, buf, 0666); err != nil {
t.Fatal(err)
}

Expand Down Expand Up @@ -643,7 +642,7 @@ func TestDB_Concurrent_WriteTo(t *testing.T) {
wg.Add(wtxs * rtxs)
f := func(tx *bolt.Tx) {
defer wg.Done()
f, err := ioutil.TempFile("", "bolt-")
f, err := os.CreateTemp("", "bolt-")
if err != nil {
panic(err)
}
Expand Down Expand Up @@ -1747,7 +1746,7 @@ func (db *DB) CopyTempFile() {

// tempfile returns a temporary file path.
func tempfile() string {
f, err := ioutil.TempFile("", "bolt-")
f, err := os.CreateTemp("", "bolt-")
if err != nil {
panic(err)
}
Expand Down
2 changes: 1 addition & 1 deletion go.mod
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
module go.etcd.io/bbolt

go 1.12
go 1.17

require golang.org/x/sys v0.0.0-20200923182605-d9f96fdee20d
3 changes: 1 addition & 2 deletions manydbs_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,6 @@ package bbolt

import (
"fmt"
"io/ioutil"
"math/rand"
"os"
"path/filepath"
Expand All @@ -12,7 +11,7 @@ import (
func createDb(t *testing.T) (*DB, func()) {
// First, create a temporary directory to be used for the duration of
// this test.
tempDirName, err := ioutil.TempDir("", "bboltmemtest")
tempDirName, err := os.MkdirTemp("", "bboltmemtest")
if err != nil {
t.Fatalf("error creating temp dir: %v", err)
}
Expand Down
1 change: 1 addition & 0 deletions mlock_unix.go
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
//go:build !windows
// +build !windows

package bbolt
Expand Down
1 change: 1 addition & 0 deletions unix_test.go
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
//go:build !windows
// +build !windows

package bbolt_test
Expand Down

0 comments on commit d5db64b

Please sign in to comment.