From b4d3f678b3ed2ce9542488a8da9722145408cd08 Mon Sep 17 00:00:00 2001 From: SuperQ Date: Tue, 11 Oct 2022 15:14:56 +0200 Subject: [PATCH] Update Go * Update build to latest two Go releases. * Bump module requirements. * Fixup go fmt. * Only make style on latest version. Signed-off-by: SuperQ --- .circleci/config.yml | 9 ++--- .github/workflows/golangci-lint.yml | 4 +-- doc.go | 51 ++++++++++++++--------------- go.mod | 6 ++-- go.sum | 8 ++--- mountstats.go | 3 +- nfs/nfs.go | 1 + proc_cgroups_test.go | 8 ++--- vm.go | 4 ++- 9 files changed, 49 insertions(+), 45 deletions(-) diff --git a/.circleci/config.yml b/.circleci/config.yml index 70d3887f2..d3ad0f9a9 100644 --- a/.circleci/config.yml +++ b/.circleci/config.yml @@ -4,13 +4,14 @@ version: 2.1 jobs: lint: docker: - - image: cimg/go:1.18 + - image: cimg/go:1.19 steps: - checkout - run: make check_license - run: ./scripts/check_build_tags.sh - run: make fixtures - run: make update_fixtures + - run: make style - run: git diff --exit-code test: @@ -28,7 +29,7 @@ jobs: GOOS: "<< parameters.os >>" steps: - checkout - - run: make style lint + - run: make lint - when: condition: << parameters.run_test >> steps: @@ -54,8 +55,8 @@ workflows: matrix: parameters: go_version: - - "1.17" - "1.18" + - "1.19" - test: name: test-windows os: windows @@ -63,6 +64,6 @@ workflows: matrix: parameters: go_version: - - "1.17" - "1.18" + - "1.19" - codespell diff --git a/.github/workflows/golangci-lint.yml b/.github/workflows/golangci-lint.yml index 6034bcbf8..2ba5e88dd 100644 --- a/.github/workflows/golangci-lint.yml +++ b/.github/workflows/golangci-lint.yml @@ -25,6 +25,6 @@ jobs: run: sudo apt-get update && sudo apt-get -y install libsnmp-dev if: github.repository == 'prometheus/snmp_exporter' - name: Lint - uses: golangci/golangci-lint-action@v3.2.0 + uses: golangci/golangci-lint-action@v3.3.1 with: - version: v1.45.2 + version: v1.50.1 diff --git a/doc.go b/doc.go index d31a82600..f9d961e44 100644 --- a/doc.go +++ b/doc.go @@ -16,30 +16,29 @@ // // Example: // -// package main -// -// import ( -// "fmt" -// "log" -// -// "github.com/prometheus/procfs" -// ) -// -// func main() { -// p, err := procfs.Self() -// if err != nil { -// log.Fatalf("could not get process: %s", err) -// } -// -// stat, err := p.Stat() -// if err != nil { -// log.Fatalf("could not get process stat: %s", err) -// } -// -// fmt.Printf("command: %s\n", stat.Comm) -// fmt.Printf("cpu time: %fs\n", stat.CPUTime()) -// fmt.Printf("vsize: %dB\n", stat.VirtualMemory()) -// fmt.Printf("rss: %dB\n", stat.ResidentMemory()) -// } -// +// package main +// +// import ( +// "fmt" +// "log" +// +// "github.com/prometheus/procfs" +// ) +// +// func main() { +// p, err := procfs.Self() +// if err != nil { +// log.Fatalf("could not get process: %s", err) +// } +// +// stat, err := p.Stat() +// if err != nil { +// log.Fatalf("could not get process stat: %s", err) +// } +// +// fmt.Printf("command: %s\n", stat.Comm) +// fmt.Printf("cpu time: %fs\n", stat.CPUTime()) +// fmt.Printf("vsize: %dB\n", stat.VirtualMemory()) +// fmt.Printf("rss: %dB\n", stat.ResidentMemory()) +// } package procfs diff --git a/go.mod b/go.mod index a5c17878b..d88b4397c 100644 --- a/go.mod +++ b/go.mod @@ -1,9 +1,9 @@ module github.com/prometheus/procfs -go 1.17 +go 1.18 require ( github.com/google/go-cmp v0.5.9 - golang.org/x/sync v0.0.0-20220601150217-0de741cfad7f - golang.org/x/sys v0.0.0-20220520151302-bc2c85ada10a + golang.org/x/sync v0.1.0 + golang.org/x/sys v0.3.0 ) diff --git a/go.sum b/go.sum index f80152f5f..f7fa868d7 100644 --- a/go.sum +++ b/go.sum @@ -1,6 +1,6 @@ github.com/google/go-cmp v0.5.9 h1:O2Tfq5qg4qc4AmwVlvv0oLiVAGB7enBSJ2x2DqQFi38= github.com/google/go-cmp v0.5.9/go.mod h1:17dUlkBOakJ0+DkrSSNjCkIjxS6bF9zb3elmeNGIjoY= -golang.org/x/sync v0.0.0-20220601150217-0de741cfad7f h1:Ax0t5p6N38Ga0dThY21weqDEyz2oklo4IvDkpigvkD8= -golang.org/x/sync v0.0.0-20220601150217-0de741cfad7f/go.mod h1:RxMgew5VJxzue5/jJTE5uejpjVlOe/izrB70Jof72aM= -golang.org/x/sys v0.0.0-20220520151302-bc2c85ada10a h1:dGzPydgVsqGcTRVwiLJ1jVbufYwmzD3LfVPLKsKg+0k= -golang.org/x/sys v0.0.0-20220520151302-bc2c85ada10a/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg= +golang.org/x/sync v0.1.0 h1:wsuoTGHzEhffawBOhz5CYhcrV4IdKZbEyZjBMuTp12o= +golang.org/x/sync v0.1.0/go.mod h1:RxMgew5VJxzue5/jJTE5uejpjVlOe/izrB70Jof72aM= +golang.org/x/sys v0.3.0 h1:w8ZOecv6NaNa/zC8944JTU3vz4u6Lagfk4RPQxv92NQ= +golang.org/x/sys v0.3.0/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg= diff --git a/mountstats.go b/mountstats.go index f7a828bb1..0c482c18c 100644 --- a/mountstats.go +++ b/mountstats.go @@ -284,7 +284,8 @@ func parseMountStats(r io.Reader) ([]*Mount, error) { } // parseMount parses an entry in /proc/[pid]/mountstats in the format: -// device [device] mounted on [mount] with fstype [type] +// +// device [device] mounted on [mount] with fstype [type] func parseMount(ss []string) (*Mount, error) { if len(ss) < deviceEntryLen { return nil, fmt.Errorf("invalid device entry: %v", ss) diff --git a/nfs/nfs.go b/nfs/nfs.go index 6bf1b80c6..729210295 100644 --- a/nfs/nfs.go +++ b/nfs/nfs.go @@ -204,6 +204,7 @@ type ServerV4Stats struct { // - v4.0 https://tools.ietf.org/html/rfc3010 (38 operations) // - v4.1 https://tools.ietf.org/html/rfc5661 (58 operations) // - v4.2 https://tools.ietf.org/html/draft-ietf-nfsv4-minorversion2-41 (71 operations) +// //nolint:godot type V4Ops struct { //Values uint64 // Variable depending on v4.x sub-version. TODO: Will this always at least include the fields in this struct? diff --git a/proc_cgroups_test.go b/proc_cgroups_test.go index b0a61d24b..b2b936528 100644 --- a/proc_cgroups_test.go +++ b/proc_cgroups_test.go @@ -26,8 +26,8 @@ func TestParseCgroupSummaryString(t *testing.T) { CgroupSummary *CgroupSummary }{ { - name: "cpuset simple line", - s: "cpuset 7 148 1", + name: "cpuset simple line", + s: "cpuset 7 148 1", shouldErr: false, CgroupSummary: &CgroupSummary{ SubsysName: "cpuset", @@ -37,8 +37,8 @@ func TestParseCgroupSummaryString(t *testing.T) { }, }, { - name: "memory cgroup number mis format", - s: "memory 9 ## 1", + name: "memory cgroup number mis format", + s: "memory 9 ## 1", shouldErr: true, CgroupSummary: nil, }, diff --git a/vm.go b/vm.go index 20ceb77e2..cdedcae99 100644 --- a/vm.go +++ b/vm.go @@ -26,7 +26,9 @@ import ( ) // The VM interface is described at -// https://www.kernel.org/doc/Documentation/sysctl/vm.txt +// +// https://www.kernel.org/doc/Documentation/sysctl/vm.txt +// // Each setting is exposed as a single file. // Each file contains one line with a single numerical value, except lowmem_reserve_ratio which holds an array // and numa_zonelist_order (deprecated) which is a string.