Skip to content

Commit 935bb6c

Browse files
authored
Merge branch 'master' into support-get-disk-serial-number-darwin
2 parents 9fc28f2 + 591e789 commit 935bb6c

File tree

122 files changed

+1175
-1677
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

122 files changed

+1175
-1677
lines changed

.github/workflows/build_test.yml

+13-3
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,15 @@
1-
on: [push, pull_request]
21
name: Build Test
2+
3+
on:
4+
push:
5+
branches:
6+
- master
7+
pull_request:
8+
9+
concurrency:
10+
group: ${{ github.workflow }}-${{ github.ref }}
11+
cancel-in-progress: true
12+
313
permissions:
414
contents: read
515

@@ -12,7 +22,7 @@ jobs:
1222
- id: versions
1323
run: |
1424
versions=$(curl -s 'https://go.dev/dl/?mode=json' | jq -c 'map(.version[2:])')
15-
echo "::set-output name=value::${versions}"
25+
echo "value=${versions}" >> $GITHUB_OUTPUT
1626
build_test:
1727
needs: go-versions
1828
strategy:
@@ -24,7 +34,7 @@ jobs:
2434
- name: Checkout code
2535
uses: actions/checkout@11bd71901bbe5b1630ceea73d27597364c9af683 # v4.2.2
2636
- name: Install Go
27-
uses: actions/setup-go@f111f3307d8850f501ac008e886eec1fd1932a34 # v5.3.0
37+
uses: actions/setup-go@0aaccfd150d50ccaeb58ebd88d36e91967a5f35b # v5.4.0
2838
with:
2939
go-version: ${{ matrix.go-version }}
3040
- name: Build Test v3

.github/workflows/labeler.yml

+5-4
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
name: "Pull Request Labeler"
2+
23
on:
3-
- pull_request_target
4+
pull_request_target:
45

56
permissions:
67
contents: read
@@ -12,6 +13,6 @@ jobs:
1213
pull-requests: write # for actions/labeler to add labels to PRs
1314
runs-on: ubuntu-latest
1415
steps:
15-
- uses: actions/labeler@ac9175f8a1f3625fd0d4fb234536d26811351594 # v4.3.0
16-
with:
17-
repo-token: "${{ secrets.GITHUB_TOKEN }}"
16+
- uses: actions/labeler@ac9175f8a1f3625fd0d4fb234536d26811351594 # v4.3.0
17+
with:
18+
repo-token: "${{ secrets.GITHUB_TOKEN }}"

.github/workflows/lint.yml

+42-28
Original file line numberDiff line numberDiff line change
@@ -2,8 +2,14 @@ name: Golangci-lint
22

33
on:
44
push:
5+
branches:
6+
- master
57
pull_request:
68

9+
concurrency:
10+
group: ${{ github.workflow }}-${{ github.ref }}
11+
cancel-in-progress: true
12+
713
permissions:
814
contents: read
915

