package
Version:
v0.2.5
Opens a new window with list of versions in this module.
Published: Nov 13, 2025
License: MIT
Opens a new window with license information.
Imports: 1
Opens a new window with list of imports.
Imported by: 1
Opens a new window with list of known importers.
Documentation
¶
As 尝试将任意类型 v 转换为 T 类型,内部基于 gconv 实现,支持:
1. 基本类型互转(如 string ↔ int、bool ↔ float 等);
2. 复合类型转换(如 slice ↔ array、map ↔ struct 等,需符合 gconv 规则)。
返回转换后的值和是否成功(true 表示转换有效)。
If 实现两种功能:
1. 三元运算:当传入 trueVal 和 falseVal 时,返回对应值
2. 条件执行:当传入 f(或 f、g)时,执行对应函数
注:两种功能通过参数类型区分,互斥使用
注意:Go 语言中,函数参数会先求值再传递,因此如果传入的函数有副作用,需要注意顺序问题。
Source Files
¶
Click to show internal directories.
Click to hide internal directories.