runtime

package
v0.1.1 Latest Latest
Warning

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

Go to latest
Published: Oct 6, 2023 License: Apache-2.0 Imports: 21 Imported by: 0

Documentation

Index

Constants

View Source
const (
	// GOOS is the running program's operating system target:
	// one of darwin, freebsd, linux, and so on.
	// To view possible combinations of GOOS and GOARCH, run "go tool dist list".
	GOOS string = os.GOOS

	// GOARCH is the running program's architecture target:
	// one of 386, amd64, arm, s390x, and so on.
	GOARCH string = arch.GOARCH
)

Variables

This section is empty.

Functions

func GOARM

func GOARM() uint8

GOARM returns the GOARM environ used to build this application.

func GOMAXPROCS

func GOMAXPROCS(int) int

GOMAXPROCS returns 1.

func GOROOT

func GOROOT() string

GOROOT returns the root used during the Go build.

func KeepAlive

func KeepAlive(x any)

KeepAlive marks its argument as currently reachable. This ensures that the object is not freed, and its finalizer is not run, before the point in the program where KeepAlive is called.

A very simplified example showing where KeepAlive is required:

type File struct { d int }
d, err := syscall.Open("/file/path", syscall.O_RDONLY, 0)
// ... do something if err != nil ...
p := &File{d}
runtime.SetFinalizer(p, func(p *File) { syscall.Close(p.d) })
var buf [10]byte
n, err := syscall.Read(p.d, buf[:])
// Ensure p is not finalized until Read returns.
runtime.KeepAlive(p)
// No more uses of p after this point.

Without the KeepAlive call, the finalizer could run at the start of syscall.Read, closing the file descriptor before syscall.Read makes the actual system call.

Note: KeepAlive should only be used to prevent finalizers from running prematurely. In particular, when used with unsafe.Pointer, the rules for valid uses of unsafe.Pointer still apply.

func Version

func Version() string

Version returns the Go tree's version string. It is either the commit hash and date at the time of the build or, when possible, a release tag like "go1.3".

If any GOEXPERIMENTs are set to non-default values, it will include "X:<GOEXPERIMENT>".

Types

This section is empty.

Directories

Path Synopsis
Package asan to satisfy go linker `loadinternal` when building with -asan
Package asan to satisfy go linker `loadinternal` when building with -asan
Package cgo to satisfy go linker `loadinternal` when building with CGO_ENABLED=1
Package cgo to satisfy go linker `loadinternal` when building with CGO_ENABLED=1
Package msan to satisfy go linker `loadinternal` when building with -msan
Package msan to satisfy go linker `loadinternal` when building with -msan
Package race to satisfy go linker `loadinternal` when building with -race
Package race to satisfy go linker `loadinternal` when building with -race

Jump to

Keyboard shortcuts

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