mirror of
https://github.com/shirou/gopsutil.git
synced 2025-05-08 19:29:25 +08:00
fix more linting reports
This commit is contained in:
parent
842e4da755
commit
b712e59295
@ -6,8 +6,9 @@ package disk
|
|||||||
import (
|
import (
|
||||||
"context"
|
"context"
|
||||||
|
|
||||||
"github.com/shirou/gopsutil/v3/internal/common"
|
|
||||||
"golang.org/x/sys/unix"
|
"golang.org/x/sys/unix"
|
||||||
|
|
||||||
|
"github.com/shirou/gopsutil/v3/internal/common"
|
||||||
)
|
)
|
||||||
|
|
||||||
// PartitionsWithContext returns disk partition.
|
// PartitionsWithContext returns disk partition.
|
||||||
|
@ -3,7 +3,10 @@
|
|||||||
|
|
||||||
package docker
|
package docker
|
||||||
|
|
||||||
import "testing"
|
import (
|
||||||
|
"context"
|
||||||
|
"testing"
|
||||||
|
)
|
||||||
|
|
||||||
func TestGetDockerIDList(t *testing.T) {
|
func TestGetDockerIDList(t *testing.T) {
|
||||||
// If there is not docker environment, this test always fail.
|
// If there is not docker environment, this test always fail.
|
||||||
@ -43,7 +46,7 @@ func TestGetDockerStat(t *testing.T) {
|
|||||||
func TestCgroupCPU(t *testing.T) {
|
func TestCgroupCPU(t *testing.T) {
|
||||||
v, _ := GetDockerIDList()
|
v, _ := GetDockerIDList()
|
||||||
for _, id := range v {
|
for _, id := range v {
|
||||||
v, err := CgroupCPUDocker(id)
|
v, err := CgroupCPUDockerWithContext(context.Background(), id)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
t.Errorf("error %v", err)
|
t.Errorf("error %v", err)
|
||||||
}
|
}
|
||||||
@ -55,7 +58,7 @@ func TestCgroupCPU(t *testing.T) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
func TestCgroupCPUInvalidId(t *testing.T) {
|
func TestCgroupCPUInvalidId(t *testing.T) {
|
||||||
_, err := CgroupCPUDocker("bad id")
|
_, err := CgroupCPUDockerWithContext(context.Background(), "bad id")
|
||||||
if err == nil {
|
if err == nil {
|
||||||
t.Error("Expected path does not exist error")
|
t.Error("Expected path does not exist error")
|
||||||
}
|
}
|
||||||
|
@ -46,7 +46,7 @@ func CgroupCPUDocker(containerid string) (*CgroupCPUStat, error) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
func CgroupCPUDockerWithContext(ctx context.Context, containerid string) (*CgroupCPUStat, error) {
|
func CgroupCPUDockerWithContext(ctx context.Context, containerid string) (*CgroupCPUStat, error) {
|
||||||
return CgroupCPU(containerid, common.HostSysWithContext(ctx, "fs/cgroup/cpuacct/docker"))
|
return CgroupCPUWithContext(ctx, containerid, common.HostSysWithContext(ctx, "fs/cgroup/cpuacct/docker"))
|
||||||
}
|
}
|
||||||
|
|
||||||
func CgroupMem(containerid string, base string) (*CgroupMemStat, error) {
|
func CgroupMem(containerid string, base string) (*CgroupMemStat, error) {
|
||||||
|
@ -13,9 +13,10 @@ import (
|
|||||||
"strings"
|
"strings"
|
||||||
"unsafe"
|
"unsafe"
|
||||||
|
|
||||||
|
"golang.org/x/sys/unix"
|
||||||
|
|
||||||
"github.com/shirou/gopsutil/v3/internal/common"
|
"github.com/shirou/gopsutil/v3/internal/common"
|
||||||
"github.com/shirou/gopsutil/v3/process"
|
"github.com/shirou/gopsutil/v3/process"
|
||||||
"golang.org/x/sys/unix"
|
|
||||||
)
|
)
|
||||||
|
|
||||||
// from utmpx.h
|
// from utmpx.h
|
||||||
|
@ -8,8 +8,9 @@ import (
|
|||||||
"fmt"
|
"fmt"
|
||||||
"unsafe"
|
"unsafe"
|
||||||
|
|
||||||
"github.com/shirou/gopsutil/v3/internal/common"
|
|
||||||
"golang.org/x/sys/unix"
|
"golang.org/x/sys/unix"
|
||||||
|
|
||||||
|
"github.com/shirou/gopsutil/v3/internal/common"
|
||||||
)
|
)
|
||||||
|
|
||||||
func getHwMemsize() (uint64, error) {
|
func getHwMemsize() (uint64, error) {
|
||||||
|
@ -10,10 +10,11 @@ import (
|
|||||||
"strconv"
|
"strconv"
|
||||||
"strings"
|
"strings"
|
||||||
|
|
||||||
"github.com/shirou/gopsutil/v3/internal/common"
|
|
||||||
"github.com/shirou/gopsutil/v3/net"
|
|
||||||
"github.com/tklauser/go-sysconf"
|
"github.com/tklauser/go-sysconf"
|
||||||
"golang.org/x/sys/unix"
|
"golang.org/x/sys/unix"
|
||||||
|
|
||||||
|
"github.com/shirou/gopsutil/v3/internal/common"
|
||||||
|
"github.com/shirou/gopsutil/v3/net"
|
||||||
)
|
)
|
||||||
|
|
||||||
// copied from sys/sysctl.h
|
// copied from sys/sysctl.h
|
||||||
|
Loading…
x
Reference in New Issue
Block a user