@@ -13,49 +19,57 @@ jobs:
1319
fail-fast: false
1420
matrix:
1521
include:
16-
- {os: macos-latest, GOOS: darwin, GOARCH: amd64}
17-
- {os: macos-latest, GOOS: darwin, GOARCH: arm64}
18-
- {os: ubuntu-latest, GOOS: dragonfly, GOARCH: amd64}
19-
- {os: ubuntu-latest, GOOS: freebsd, GOARCH: amd64}
20-
- {os: ubuntu-latest, GOOS: freebsd, GOARCH: 386}
21-
- {os: ubuntu-latest, GOOS: freebsd, GOARCH: arm}
22-
- {os: ubuntu-latest, GOOS: linux, GOARCH: 386}
23-
- {os: ubuntu-latest, GOOS: linux, GOARCH: amd64}
24-
- {os: ubuntu-latest, GOOS: linux, GOARCH: arm64}
25-
- {os: ubuntu-latest, GOOS: linux, GOARCH: arm}
26-
- {os: ubuntu-latest, GOOS: linux, GOARCH: mips64}
27-
- {os: ubuntu-latest, GOOS: linux, GOARCH: mips64le}
28-
- {os: ubuntu-latest, GOOS: linux, GOARCH: mips}
29-
- {os: ubuntu-latest, GOOS: linux, GOARCH: mipsle}
30-
- {os: ubuntu-latest, GOOS: linux, GOARCH: ppc64le}
31-
- {os: ubuntu-latest, GOOS: linux, GOARCH: ppc64}
32-
- {os: ubuntu-latest, GOOS: linux, GOARCH: riscv64}
33-
- {os: ubuntu-latest, GOOS: linux, GOARCH: s390x}
34-
- {os: ubuntu-latest, GOOS: netbsd, GOARCH: amd64}
35-
- {os: ubuntu-latest, GOOS: openbsd, GOARCH: 386}
36-
- {os: ubuntu-latest, GOOS: openbsd, GOARCH: amd64}
37-
- {os: ubuntu-latest, GOOS: plan9, GOARCH: amd64}
38-
- {os: ubuntu-latest, GOOS: plan9, GOARCH: 386}
39-
- {os: ubuntu-latest, GOOS: solaris, GOARCH: amd64}
40-
- {os: windows-latest, GOOS: windows, GOARCH: amd64}
41-
- {os: windows-latest, GOOS: windows, GOARCH: 386}
22+
- {os: macos-latest, CGO_ENABLED: "0", GOOS: darwin, GOARCH: amd64}
23+
- {os: macos-latest, CGO_ENABLED: "1", GOOS: darwin, GOARCH: amd64}
24+
- {os: macos-latest, CGO_ENABLED: "0", GOOS: darwin, GOARCH: arm64}
25+
- {os: ubuntu-latest, CGO_ENABLED: "0", GOOS: aix, GOARCH: ppc64}
26+
# - {os: ubuntu-latest, CGO_ENABLED: "1", GOOS: aix, GOARCH: ppc64} # FIXME
27+
- {os: ubuntu-latest, CGO_ENABLED: "0", GOOS: dragonfly, GOARCH: amd64}
28+
- {os: ubuntu-latest, CGO_ENABLED: "0", GOOS: freebsd, GOARCH: amd64}
29+
# - {os: ubuntu-latest, CGO_ENABLED: "1", GOOS: freebsd, GOARCH: amd64} # FIXME
30+
- {os: ubuntu-latest, CGO_ENABLED: "0", GOOS: freebsd, GOARCH: 386}
31+
- {os: ubuntu-latest, CGO_ENABLED: "0", GOOS: freebsd, GOARCH: arm}
32+
- {os: ubuntu-latest, CGO_ENABLED: "0", GOOS: linux, GOARCH: 386}
33+
- {os: ubuntu-latest, CGO_ENABLED: "0", GOOS: linux, GOARCH: amd64}
34+
- {os: ubuntu-latest, CGO_ENABLED: "0", GOOS: linux, GOARCH: arm64}
35+
- {os: ubuntu-latest, CGO_ENABLED: "0", GOOS: linux, GOARCH: arm}
36+
- {os: ubuntu-latest, CGO_ENABLED: "0", GOOS: linux, GOARCH: loong64}
37+
- {os: ubuntu-latest, CGO_ENABLED: "0", GOOS: linux, GOARCH: mips64}
38+
- {os: ubuntu-latest, CGO_ENABLED: "0", GOOS: linux, GOARCH: mips64le}
39+
- {os: ubuntu-latest, CGO_ENABLED: "0", GOOS: linux, GOARCH: mips}
40+
- {os: ubuntu-latest, CGO_ENABLED: "0", GOOS: linux, GOARCH: mipsle}
41+
- {os: ubuntu-latest, CGO_ENABLED: "0", GOOS: linux, GOARCH: ppc64le}
42+
- {os: ubuntu-latest, CGO_ENABLED: "0", GOOS: linux, GOARCH: ppc64}
43+
- {os: ubuntu-latest, CGO_ENABLED: "0", GOOS: linux, GOARCH: riscv64}
44+
- {os: ubuntu-latest, CGO_ENABLED: "0", GOOS: linux, GOARCH: s390x}
45+
- {os: ubuntu-latest, CGO_ENABLED: "0", GOOS: netbsd, GOARCH: amd64}
46+
- {os: ubuntu-latest, CGO_ENABLED: "1", GOOS: netbsd, GOARCH: amd64}
47+
- {os: ubuntu-latest, CGO_ENABLED: "0", GOOS: openbsd, GOARCH: 386}
48+
- {os: ubuntu-latest, CGO_ENABLED: "0", GOOS: openbsd, GOARCH: amd64}
49+
# - {os: ubuntu-latest, CGO_ENABLED: "1", GOOS: openbsd, GOARCH: amd64} # FIXME
50+
- {os: ubuntu-latest, CGO_ENABLED: "0", GOOS: plan9, GOARCH: amd64}
51+
- {os: ubuntu-latest, CGO_ENABLED: "0", GOOS: plan9, GOARCH: 386}
52+
- {os: ubuntu-latest, CGO_ENABLED: "0", GOOS: solaris, GOARCH: amd64}
53+
- {os: windows-latest, CGO_ENABLED: "0", GOOS: windows, GOARCH: amd64}
54+
- {os: windows-latest, CGO_ENABLED: "0", GOOS: windows, GOARCH: 386}
4255
permissions:
4356
contents: read # for actions/checkout to fetch code
4457
pull-requests: read # for golangci/golangci-lint-action to fetch pull requests
4558
name: lint
4659
runs-on: ${{ matrix.os }}
4760
env:
61+
CGO_ENABLED: "${{ matrix.CGO_ENABLED }}"
4862
GOARCH: ${{ matrix.GOARCH }}
4963
GOOS: ${{ matrix.GOOS }}
5064
steps:
5165
- name: Checkout repository
5266
uses: actions/checkout@11bd71901bbe5b1630ceea73d27597364c9af683 # v4.2.2
5367
- name: Setup go
54-
uses: actions/setup-go@f111f3307d8850f501ac008e886eec1fd1932a34 # v5.3.0
68+
uses: actions/setup-go@0aaccfd150d50ccaeb58ebd88d36e91967a5f35b # v5.4.0
5569
with:
5670
go-version-file: go.mod
5771
- name: Setup golangci-lint
58-
uses: golangci/golangci-lint-action@2226d7cb06a077cd73e56eedd38eecad18e5d837 # v6.5.0
72+
uses: golangci/golangci-lint-action@55c2c1448f86e01eaae002a5a3a9624417608d84 # v6.5.2
5973
with:
6074
args: --verbose
6175
version: latest

