Documentation
¶
Index ¶
- Constants
- Variables
- func BlockBySignal()
- func BlockBySignalAndCancel(cancel context.CancelFunc, duration time.Duration)
- func FindPrefixedEnvVars(environ []string, prefix string, element interface{}) []string
- func GeneratePID(path, name string) (string, error)
- func IsExported(f reflect.StructField) bool
- func ManualGC()
- func PrintStack()
- func RunCPUProfile() func()
- func RunMemProfile() func()
- func SignalContext() context.Context
- func Stack() []byte
- func Try(userFn func(), catchFn func(err interface{}))
- func VersionWithCommit(gitCommit, buildDate string) string
- type VersionModel
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 ¶
FindPrefixedEnvVars finds prefixed environment variables.
func GeneratePID ¶
func IsExported ¶
func IsExported(f reflect.StructField) bool
IsExported reports whether f is exported. https://golang.org/pkg/reflect/#StructField
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 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 VersionWithCommit ¶
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
Source Files
¶
Click to show internal directories.
Click to hide internal directories.