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

update go version to 1.17 #63

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
1 change: 1 addition & 0 deletions .travis.yml
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@ go:
- "1.12"
- "1.13"
- "1.14"
- "1.17"
env:
- GO111MODULE=on
before_install:
Expand Down
3 changes: 1 addition & 2 deletions cmd/goversioninfo/main.go
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,6 @@ import (
"flag"
"fmt"
"io"
"io/ioutil"
"log"
"os"

Expand Down Expand Up @@ -81,7 +80,7 @@ func main() {
}

// Read the config file.
jsonBytes, err := ioutil.ReadAll(input)
jsonBytes, err := io.ReadAll(input)
input.Close()
if err != nil {
log.Printf("Error reading %q: %v", configFile, err)
Expand Down
8 changes: 7 additions & 1 deletion go.mod
Original file line number Diff line number Diff line change
@@ -1,8 +1,14 @@
module github.com/josephspurrier/goversioninfo

go 1.12
go 1.17

require (
github.com/akavel/rsrc v0.10.2
github.com/stretchr/testify v1.6.1
)

require (
github.com/davecgh/go-spew v1.1.0 // indirect
github.com/pmezard/go-difflib v1.0.0 // indirect
gopkg.in/yaml.v3 v3.0.0-20200313102051-9f266ea9e77c // indirect
)
3 changes: 1 addition & 2 deletions goversioninfo.go
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,6 @@ import (
"encoding/json"
"fmt"
"io"
"io/ioutil"
"log"
"os"
"reflect"
Expand Down Expand Up @@ -230,7 +229,7 @@ func (vi *VersionInfo) WriteSyso(filename string, arch string) error {

// WriteHex creates a hex file for debugging version info
func (vi *VersionInfo) WriteHex(filename string) error {
return ioutil.WriteFile(filename, vi.Buffer.Bytes(), 0655)
return os.WriteFile(filename, vi.Buffer.Bytes(), 0655)
}

// WriteGo creates a Go file that contains the version info so you can access
Expand Down
51 changes: 25 additions & 26 deletions goversioninfo_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,6 @@ package goversioninfo
import (
"bytes"
"io"
"io/ioutil"
"log"
"os"
"path/filepath"
Expand All @@ -29,7 +28,7 @@ func TestFile1(t *testing.T) {
func testFile(t *testing.T, filename string) {
path, _ := filepath.Abs("./testdata/json/" + filename + ".json")

jsonBytes, err := ioutil.ReadFile(path)
jsonBytes, err := os.ReadFile(path)
assert.NoError(t, err)

// Create a new container
Expand All @@ -49,28 +48,28 @@ func testFile(t *testing.T, filename string) {

// This is for easily exporting results when the algorithm improves
/*path3, _ := filepath.Abs("./testdata/" + filename + ".out")
ioutil.WriteFile(path3, vi.Buffer.Bytes(), 0655)*/
os.WriteFile(path3, vi.Buffer.Bytes(), 0655)*/

expected, err := ioutil.ReadFile(path2)
expected, err := os.ReadFile(path2)
assert.NoError(t, err)

if !bytes.Equal(vi.Buffer.Bytes(), expected) {
t.Error("Data does not match " + filename + ".hex")
}

// Test the Go file generation.
tmpdir, err := ioutil.TempDir("", "generate_go")
tmpdir, err := os.MkdirTemp("", "generate_go")
assert.NoError(t, err)
defer os.RemoveAll(tmpdir)
path4 := filepath.Join(tmpdir, filename+".go")
err = vi.WriteGo(path4, "")
assert.NoError(t, err)

gen, err := ioutil.ReadFile(path4)
gen, err := os.ReadFile(path4)
assert.NoError(t, err)

path5, _ := filepath.Abs("./testdata/gofile/" + filename + ".go")
expected5, err := ioutil.ReadFile(path5)
expected5, err := os.ReadFile(path5)
if err != nil {
t.Error("Could not load "+path5, err)
}
Expand Down Expand Up @@ -104,7 +103,7 @@ func doTestWrite(t *testing.T, arch string) {

path, _ := filepath.Abs("./testdata/json/" + filename + ".json")

jsonBytes, err := ioutil.ReadFile(path)
jsonBytes, err := os.ReadFile(path)
assert.NoError(t, err)

// Create a new container
Expand All @@ -120,15 +119,15 @@ func doTestWrite(t *testing.T, arch string) {
// Write the data to a buffer
vi.Walk()

tmpdir, err := ioutil.TempDir("", "resource")
tmpdir, err := os.MkdirTemp("", "resource")
assert.NoError(t, err)
defer os.RemoveAll(tmpdir)
file := filepath.Join(tmpdir, "resource.syso")

err = vi.WriteSyso(file, arch)
assert.NoError(t, err)

_, err = ioutil.ReadFile(file)
_, err = os.ReadFile(file)
assert.NoError(t, err)
}

Expand All @@ -137,7 +136,7 @@ func TestMalformedJSON(t *testing.T) {

path, _ := filepath.Abs("./testdata/json/" + filename + ".json")

jsonBytes, err := ioutil.ReadFile(path)
jsonBytes, err := os.ReadFile(path)
assert.NoError(t, err)

// Create a new container
Expand All @@ -154,7 +153,7 @@ func TestIcon(t *testing.T) {

path, _ := filepath.Abs("./testdata/json/" + filename + ".json")

jsonBytes, err := ioutil.ReadFile(path)
jsonBytes, err := os.ReadFile(path)
assert.NoError(t, err)

// Create a new container
Expand All @@ -173,15 +172,15 @@ func TestIcon(t *testing.T) {
// Write the data to a buffer
vi.Walk()

tmpdir, err := ioutil.TempDir("", "resource")
tmpdir, err := os.MkdirTemp("", "resource")
assert.NoError(t, err)
defer os.RemoveAll(tmpdir)
file := filepath.Join(tmpdir, "resource.syso")

err = vi.WriteSyso(file, "386")
assert.NoError(t, err)

_, err = ioutil.ReadFile(file)
_, err = os.ReadFile(file)
assert.NoError(t, err)
}

Expand All @@ -190,7 +189,7 @@ func TestBadIcon(t *testing.T) {

path, _ := filepath.Abs("./testdata/json/" + filename + ".json")

jsonBytes, err := ioutil.ReadFile(path)
jsonBytes, err := os.ReadFile(path)
assert.NoError(t, err)

// Create a new container
Expand All @@ -209,7 +208,7 @@ func TestBadIcon(t *testing.T) {
// Write the data to a buffer
vi.Walk()

tmpdir, err := ioutil.TempDir("", "resource")
tmpdir, err := os.MkdirTemp("", "resource")
assert.NoError(t, err)
defer os.RemoveAll(tmpdir)
file := filepath.Join(tmpdir, "resource.syso")
Expand All @@ -219,7 +218,7 @@ func TestBadIcon(t *testing.T) {
t.Errorf("Error is missing because it should throw an error")
}

_, err = ioutil.ReadFile(file)
_, err = os.ReadFile(file)
if err == nil {
t.Error("File should not exist "+file, err)
}
Expand All @@ -230,7 +229,7 @@ func TestTimestamp(t *testing.T) {

path, _ := filepath.Abs("./testdata/json/" + filename + ".json")

jsonBytes, err := ioutil.ReadFile(path)
jsonBytes, err := os.ReadFile(path)
assert.NoError(t, err)

// Create a new container
Expand All @@ -249,15 +248,15 @@ func TestTimestamp(t *testing.T) {
// Write the data to a buffer
vi.Walk()

tmpdir, err := ioutil.TempDir("", "resource")
tmpdir, err := os.MkdirTemp("", "resource")
assert.NoError(t, err)
defer os.RemoveAll(tmpdir)
file := filepath.Join(tmpdir, "resource.syso")

err = vi.WriteSyso(file, "386")
assert.NoError(t, err)

_, err = ioutil.ReadFile(file)
_, err = os.ReadFile(file)
assert.NoError(t, err)
}

Expand All @@ -266,7 +265,7 @@ func TestVersionString(t *testing.T) {

path, _ := filepath.Abs("./testdata/json/" + filename + ".json")

jsonBytes, err := ioutil.ReadFile(path)
jsonBytes, err := os.ReadFile(path)
assert.NoError(t, err)

// Create a new container
Expand All @@ -286,7 +285,7 @@ func TestWriteHex(t *testing.T) {

path, _ := filepath.Abs("./testdata/json/" + filename + ".json")

jsonBytes, err := ioutil.ReadFile(path)
jsonBytes, err := os.ReadFile(path)
assert.NoError(t, err)

// Create a new container
Expand All @@ -302,15 +301,15 @@ func TestWriteHex(t *testing.T) {
// Write the data to a buffer
vi.Walk()

tmpdir, err := ioutil.TempDir("", "resource")
tmpdir, err := os.MkdirTemp("", "resource")
assert.NoError(t, err)
defer os.RemoveAll(tmpdir)
file := filepath.Join(tmpdir, "resource.syso")

err = vi.WriteHex(file)
assert.NoError(t, err)

_, err = ioutil.ReadFile(file)
_, err = os.ReadFile(file)
assert.NoError(t, err)
}

Expand All @@ -319,7 +318,7 @@ func testdatatr2Uint32(t *testing.T) {
in string
out uint32
}{{"0", 0}, {"", 0}, {"FFEF", 65519}, {"\x00\x00", 0}} {
log.SetOutput(ioutil.Discard)
log.SetOutput(io.Discard)
got := str2Uint32(tt.in)
if got != tt.out {
t.Errorf("%q: awaited %d, got %d.", tt.in, tt.out, got)
Expand Down Expand Up @@ -358,7 +357,7 @@ func TestCharsetID(t *testing.T) {
}

func TestWriteCoff(t *testing.T) {
tempFh, err := ioutil.TempFile("", "goversioninfo-test-")
tempFh, err := os.CreateTemp("", "goversioninfo-test-")
if err != nil {
t.Fatalf("temp file: %v", err)
}
Expand Down
3 changes: 1 addition & 2 deletions icon_test.go
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
package goversioninfo

import (
"io/ioutil"
"os"
"path/filepath"
"runtime"
Expand All @@ -11,7 +10,7 @@ import (
func TestIconReleaseFileHandle(t *testing.T) {
icoPath := "testdata/resource/icon.ico"
icoPath2 := "testdata/resource/icon2.ico"
tmpdir, err := ioutil.TempDir("", "resource")
tmpdir, err := os.MkdirTemp("", "resource")
if err != nil {
t.Error("Could not create temp dir", err)
}
Expand Down