An elegant way to get goroutine id
package main
import (
"fmt"
"github.com/rpccloud/goid"
)
func main() {
fmt.Println("Current Goroutine ID:", goid.GetRoutineId())
}
$ 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