sys

package
v0.0.1 Latest Latest
Warning

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

Go to latest
Published: May 2, 2025 License: Apache-2.0 Imports: 19 Imported by: 0

Documentation

Index

Constants

View Source
const (
	GcSize = 50 << 20 //默认50MB
)

Variables

View Source
var (
	VersionMajor = 0          // Major version component of the current release
	VersionMinor = 0          // Minor version component of the current release
	VersionPatch = 1          // Patch version component of the current release
	VersionMeta  = "snapshot" // Version metadata to append to the version string   stable   snapshot
)
View Source
var VersionStr = func() string {
	return fmt.Sprintf("%d.%d.%d", VersionMajor, VersionMinor, VersionPatch)
}
View Source
var VersionWithMeta = func() string {
	v := VersionStr()
	if VersionMeta != "" {
		v += "-" + VersionMeta
	}
	return v
}

VersionWithMeta holds the textual version string including the metadata.

Functions

func BlockBySignal

func BlockBySignal()

func BlockBySignalAndCancel

func BlockBySignalAndCancel(cancel context.CancelFunc, duration time.Duration)

func FindPrefixedEnvVars

func FindPrefixedEnvVars(environ []string, prefix string, element interface{}) []string

FindPrefixedEnvVars finds prefixed environment variables.

func GeneratePID

func GeneratePID(path, name string) (string, error)

func IsExported

func IsExported(f reflect.StructField) bool

IsExported reports whether f is exported. https://golang.org/pkg/reflect/#StructField

func ManualGC

func ManualGC()

ManualGC 手动释放堆中准备重用的一些内存

func PrintStack

func PrintStack()

PrintStack prints to standard error the stack trace returned by runtime.Stack.

func RunCPUProfile

func RunCPUProfile() func()

RunCPUProfile Run starts up stuff at the beginning of a main function, and returns a function to defer until the function completes. It should be used like this:

func main() {
  defer sys.RunCPUProfile()()
  ... stuff ...
}

func RunMemProfile

func RunMemProfile() func()

func SignalContext

func SignalContext() context.Context

func Stack

func Stack() []byte

Stack returns a formatted stack trace of the goroutine that calls it. It calls runtime.Stack with a large enough buffer to capture the entire trace.

func Try

func Try(userFn func(), catchFn func(err interface{}))

func VersionWithCommit

func VersionWithCommit(gitCommit, buildDate string) string

Types

type VersionModel

type VersionModel struct {
	Identify  string `json:"id"`
	Version   string `json:"version"`
	Commit    string `json:"commit"`
	BuildDate string `json:"buildDate"`
	Arch      string `json:"arch"`
	GoVersion string `json:"goVersion"`
	GoOS      string `json:"goos"`
	GoPath    string `json:"goPath"`
	GoRoot    string `json:"goRoot"`
}

func Version

func Version() VersionModel

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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