helper

package
v1.4.4 Latest Latest
Warning

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

Go to latest
Published: Nov 22, 2026 License: MIT Imports: 9 Imported by: 1 module, 0 packages

The first number is the count of modules that contain a package that imports this one. The module count is a better indicator of popularity than the package count. A module with 100 importing packages is counted only once instead of 100 times, reflecting the fact that the choice to use the package was likely made only once, not 100 times.
A '?' means that the value hasn't been computed yet.

Documentation

Overview

Package helper 提供官方插件 helper 的启动与协议辅助。

三个 helper 共用同一套内存预算、JSON 编解码与错误退出约定, 避免实现随时间产生差异。

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func ApplyMemoryLimit

func ApplyMemoryLimit()

ApplyMemoryLimit 根据主程序传入的预算设置 Go 堆软上限。 硬性的常驻内存限制由主程序轮询 RSS 并在超限时结束进程实现, 这里不使用 RLIMIT_AS:Go 运行时需要预留大量虚拟地址空间。

func Fail

func Fail(message string)

Fail 把错误写入 stderr 并以非 0 退出。

func Failf

func Failf(format string, args ...any)

Failf 是 Fail 的格式化版本。

func HasFeature

func HasFeature(name string) bool

HasFeature 判断主程序是否声明了某个插件特性。 保留兼容行为:同时读取部署与 DNS 两套环境变量。

func HasFeatureIn added in v1.4.2

func HasFeatureIn(env, name string) bool

HasFeatureIn 只读取指定的环境变量,避免 deploy/DNS 特性串用。

func ReadJSON

func ReadJSON(v any) error

ReadJSON 从 stdin 解码一个 JSON 对象,并限制最大输入大小。

func Recover added in v1.4.2

func Recover()

Recover 捕获插件 panic,避免把完整栈和可能含凭据的 panic 值写入日志。

func WriteJSON

func WriteJSON(v any) error

WriteJSON 把 v 编码到 stdout,保留非 ASCII 字符且不转义 HTML。

Types

This section is empty.

Jump to

Keyboard shortcuts

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