.github/workflows/release.yml

+3-2
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,9 @@
1+
name: Release
2+
13
on:
24
schedule:
3-
- cron: '0 1 1 * *' # UTC 01:00 on the first day of the Month
5+
- cron: '0 1 1 * *' # UTC 01:00 on the first day of the Month
46

5-
name: Release
67
permissions:
78
contents: write
89

.github/workflows/sbom_generator.yml

+3-5
Original file line numberDiff line numberDiff line change
@@ -2,24 +2,22 @@ name: SBOM Generator
22

33
on:
44
push:
5-
branches: [ "master" ]
6-
5+
branches:
6+
- master
77
workflow_dispatch:
88

99
permissions: read-all
1010

1111
jobs:
1212
build:
1313
runs-on: ubuntu-latest
14-
1514
steps:
1615
- uses: actions/checkout@11bd71901bbe5b1630ceea73d27597364c9af683 # v4.2.2
17-
1816
- uses: advanced-security/sbom-generator-action@6fe43abf522b2e7a19bc769aec1e6c848614b517 # v0.0.2
1917
id: sbom
2018
env:
2119
GITHUB_TOKEN: ${{ github.token }}
22-
- uses: actions/upload-artifact@65c4c4a1ddee5b72f698fdd19549f0f0fb45cf08 # v4.6.0
20+
- uses: actions/upload-artifact@ea165f8d65b6e75b540449e92b4886f43607fa02 # v4.6.2
2321
with:
2422
path: ${{steps.sbom.outputs.fileName }}
2523
name: "SBOM"

.github/workflows/shellcheck.yml

+14-4
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,15 @@
1-
on: [push, pull_request]
21
name: Shellcheck
2+
3+
on:
4+
push:
5+
branches:
6+
- master
7+
pull_request:
8+
9+
concurrency:
10+
group: ${{ github.workflow }}-${{ github.ref }}
11+
cancel-in-progress: true
12+
313
permissions:
414
contents: read
515

