22 lines
499 B
Go
22 lines
499 B
Go
package util
|
||
|
||
import (
|
||
"encoding/json"
|
||
"strings"
|
||
)
|
||
|
||
// 占位符替换 xxx{placeholder}xxx
|
||
func ReplacePlaceholder(str string, placeholder string, value string) string {
|
||
return strings.ReplaceAll(str, "{"+placeholder+"}", value)
|
||
}
|
||
|
||
// 构建跳转a标签,新tab打开
|
||
func BuildJumpLink(url string, text string) string {
|
||
return "<a href=\"" + url + "\" target=\"_blank\">" + text + "</a>"
|
||
}
|
||
|
||
func EscapeJSONString(s string) string {
|
||
b, _ := json.Marshal(s)
|
||
return string(b[1 : len(b)-1])
|
||
}
|