https://github.com/cloudwego/runtimex
Runtimex package help to expose Go Runtime internals representation safely.
https://github.com/cloudwego/runtimex
go golang runtime
Last synced: about 2 months ago
JSON representation
Runtimex package help to expose Go Runtime internals representation safely.
- Host: GitHub
- URL: https://github.com/cloudwego/runtimex
- Owner: cloudwego
- License: apache-2.0
- Created: 2024-05-09T02:44:33.000Z (about 1 year ago)
- Default Branch: main
- Last Pushed: 2025-02-19T07:00:37.000Z (4 months ago)
- Last Synced: 2025-04-05T12:33:10.227Z (3 months ago)
- Topics: go, golang, runtime
- Language: Go
- Homepage:
- Size: 19.5 KB
- Stars: 13
- Watchers: 5
- Forks: 2
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- Contributing: CONTRIBUTING.md
- License: LICENSE-APACHE
- Code of conduct: CODE_OF_CONDUCT.md
Awesome Lists containing this project
README
# runtimex
Runtimex package help to expose Go Runtime internals representation safely.
## Usage
### Get Goroutine ID
```go
gid, err := runtimex.GID()
```### Get Processor ID
```go
pid, err := runtimex.PID()
```## Note
Since we use a hack way to expose internal representation of the Go runtime, so if Go change some internal variable names, the package will return error.
You should care about the error returned by runtimex and do the fallback logic If necessary.
For now, we only depend on `runtime.g` and `g.goid`.