Merge pull request #949 from boogie-byte/vet-target

Add "vet" target to the Makefile
This commit is contained in:
shirou 2020-10-11 23:01:10 +09:00 committed by GitHub
commit b94f262e7d
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
7 changed files with 41 additions and 13 deletions

View File

@ -4,7 +4,7 @@ version: 2.1
jobs:
test:
docker:
- image: circleci/golang:1.11
- image: circleci/golang:1.14
working_directory: /home/circleci/go/src/github.com/shirou/gopsutil
environment:
GOPATH: /home/circleci/go
@ -19,7 +19,7 @@ jobs:
- run:
command: dep ensure
- run:
command: go build -v
command: make vet
- run:
command: make build_test
macos:

View File

@ -34,6 +34,35 @@ ifeq ($(shell uname -s), Darwin)
endif
@echo 'Successfully built on all known operating systems'
vet:
GOOS=darwin GOARCH=amd64 go vet ./...
GOOS=darwin GOARCH=386 go vet ./...
GOOS=darwin GOARCH=arm64 go vet ./...
GOOS=dragonfly GOARCH=amd64 go vet ./...
GOOS=freebsd GOARCH=amd64 go vet ./...
GOOS=freebsd GOARCH=386 go vet ./...
GOOS=freebsd GOARCH=arm go vet ./...
GOOS=linux GOARCH=386 go vet ./...
GOOS=linux GOARCH=amd64 go vet ./...
GOOS=linux GOARCH=arm64 go vet ./...
GOOS=linux GOARCH=arm go vet ./...
GOOS=linux GOARCH=mips64 go vet ./...
GOOS=linux GOARCH=mips64le go vet ./...
GOOS=linux GOARCH=mips go vet ./...
GOOS=linux GOARCH=mipsle go vet ./...
GOOS=linux GOARCH=ppc64le go vet ./...
GOOS=linux GOARCH=riscv64 go vet ./...
GOOS=linux GOARCH=s390x go vet ./...
GOOS=netbsd GOARCH=amd64 go vet ./...
GOOS=solaris GOARCH=amd64 go vet ./...
GOOS=windows GOARCH=amd64 go vet ./...
GOOS=windows GOARCH=386 go vet ./...
macos_test:
CGO_ENABLED=0 GOOS=darwin go test ./... | $(BUILD_FAIL_PATTERN)
CGO_ENABLED=1 GOOS=darwin go test ./... | $(BUILD_FAIL_PATTERN)

View File

@ -155,7 +155,7 @@ func IOCountersWithContext(ctx context.Context, names ...string) (map[string]IOC
}
for _, v := range lpBuffer[:lpBufferLen] {
if 'A' <= v && v <= 'Z' {
path := string(v) + ":"
path := string(rune(v)) + ":"
typepath, _ := windows.UTF16PtrFromString(path)
typeret := windows.GetDriveType(typepath)
if typeret == 0 {

View File

@ -326,7 +326,6 @@ func GetEnv(key string, dfault string, combineWith ...string) string {
copy(all[1:], combineWith)
return filepath.Join(all...)
}
panic("invalid switch case")
}
func HostProc(combineWith ...string) string {

View File

@ -57,19 +57,19 @@ func TestHexToUint32(t *testing.T) {
}
}
func TestmustParseInt32(t *testing.T) {
func TestMustParseInt32(t *testing.T) {
ret := mustParseInt32("11111")
if ret != int32(11111) {
t.Error("could not parse")
}
}
func TestmustParseUint64(t *testing.T) {
func TestMustParseUint64(t *testing.T) {
ret := mustParseUint64("11111")
if ret != uint64(11111) {
t.Error("could not parse")
}
}
func TestmustParseFloat64(t *testing.T) {
func TestMustParseFloat64(t *testing.T) {
ret := mustParseFloat64("11111.11")
if ret != float64(11111.11) {
t.Error("could not parse")

View File

@ -30,7 +30,7 @@ en0 1500 <Link#4> a8:66:7f:dd:ee:ff 5708989 0 7295722068 3494252
en0 1500 fe80::aa66: fe80:4::aa66:7fff 5708989 - 7295722068 3494252 - 379533492 - -`
)
func TestparseNetstatLineHeader(t *testing.T) {
func TestParseNetstatLineHeader(t *testing.T) {
stat, linkIkd, err := parseNetstatLine(`Name Mtu Network Address Ipkts Ierrs Ibytes Opkts Oerrs Obytes Coll Drop`)
assert.Nil(t, linkIkd)
assert.Nil(t, stat)
@ -48,7 +48,7 @@ func assertLoopbackStat(t *testing.T, err error, stat *IOCountersStat) {
assert.Equal(t, 169411756, stat.BytesSent)
}
func TestparseNetstatLineLink(t *testing.T) {
func TestParseNetstatLineLink(t *testing.T) {
stat, linkID, err := parseNetstatLine(
`lo0 16384 <Link#1> 869107 0 169411755 869108 1 169411756 0 0`,
)
@ -57,7 +57,7 @@ func TestparseNetstatLineLink(t *testing.T) {
assert.Equal(t, uint(1), *linkID)
}
func TestparseNetstatLineIPv6(t *testing.T) {
func TestParseNetstatLineIPv6(t *testing.T) {
stat, linkID, err := parseNetstatLine(
`lo0 16384 ::1/128 ::1 869107 - 169411755 869108 1 169411756 - -`,
)
@ -65,7 +65,7 @@ func TestparseNetstatLineIPv6(t *testing.T) {
assert.Nil(t, linkID)
}
func TestparseNetstatLineIPv4(t *testing.T) {
func TestParseNetstatLineIPv4(t *testing.T) {
stat, linkID, err := parseNetstatLine(
`lo0 16384 127 127.0.0.1 869107 - 169411755 869108 1 169411756 - -`,
)

View File

@ -712,7 +712,7 @@ func (p *Process) SuspendWithContext(ctx context.Context) error {
}
defer windows.CloseHandle(c)
r1, _, _ := procNtSuspendProcess.Call(uintptr(unsafe.Pointer(c)))
r1, _, _ := procNtSuspendProcess.Call(uintptr(c))
if r1 != 0 {
// See https://docs.microsoft.com/en-us/openspecs/windows_protocols/ms-erref/596a1078-e883-4972-9bbc-49e60bebca55
return fmt.Errorf("NtStatus='0x%.8X'", r1)
@ -732,7 +732,7 @@ func (p *Process) ResumeWithContext(ctx context.Context) error {
}
defer windows.CloseHandle(c)
r1, _, _ := procNtResumeProcess.Call(uintptr(unsafe.Pointer(c)))
r1, _, _ := procNtResumeProcess.Call(uintptr(c))
if r1 != 0 {
// See https://docs.microsoft.com/en-us/openspecs/windows_protocols/ms-erref/596a1078-e883-4972-9bbc-49e60bebca55
return fmt.Errorf("NtStatus='0x%.8X'", r1)