Standard library / runtime

runtime.MemProfileRecord.Stack()

Return the prefix of Stack0 up to the first zero. Synthetic PCs here are not valid symbolization inputs. Expected stdout: '2\n'.

Formal Syntax & Structure

go syntaxgo
func (r *MemProfileRecord) Stack() []uintptr

Return Value

[]uintptr

Prefix of the stack buffer before the first zero PC.

Working Example

Example Snippetgo
package main
import (  "fmt"  "runtime")
func main() {  r := runtime.MemProfileRecord{Stack0: [32]uintptr{1, 2, 0, 9}}  fmt.Println(len(r.Stack()))}
Go Reference