| : 传递参数
在tpl中 { {.price | printf "%.2f" }} 做格式化取小数点后2位
结果 123.46
call :调用函数
在tpl中 { {call .function .x .y}}
结果 5
and : 取第一个空值,如果全部非空,就取最后一个非空值
在tpl中 { {and .x .y .z}}
结果:false
模板中的空值
- false ,0
- 指针类型的0:nil
- interface
- 长度为0的array,slice,map,string
index :
-
map的键是int类型<