zstdzgo.at/zstd/zruntime Index | Files

package zruntime

import "zgo.at/zstd/zruntime"

Package zruntime provides utilities to interface with the Go runtime.

Index

Constants

const CGO = true

CGO reports if this is build with cgo.

const Race = false

Race reports if the race detector is enabled.

Functions

func Callers

func Callers(filterFun ...string) []runtime.Frame

Callers gets a list of callers.

func FuncName

func FuncName(f any) string

FuncName gets the name of a function.

func GoroutineID

func GoroutineID() uint64

GoroutineID gets the current goroutine ID.

Go doesn't give access to this to discourage certain unwise design patterns, but in some cases it can still be useful; for example for some tests or debugging.

func SizeOf

func SizeOf(v any) int64

SizeOf gets the memory size of an object in bytes.

This recurses struct fields and pointers, but there are a few limitations:

  1. Space occupied by code and data reachable through variables captured in the closure of a function pointer are not counted. A value of function type is counted only as a pointer.

  2. Unused buckets of a map cannot be inspected by the reflect package. Their size is estimated by assuming unfilled slots contain zeroes of their type.

  3. Unused capacity of the array underlying a slice is estimated by assuming the unused slots contain zeroes of their type. It is possible they contain non zero values from sharing or reslicing, but without explicitly reslicing the reflect package cannot touch them.

This is adapted from: https://github.com/creachadair/misctools/blob/master/sizeof/size.go

Also see: https://github.com/golang/go/issues/34561

func Test

func Test() bool

Test reports if we're running a go test command.

func TestVerbose

func TestVerbose() bool

TestVerbose reports if the test was started with the -v flag.

Source Files

cgo.go race_off.go zruntime.go

Version
v0.0.0-20240930202209-a63c3335042a (latest)
Published
Sep 30, 2024
Platform
linux/amd64
Imports
9 packages
Last checked
2 days ago

Tools for package owners.