Skip to content

rpccloud/goid

Repository files navigation

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