Documentation
¶
Index ¶
- Constants
- func DetectProxyEnv() (key, value string)
- func FallbackTransport() *http.Transport
- func IsEmptyValue(v interface{}) bool
- func IsNil(v interface{}) bool
- func NewBaseTransport() *http.Transport
- func ToFloat64(v interface{}) (float64, bool)
- func TruncateStr(s string, n int) string
- func TruncateStrWithEllipsis(s string, n int) string
- func WarnIfProxied(w io.Writer)
Constants ¶
const (
// EnvNoProxy disables automatic proxy support when set to any non-empty value.
EnvNoProxy = "LARK_CLI_NO_PROXY"
)
Variables ¶
This section is empty.
Functions ¶
func DetectProxyEnv ¶ added in v1.0.4
func DetectProxyEnv() (key, value string)
DetectProxyEnv returns the first proxy-related environment variable that is set, or empty strings if none are configured.
func FallbackTransport ¶ added in v1.0.4
FallbackTransport returns a shared *http.Transport singleton suitable for use as a fallback when a transport decorator's Base is nil. Unlike NewBaseTransport (which clones per call), this reuses a single instance so that TCP connections and TLS sessions are pooled.
func IsEmptyValue ¶
func IsEmptyValue(v interface{}) bool
IsEmptyValue checks whether v is considered empty using reflect. Returns true for nil interface, and zero values of the underlying type (e.g. "", 0, false, empty slice/map).
func IsNil ¶
func IsNil(v interface{}) bool
IsNil reports whether v is nil, covering both untyped nil (interface itself) and typed nil (e.g. (*T)(nil) wrapped in interface{}). Avoids direct interface{} == nil comparison .
func NewBaseTransport ¶ added in v1.0.4
NewBaseTransport creates an *http.Transport cloned from http.DefaultTransport. If LARK_CLI_NO_PROXY is set, proxy support is disabled. Each call returns a new instance; use FallbackTransport for a shared singleton.
func ToFloat64 ¶
ToFloat64 extracts a float64 from a value that may be float64 or json.Number. Returns (0, false) if the value is neither.
func TruncateStr ¶
TruncateStr truncates s to at most n runes, safe for multi-byte (e.g. CJK) characters.
func TruncateStrWithEllipsis ¶
TruncateStrWithEllipsis truncates s to at most n runes (including "..." suffix).
func WarnIfProxied ¶ added in v1.0.4
WarnIfProxied prints a one-time warning to w when a proxy environment variable is detected and proxy is not disabled via LARK_CLI_NO_PROXY. Proxy credentials are redacted. Safe to call multiple times; only the first call prints.
Types ¶
This section is empty.