@@ -8,6 +18,6 @@ jobs:
818
name: Shellcheck
919
runs-on: ubuntu-latest
1020
steps:
11-
- uses: actions/checkout@11bd71901bbe5b1630ceea73d27597364c9af683 # v4.2.2
12-
- name: Run ShellCheck
13-
uses: ludeeus/action-shellcheck@00cae500b08a931fb5698e11e79bfbd38e612a38 # v2.0.0
21+
- uses: actions/checkout@11bd71901bbe5b1630ceea73d27597364c9af683 # v4.2.2
22+
- name: Run ShellCheck
23+
uses: ludeeus/action-shellcheck@00cae500b08a931fb5698e11e79bfbd38e612a38 # v2.0.0

.github/workflows/test.yml

+13-3
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,15 @@
1-
on: [push, pull_request]
21
name: Test
2+
3+
on:
4+
push:
5+
branches:
6+
- master
7+
pull_request:
8+
9+
concurrency:
10+
group: ${{ github.workflow }}-${{ github.ref }}
11+
cancel-in-progress: true
12+
313
permissions:
414
contents: read
515

@@ -12,7 +22,7 @@ jobs:
1222
- id: versions
1323
run: |
1424
versions=$(curl -s 'https://go.dev/dl/?mode=json' | jq -c 'map(.version[2:])')
15-
echo "::set-output name=value::${versions}"
25+
echo "value=${versions}" >> $GITHUB_OUTPUT
1626
test:
1727
needs: go-versions
1828
strategy:
@@ -25,7 +35,7 @@ jobs:
2535
- name: Checkout code
2636
uses: actions/checkout@11bd71901bbe5b1630ceea73d27597364c9af683 # v4.2.2
2737
- name: Install Go
28-
uses: actions/setup-go@f111f3307d8850f501ac008e886eec1fd1932a34 # v5.3.0
38+
uses: actions/setup-go@0aaccfd150d50ccaeb58ebd88d36e91967a5f35b # v5.4.0
2939
with:
3040
go-version: ${{ matrix.go-version }}
3141
- name: Test

.golangci.yml

+15-3
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,7 @@ linters:
88
- durationcheck
99
- errorlint
1010
- gci
11+
- gocritic
1112
- gofmt
1213
- gofumpt
1314
- goimports
@@ -22,8 +23,10 @@ linters:
2223
- predeclared
2324
- revive
2425
- testifylint
26+
- thelper
2527
- typecheck
2628
- unparam
29+
- usetesting
2730
disable:
2831
- errcheck
2932
- govet
@@ -36,6 +39,9 @@ linters-settings:
3639
- standard
3740
- default
3841
- prefix(github.com/shirou)
42+
gocritic:
43+
disabled-checks:
44+
- captLocal
3945
gomodguard:
4046
blocked:
4147
modules:
@@ -91,13 +97,19 @@ linters-settings:
9197
- name: time-naming
9298
- name: unexported-return
9399
- name: unnecessary-stmt
94-
disabled: true
95100
- name: unreachable-code
96101
- name: unused-parameter
97-
disabled: true
98102
- name: use-any
99103
- name: var-declaration
100104
- name: var-naming
101-
disabled: true
105+
arguments:
106+
- ["ID"] # AllowList
107+
- ["VM"] # DenyList
108+
- - upperCaseConst: true # Extra parameter (upperCaseConst|skipPackageNameChecks)
102109
testifylint:
103110
enable-all: true
111+
usetesting:
112+
os-create-temp: false
113+
os-mkdir-temp: false
114+
run:
115+
timeout: 5m

Makefile

+3
Original file line numberDiff line numberDiff line change
@@ -34,6 +34,7 @@ build_test: ## test only buildable
3434
GOOS=netbsd go test ./... | $(BUILD_FAIL_PATTERN)
3535
GOOS=openbsd go test ./... | $(BUILD_FAIL_PATTERN)
3636
GOOS=plan9 go test ./... | $(BUILD_FAIL_PATTERN)
37+
CGO_ENABLED=0 GOOS=aix GOARCH=ppc64 go test ./... | $(BUILD_FAIL_PATTERN)
3738

