jingc1413 / goid

An elegant way to get goroutine id

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

goid

Test Lint codecov Go Report Card

An elegant way to get goroutine id

Usage

package main

import (
  "fmt"
  "github.com/rpccloud/goid"
)

func main() {
  fmt.Println("Current Goroutine ID:", goid.GetRoutineId())
}

Benchmark

$ go test -bench=.
goos: darwin
goarch: amd64
pkg: github.com/rpccloud/goid
BenchmarkGetRoutineId-12         1000000000               0.413 ns/op           0 B/op          0 allocs/op
PASS
ok      github.com/rpccloud/goid        1.040s

About

An elegant way to get goroutine id

License:MIT License


Languages

Language:Go 65.5%Language:Assembly 25.1%Language:C 9.4%