Skip to content

Commit

Permalink
Add a link to v4 release note and Ex struct in README.
Browse files Browse the repository at this point in the history
  • Loading branch information
shirou committed Jun 1, 2024
1 parent 3489a34 commit 184fb1c
Showing 1 changed file with 26 additions and 1 deletion.
27 changes: 26 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ challenge is porting all psutil functions on some architectures.

### v4 migration

See v4 release note.
There are some breaking changes. Please see [v4 release note](https://github.com/shirou/gopsutil/releases/tag/v4.24.5).

## Tag semantics

Expand Down Expand Up @@ -118,6 +118,31 @@ Be very careful that enabling the cache may cause inconsistencies. For example,
- `process`
- EnableBootTimeCache

### `Ex` struct (from v4.24.5)

gopsutil is designed to work across multiple platforms. However, there are differences in the information available on different platforms, such as memory information that exists on Linux but not on Windows.

As of v4.24.5, to access this platform-specific information, gopsutil provides functions named `Ex` within the package. Currently, these functions are available in the mem and sensor packages.

The Ex structs are specific to each platform. For example, on Linux, there is an `ExLinux` struct, which can be obtained using the `mem.NewExLinux()` function. On Windows, it's `mem.ExWindows()`. These Ex structs provide platform-specific information.

```
ex := NewExWindows()
v, err := ex.VirtualMemory()
if err != nil {
panic(err)
}
fmt.Println(v.VirtualAvail)
fmt.Println(v.VirtualTotal)
// Output:
// 140731958648832
// 140737488224256
```

gopsutil aims to minimize platform differences by offering common functions. However, there are many requests to obtain unique information for each platform. The Ex structs are designed to meet those requests. Additional functionalities might be added in the future. The use of these structures makes it clear that the information they provide is specific to each platform, which is why they have been designed in this way.

## Documentation

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

0 comments on commit 184fb1c

Please sign in to comment.