Skip to content

Commit

Permalink
add SPDX License, remove old build tag, and replace import
Browse files Browse the repository at this point in the history
  • Loading branch information
shirou committed Feb 17, 2024
1 parent 324af9e commit 60f4fc7
Show file tree
Hide file tree
Showing 231 changed files with 369 additions and 289 deletions.
20 changes: 13 additions & 7 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,13 @@
This is a port of psutil (https://github.com/giampaolo/psutil). The
challenge is porting all psutil functions on some architectures.

## v3 migration
## migration

### v4 migration

See v4 release note.

### v3 migration

From v3.20.10, gopsutil becomes v3 which breaks backwards compatibility.
See [v3Changes.md](_tools/v3migration/v3Changes.md) for more detailed changes.
Expand All @@ -15,10 +21,10 @@ See [v3Changes.md](_tools/v3migration/v3Changes.md) for more detailed changes.
gopsutil tag policy is almost same as Semantic Versioning, but
automatically increases like [Ubuntu versioning](https://calver.org/).

For example, v2.17.04 means
For example, v4.24.04 means

- v2: major version
- 17: release year, 2017
- v4: major version
- 24: release year, 2024
- 04: release month

gopsutil aims to keep backwards compatibility until major version change.
Expand Down Expand Up @@ -52,7 +58,7 @@ package main
import (
"fmt"

"github.com/shirou/gopsutil/v3/mem"
"github.com/shirou/gopsutil/v4/mem"
// "github.com/shirou/gopsutil/mem" // to use v2
)

Expand Down Expand Up @@ -122,11 +128,11 @@ Be very careful that enabling the cache may cause inconsistencies. For example,

## Documentation

See https://pkg.go.dev/github.com/shirou/gopsutil/v3 or https://godocs.io/github.com/shirou/gopsutil/v3
See https://pkg.go.dev/github.com/shirou/gopsutil/v4 or https://godocs.io/github.com/shirou/gopsutil/v4

## Requirements

- go1.16 or above is required.
- go1.20 or above is required.

## More Info

Expand Down
1 change: 1 addition & 0 deletions common/env.go
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
// SPDX-License-Identifier: BSD-3-Clause
package common

type EnvKeyType string
Expand Down
3 changes: 2 additions & 1 deletion cpu/cpu.go
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
// SPDX-License-Identifier: BSD-3-Clause
package cpu

import (
Expand All @@ -11,7 +12,7 @@ import (
"sync"
"time"

"github.com/shirou/gopsutil/v3/internal/common"
"github.com/shirou/gopsutil/v4/internal/common"
)

// TimesStat contains the amounts of time the CPU has spent performing different
Expand Down
2 changes: 1 addition & 1 deletion cpu/cpu_aix.go
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
// SPDX-License-Identifier: BSD-3-Clause
//go:build aix
// +build aix

package cpu

Expand Down
2 changes: 1 addition & 1 deletion cpu/cpu_aix_cgo.go
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
// SPDX-License-Identifier: BSD-3-Clause
//go:build aix && cgo
// +build aix,cgo

package cpu

Expand Down
4 changes: 2 additions & 2 deletions cpu/cpu_aix_nocgo.go
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
// SPDX-License-Identifier: BSD-3-Clause
//go:build aix && !cgo
// +build aix,!cgo

package cpu

Expand All @@ -8,7 +8,7 @@ import (
"strconv"
"strings"

"github.com/shirou/gopsutil/v3/internal/common"
"github.com/shirou/gopsutil/v4/internal/common"
)

func TimesWithContext(ctx context.Context, percpu bool) ([]TimesStat, error) {
Expand Down
2 changes: 1 addition & 1 deletion cpu/cpu_darwin.go
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
// SPDX-License-Identifier: BSD-3-Clause
//go:build darwin
// +build darwin

package cpu

Expand Down
2 changes: 1 addition & 1 deletion cpu/cpu_darwin_cgo.go
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
// SPDX-License-Identifier: BSD-3-Clause
//go:build darwin && cgo
// +build darwin,cgo

package cpu

Expand Down
4 changes: 2 additions & 2 deletions cpu/cpu_darwin_nocgo.go
Original file line number Diff line number Diff line change
@@ -1,9 +1,9 @@
// SPDX-License-Identifier: BSD-3-Clause
//go:build darwin && !cgo
// +build darwin,!cgo

package cpu

import "github.com/shirou/gopsutil/v3/internal/common"
import "github.com/shirou/gopsutil/v4/internal/common"

func perCPUTimes() ([]TimesStat, error) {
return []TimesStat{}, common.ErrNotImplementedError
Expand Down
2 changes: 1 addition & 1 deletion cpu/cpu_darwin_test.go
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
// SPDX-License-Identifier: BSD-3-Clause
//go:build darwin
// +build darwin

package cpu

Expand Down
3 changes: 2 additions & 1 deletion cpu/cpu_dragonfly.go
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
// SPDX-License-Identifier: BSD-3-Clause
package cpu

import (
Expand All @@ -10,7 +11,7 @@ import (
"strings"
"unsafe"

"github.com/shirou/gopsutil/v3/internal/common"
"github.com/shirou/gopsutil/v4/internal/common"
"github.com/tklauser/go-sysconf"
"golang.org/x/sys/unix"
)
Expand Down
1 change: 1 addition & 0 deletions cpu/cpu_dragonfly_amd64.go
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
// SPDX-License-Identifier: BSD-3-Clause
package cpu

type cpuTimes struct {
Expand Down
4 changes: 2 additions & 2 deletions cpu/cpu_fallback.go
Original file line number Diff line number Diff line change
@@ -1,13 +1,13 @@
// SPDX-License-Identifier: BSD-3-Clause
//go:build !darwin && !linux && !freebsd && !openbsd && !netbsd && !solaris && !windows && !dragonfly && !plan9 && !aix
// +build !darwin,!linux,!freebsd,!openbsd,!netbsd,!solaris,!windows,!dragonfly,!plan9,!aix

package cpu

import (
"context"
"runtime"

"github.com/shirou/gopsutil/v3/internal/common"
"github.com/shirou/gopsutil/v4/internal/common"
)

func Times(percpu bool) ([]TimesStat, error) {
Expand Down
3 changes: 2 additions & 1 deletion cpu/cpu_freebsd.go
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
// SPDX-License-Identifier: BSD-3-Clause
package cpu

import (
Expand All @@ -10,7 +11,7 @@ import (
"strings"
"unsafe"

"github.com/shirou/gopsutil/v3/internal/common"
"github.com/shirou/gopsutil/v4/internal/common"
"github.com/tklauser/go-sysconf"
"golang.org/x/sys/unix"
)
Expand Down
1 change: 1 addition & 0 deletions cpu/cpu_freebsd_386.go
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
// SPDX-License-Identifier: BSD-3-Clause
package cpu

type cpuTimes struct {
Expand Down
1 change: 1 addition & 0 deletions cpu/cpu_freebsd_amd64.go
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
// SPDX-License-Identifier: BSD-3-Clause
package cpu

type cpuTimes struct {
Expand Down
1 change: 1 addition & 0 deletions cpu/cpu_freebsd_arm.go
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
// SPDX-License-Identifier: BSD-3-Clause
package cpu

type cpuTimes struct {
Expand Down
1 change: 1 addition & 0 deletions cpu/cpu_freebsd_arm64.go
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
// SPDX-License-Identifier: BSD-3-Clause
package cpu

type cpuTimes struct {
Expand Down
3 changes: 2 additions & 1 deletion cpu/cpu_freebsd_test.go
Original file line number Diff line number Diff line change
@@ -1,11 +1,12 @@
// SPDX-License-Identifier: BSD-3-Clause
package cpu

import (
"path/filepath"
"runtime"
"testing"

"github.com/shirou/gopsutil/v3/internal/common"
"github.com/shirou/gopsutil/v4/internal/common"
)

func TestParseDmesgBoot(t *testing.T) {
Expand Down
4 changes: 2 additions & 2 deletions cpu/cpu_linux.go
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
// SPDX-License-Identifier: BSD-3-Clause
//go:build linux
// +build linux

package cpu

Expand All @@ -13,7 +13,7 @@ import (

"github.com/tklauser/go-sysconf"

"github.com/shirou/gopsutil/v3/internal/common"
"github.com/shirou/gopsutil/v4/internal/common"
)

var ClocksPerSec = float64(100)
Expand Down
1 change: 1 addition & 0 deletions cpu/cpu_linux_test.go
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
// SPDX-License-Identifier: BSD-3-Clause
package cpu

import (
Expand Down
4 changes: 2 additions & 2 deletions cpu/cpu_netbsd.go
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
// SPDX-License-Identifier: BSD-3-Clause
//go:build netbsd
// +build netbsd

package cpu

Expand All @@ -9,7 +9,7 @@ import (
"runtime"
"unsafe"

"github.com/shirou/gopsutil/v3/internal/common"
"github.com/shirou/gopsutil/v4/internal/common"
"github.com/tklauser/go-sysconf"
"golang.org/x/sys/unix"
)
Expand Down
1 change: 1 addition & 0 deletions cpu/cpu_netbsd_amd64.go
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
// SPDX-License-Identifier: BSD-3-Clause
package cpu

type cpuTimes struct {
Expand Down
1 change: 1 addition & 0 deletions cpu/cpu_netbsd_arm64.go
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
// SPDX-License-Identifier: BSD-3-Clause
package cpu

type cpuTimes struct {
Expand Down
4 changes: 2 additions & 2 deletions cpu/cpu_openbsd.go
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
// SPDX-License-Identifier: BSD-3-Clause
//go:build openbsd
// +build openbsd

package cpu

Expand All @@ -9,7 +9,7 @@ import (
"runtime"
"unsafe"

"github.com/shirou/gopsutil/v3/internal/common"
"github.com/shirou/gopsutil/v4/internal/common"
"github.com/tklauser/go-sysconf"
"golang.org/x/sys/unix"
)
Expand Down
1 change: 1 addition & 0 deletions cpu/cpu_openbsd_386.go
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
// SPDX-License-Identifier: BSD-3-Clause
package cpu

type cpuTimes struct {
Expand Down
1 change: 1 addition & 0 deletions cpu/cpu_openbsd_amd64.go
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
// SPDX-License-Identifier: BSD-3-Clause
package cpu

type cpuTimes struct {
Expand Down
1 change: 1 addition & 0 deletions cpu/cpu_openbsd_arm.go
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
// SPDX-License-Identifier: BSD-3-Clause
package cpu

type cpuTimes struct {
Expand Down
1 change: 1 addition & 0 deletions cpu/cpu_openbsd_arm64.go
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
// SPDX-License-Identifier: BSD-3-Clause
package cpu

type cpuTimes struct {
Expand Down
1 change: 1 addition & 0 deletions cpu/cpu_openbsd_riscv64.go
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
// SPDX-License-Identifier: BSD-3-Clause
package cpu

type cpuTimes struct {
Expand Down
4 changes: 2 additions & 2 deletions cpu/cpu_plan9.go
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
// SPDX-License-Identifier: BSD-3-Clause
//go:build plan9
// +build plan9

package cpu

Expand All @@ -9,7 +9,7 @@ import (
"runtime"

stats "github.com/lufia/plan9stats"
"github.com/shirou/gopsutil/v3/internal/common"
"github.com/shirou/gopsutil/v4/internal/common"
)

func Times(percpu bool) ([]TimesStat, error) {
Expand Down
2 changes: 1 addition & 1 deletion cpu/cpu_plan9_test.go
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
// SPDX-License-Identifier: BSD-3-Clause
//go:build plan9
// +build plan9

package cpu

Expand Down
1 change: 1 addition & 0 deletions cpu/cpu_solaris.go
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
// SPDX-License-Identifier: BSD-3-Clause
package cpu

import (
Expand Down
1 change: 1 addition & 0 deletions cpu/cpu_solaris_test.go
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
// SPDX-License-Identifier: BSD-3-Clause
package cpu

import (
Expand Down
3 changes: 2 additions & 1 deletion cpu/cpu_test.go
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
// SPDX-License-Identifier: BSD-3-Clause
package cpu

import (
Expand All @@ -10,7 +11,7 @@ import (

"github.com/stretchr/testify/assert"

"github.com/shirou/gopsutil/v3/internal/common"
"github.com/shirou/gopsutil/v4/internal/common"
)

func skipIfNotImplementedErr(t *testing.T, err error) {
Expand Down
4 changes: 2 additions & 2 deletions cpu/cpu_windows.go
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
// SPDX-License-Identifier: BSD-3-Clause
//go:build windows
// +build windows

package cpu

Expand All @@ -8,7 +8,7 @@ import (
"fmt"
"unsafe"

"github.com/shirou/gopsutil/v3/internal/common"
"github.com/shirou/gopsutil/v4/internal/common"
"github.com/yusufpapurcu/wmi"
"golang.org/x/sys/windows"
)
Expand Down
3 changes: 2 additions & 1 deletion disk/disk.go
Original file line number Diff line number Diff line change
@@ -1,10 +1,11 @@
// SPDX-License-Identifier: BSD-3-Clause
package disk

import (
"context"
"encoding/json"

"github.com/shirou/gopsutil/v3/internal/common"
"github.com/shirou/gopsutil/v4/internal/common"
)

var invoke common.Invoker = common.Invoke{}
Expand Down
4 changes: 2 additions & 2 deletions disk/disk_aix.go
Original file line number Diff line number Diff line change
@@ -1,12 +1,12 @@
// SPDX-License-Identifier: BSD-3-Clause
//go:build aix
// +build aix

package disk

import (
"context"

"github.com/shirou/gopsutil/v3/internal/common"
"github.com/shirou/gopsutil/v4/internal/common"
)

func IOCountersWithContext(ctx context.Context, names ...string) (map[string]IOCountersStat, error) {
Expand Down
Loading

0 comments on commit 60f4fc7

Please sign in to comment.