3839
ifeq ($(shell uname -s), Darwin)
3940
CGO_ENABLED=1 GOOS=darwin go test ./... | $(BUILD_FAIL_PATTERN)
@@ -77,6 +78,8 @@ vet:
7778
GOOS=plan9 GOARCH=amd64 go vet ./...
7879
GOOS=plan9 GOARCH=386 go vet ./...
7980

81+
CGO_ENABLED=0 GOOS=aix GOARCH=ppc64 go vet ./...
82+
8083
macos_test:
8184
CGO_ENABLED=0 GOOS=darwin go test ./... | $(BUILD_FAIL_PATTERN)
8285
CGO_ENABLED=1 GOOS=darwin go test ./... | $(BUILD_FAIL_PATTERN)

README.md

+1-1
Original file line numberDiff line numberDiff line change
@@ -260,7 +260,7 @@ Some code is ported from Ohai. Many thanks.
260260
|children |x |x |x |x |x |
261261
|connections |x | |x |x | |
262262
|is\_running | | | | | |
263-
|page\_faults |x | | | | |
263+
|page\_faults |x | | | |x |
264264

265265
### gopsutil Original Metrics
266266

cpu/cpu_aix_nocgo.go

+8-8
Original file line numberDiff line numberDiff line change
@@ -14,11 +14,11 @@ import (
1414
func TimesWithContext(ctx context.Context, percpu bool) ([]TimesStat, error) {
1515
var ret []TimesStat
1616
if percpu {
17-
per_out, err := invoke.CommandWithContext(ctx, "sar", "-u", "-P", "ALL", "10", "1")
17+
perOut, err := invoke.CommandWithContext(ctx, "sar", "-u", "-P", "ALL", "10", "1")
1818
if err != nil {
1919
return nil, err
2020
}
21-
lines := strings.Split(string(per_out), "\n")
21+
lines := strings.Split(string(perOut), "\n")
2222
if len(lines) < 6 {
2323
return []TimesStat{}, common.ErrNotImplementedError
2424
}
@@ -105,14 +105,15 @@ func InfoWithContext(ctx context.Context) ([]InfoStat, error) {
105105

106106
ret := InfoStat{}
107107
for _, line := range strings.Split(string(out), "\n") {
108-
if strings.HasPrefix(line, "Number Of Processors:") {
108+
switch {
109+
case strings.HasPrefix(line, "Number Of Processors:"):
109110
p := strings.Fields(line)
110111
if len(p) > 3 {
111112
if t, err := strconv.ParseUint(p[3], 10, 64); err == nil {
112113
ret.Cores = int32(t)
113114
}
114115
}
115-
} else if strings.HasPrefix(line, "Processor Clock Speed:") {
116+
case strings.HasPrefix(line, "Processor Clock Speed:"):
116117
p := strings.Fields(line)
117118
if len(p) > 4 {
118119
if t, err := strconv.ParseFloat(p[3], 64); err == nil {
@@ -128,13 +129,12 @@ func InfoWithContext(ctx context.Context) ([]InfoStat, error) {
128129
}
129130
}
130131
}
131-
break
132-
} else if strings.HasPrefix(line, "System Model:") {
132+
case strings.HasPrefix(line, "System Model:"):
133133
p := strings.Split(string(line), ":")
134134
if p != nil {
135135
ret.VendorID = strings.TrimSpace(p[1])
136136
}
137-
} else if strings.HasPrefix(line, "Processor Type:") {
137+
case strings.HasPrefix(line, "Processor Type:"):
138138
p := strings.Split(string(line), ":")
139139
if p != nil {
140140
c := strings.Split(string(p[1]), "_")
@@ -148,7 +148,7 @@ func InfoWithContext(ctx context.Context) ([]InfoStat, error) {
148148
return []InfoStat{ret}, nil
149149
}
150150

151-
func CountsWithContext(ctx context.Context, logical bool) (int, error) {
151+
func CountsWithContext(ctx context.Context, _ bool) (int, error) {
152152
info, err := InfoWithContext(ctx)
153153
if err == nil {
154154
return int(info[0].Cores), nil

0 commit comments

Comments
 (0)