v1.18.0-beta1 Latest Latest

This package is not in the latest version of its module.

Go to latest
Published: Aug 17, 2022 License: BSD-2-Clause Imports: 1 Imported by: 0


Rendered for js/wasm



View Source
const Compiler = "gopherjs"
View Source
const GOARCH = "ecmascript"
View Source
const GOOS = "js"


View Source
var MemProfileRate int = 512 * 1024


func Breakpoint

func Breakpoint()

func Caller

func Caller(skip int) (pc uintptr, file string, line int, ok bool)

func Callers

func Callers(skip int, pc []uintptr) int

Callers fills the slice pc with the return program counters of function invocations on the calling goroutine's stack. The argument skip is the number of stack frames to skip before recording in pc, with 0 identifying the frame for Callers itself and 1 identifying the caller of Callers. It returns the number of entries written to pc.

The returned call stack represents the logical Go call stack, which excludes certain runtime-internal call frames that would be present in the raw JavaScript stack trace. This is done to improve interoperability with the upstream Go. Use JavaScript native APIs to access the raw call stack.

To translate these PCs into symbolic information such as function names and line numbers, use CallersFrames. CallersFrames accounts for inlined functions and adjusts the return program counters into call program counters. Iterating over the returned slice of PCs directly is discouraged, as is using FuncForPC on any of the returned PCs, since these cannot account for inlining or return program counter adjustment.

func GC

func GC()


func GOMAXPROCS(int) int


func GOROOT() string

func Goexit

func Goexit()

func Gosched

func Gosched()

func KeepAlive

func KeepAlive(interface{})

func LockOSThread

func LockOSThread()

func NumCPU

func NumCPU() int

func NumCgoCall

func NumCgoCall() int64

We fake a cgo environment to catch errors. Therefor we have to implement this and always return 0

func NumGoroutine

func NumGoroutine() int

func ParseCallFrame added in v1.17.2

func ParseCallFrame(info *js.Object) basicFrame

ParseCallFrame is exported for the sake of testing. See this discussion for context

TLDR; never use this function!

func ReadMemStats

func ReadMemStats(m *MemStats)

func ReadTrace

func ReadTrace() []byte

func SetBlockProfileRate

func SetBlockProfileRate(rate int)

func SetFinalizer

func SetFinalizer(x, f interface{})

func SetMutexProfileFraction

func SetMutexProfileFraction(rate int) int

func Stack

func Stack(buf []byte, all bool) int

Stack formats a stack trace of the calling goroutine into buf and returns the number of bytes written to buf. If all is true, Stack formats stack traces of all other goroutines into buf after the trace for the current goroutine.

Unlike runtime.Callers(), it returns an unprocessed, runtime-specific text representation of the JavaScript stack trace.

func StartTrace

func StartTrace() error

func StopTrace

func StopTrace()

func UnlockOSThread

func UnlockOSThread()

func Version

func Version() string


type Error added in v1.17.2

type Error interface {

	// RuntimeError is a no-op function but
	// serves to distinguish types that are run time
	// errors from ordinary errors: a type is a
	// run time error if it has a RuntimeError method.

The Error interface identifies a run time error.

type Frame

type Frame struct {
	PC       uintptr
	Func     *Func
	Function string
	File     string
	Line     int
	Entry    uintptr

type Frames

type Frames struct {
	// contains filtered or unexported fields

func CallersFrames

func CallersFrames(callers []uintptr) *Frames

func (*Frames) Next

func (ci *Frames) Next() (frame Frame, more bool)

type Func

type Func struct {
	// contains filtered or unexported fields

func FuncForPC

func FuncForPC(pc uintptr) *Func

func (*Func) Entry

func (_ *Func) Entry() uintptr

func (*Func) FileLine

func (f *Func) FileLine(pc uintptr) (file string, line int)

func (*Func) Name

func (f *Func) Name() string

type MemStats

type MemStats struct {
	// General statistics.
	Alloc      uint64 // bytes allocated and still in use
	TotalAlloc uint64 // bytes allocated (even if freed)
	Sys        uint64 // bytes obtained from system (sum of XxxSys below)
	Lookups    uint64 // number of pointer lookups
	Mallocs    uint64 // number of mallocs
	Frees      uint64 // number of frees

	// Main allocation heap statistics.
	HeapAlloc    uint64 // bytes allocated and still in use
	HeapSys      uint64 // bytes obtained from system
	HeapIdle     uint64 // bytes in idle spans
	HeapInuse    uint64 // bytes in non-idle span
	HeapReleased uint64 // bytes released to the OS
	HeapObjects  uint64 // total number of allocated objects

	// Low-level fixed-size structure allocator statistics.
	//	Inuse is bytes used now.
	//	Sys is bytes obtained from system.
	StackInuse  uint64 // bytes used by stack allocator
	StackSys    uint64
	MSpanInuse  uint64 // mspan structures
	MSpanSys    uint64
	MCacheInuse uint64 // mcache structures
	MCacheSys   uint64
	BuckHashSys uint64 // profiling bucket hash table
	GCSys       uint64 // GC metadata
	OtherSys    uint64 // other system allocations

	// Garbage collector statistics.
	NextGC        uint64 // next collection will happen when HeapAlloc ≥ this amount
	LastGC        uint64 // end time of last collection (nanoseconds since 1970)
	PauseTotalNs  uint64
	PauseNs       [256]uint64 // circular buffer of recent GC pause durations, most recent at [(NumGC+255)%256]
	PauseEnd      [256]uint64 // circular buffer of recent GC pause end times
	NumGC         uint32
	GCCPUFraction float64 // fraction of CPU time used by GC
	EnableGC      bool
	DebugGC       bool

	// Per-size allocation statistics.
	// 61 is NumSizeClasses in the C code.
	BySize [61]struct {
		Size    uint32
		Mallocs uint64
		Frees   uint64

type TypeAssertionError added in v1.17.2

type TypeAssertionError struct {
	// contains filtered or unexported fields

A TypeAssertionError explains a failed type assertion.

func (*TypeAssertionError) Error added in v1.17.2

func (e *TypeAssertionError) Error() string

func (*TypeAssertionError) RuntimeError added in v1.17.2

func (*TypeAssertionError) RuntimeError()


Path Synopsis

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL