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

Add "vet" target to the Makefile
pull/963/head
shirou 5 years ago committed by GitHub
commit b94f262e7d
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

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

@ -34,6 +34,35 @@ ifeq ($(shell uname -s), Darwin)
endif endif
@echo 'Successfully built on all known operating systems' @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: macos_test:
CGO_ENABLED=0 GOOS=darwin go test ./... | $(BUILD_FAIL_PATTERN) CGO_ENABLED=0 GOOS=darwin go test ./... | $(BUILD_FAIL_PATTERN)
CGO_ENABLED=1 GOOS=darwin go test ./... | $(BUILD_FAIL_PATTERN) CGO_ENABLED=1 GOOS=darwin go test ./... | $(BUILD_FAIL_PATTERN)

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

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

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

@ -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 - -` 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`) stat, linkIkd, err := parseNetstatLine(`Name Mtu Network Address Ipkts Ierrs Ibytes Opkts Oerrs Obytes Coll Drop`)
assert.Nil(t, linkIkd) assert.Nil(t, linkIkd)
assert.Nil(t, stat) assert.Nil(t, stat)
@ -48,7 +48,7 @@ func assertLoopbackStat(t *testing.T, err error, stat *IOCountersStat) {
assert.Equal(t, 169411756, stat.BytesSent) assert.Equal(t, 169411756, stat.BytesSent)
} }
func TestparseNetstatLineLink(t *testing.T) { func TestParseNetstatLineLink(t *testing.T) {
stat, linkID, err := parseNetstatLine( stat, linkID, err := parseNetstatLine(
`lo0 16384 <Link#1> 869107 0 169411755 869108 1 169411756 0 0`, `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) assert.Equal(t, uint(1), *linkID)
} }
func TestparseNetstatLineIPv6(t *testing.T) { func TestParseNetstatLineIPv6(t *testing.T) {
stat, linkID, err := parseNetstatLine( stat, linkID, err := parseNetstatLine(
`lo0 16384 ::1/128 ::1 869107 - 169411755 869108 1 169411756 - -`, `lo0 16384 ::1/128 ::1 869107 - 169411755 869108 1 169411756 - -`,
) )
@ -65,7 +65,7 @@ func TestparseNetstatLineIPv6(t *testing.T) {
assert.Nil(t, linkID) assert.Nil(t, linkID)
} }
func TestparseNetstatLineIPv4(t *testing.T) { func TestParseNetstatLineIPv4(t *testing.T) {
stat, linkID, err := parseNetstatLine( stat, linkID, err := parseNetstatLine(
`lo0 16384 127 127.0.0.1 869107 - 169411755 869108 1 169411756 - -`, `lo0 16384 127 127.0.0.1 869107 - 169411755 869108 1 169411756 - -`,
) )

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

Loading…
Cancel
Save