Skip to content

Commit 7eafd66

Browse files
fix: resolve linting warnings
- Replace deprecated io/ioutil with os.ReadFile in internal/io/file - Simplify make([]*Credential, count, count) to make([]*Credential, count) - Explicitly ignore errors in test cleanup/setup for credman tests Remaining warnings are for unsafe pointer handling in credman which requires careful review before modifying.
1 parent 758fca9 commit 7eafd66

File tree

3 files changed

+10
-8
lines changed

3 files changed

+10
-8
lines changed

internal/credman/credman_windows.go

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -7,10 +7,11 @@
77
package credman
88

99
import (
10-
syscall "golang.org/x/sys/windows"
1110
"reflect"
1211
"time"
1312
"unsafe"
13+
14+
syscall "golang.org/x/sys/windows"
1415
)
1516

1617
// Load the Windows DLL "advapi32.dll", then set up Go wrapper functions for
@@ -78,7 +79,7 @@ func EnumerateCredentials(filter string, all bool) ([]*Credential, error) {
7879
Len: count,
7980
Cap: count,
8081
}))
81-
credentials := make([]*Credential, count, count)
82+
credentials := make([]*Credential, count)
8283
for i, c := range systemCredentials {
8384
credentials[i] = convertFromSystemCredential(c)
8485
}

internal/credman/credman_windows_test.go

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -4,9 +4,10 @@
44
package credman
55

66
import (
7-
"github.com/stretchr/testify/assert"
87
"testing"
98
"time"
9+
10+
"github.com/stretchr/testify/assert"
1011
)
1112

1213
func TestWriteCredential(t *testing.T) {
@@ -31,7 +32,7 @@ func TestWriteCredential(t *testing.T) {
3132
assert.Equal(t, credentials[0].Persist, PersistSession, "WriteCredential wrote incorrect Persist, got: %d, want: %d", credentials[0].Persist, PersistSession)
3233

3334
// Cleanup the written credential
34-
DeleteCredential(credential, CredTypeGeneric)
35+
_ = DeleteCredential(credential, CredTypeGeneric)
3536
}
3637

3738
func TestDeleteCredential(t *testing.T) {
@@ -44,7 +45,7 @@ func TestDeleteCredential(t *testing.T) {
4445
}
4546

4647
// Write the credential first
47-
WriteCredential(credential, CredTypeGeneric)
48+
_ = WriteCredential(credential, CredTypeGeneric)
4849

4950
err := DeleteCredential(credential, CredTypeGeneric)
5051
assert.NoErrorf(t, err, "DeleteCredential returned an error: %v", err)

internal/io/file/file.go

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -4,10 +4,10 @@
44
package file
55

66
import (
7-
"github.com/microsoft/go-sqlcmd/internal/io/folder"
8-
"io/ioutil"
97
"os"
108
"path/filepath"
9+
10+
"github.com/microsoft/go-sqlcmd/internal/io/folder"
1111
)
1212

1313
func CloseFile(f *os.File) {
@@ -55,7 +55,7 @@ func Exists(filename string) (exists bool) {
5555
}
5656

5757
func GetContents(filename string) string {
58-
b, err := ioutil.ReadFile(filename)
58+
b, err := os.ReadFile(filename)
5959
checkErr(err)
6060

6161
return string(b)

0 commit comments

Comments
 (0)