Documentation
¶
Index ¶
- func PadStart(s string, length int, pad string) string
- func RemoveSqlComments(line string, inMultiLineComment bool) (processedLine string, stillInComment bool)
- func ReplaceSqlStringContent(line string, expectedEnd string, vPlaceholder ...string) (processedLine string, nextExpectedEnd string)
- type DelimiterInfo
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func RemoveSqlComments ¶
func ReplaceSqlStringContent ¶
func ReplaceSqlStringContent(line string, expectedEnd string, vPlaceholder ...string) (processedLine string, nextExpectedEnd string)
ReplaceSqlStringContent 替换 SQL 字符串内容为占位符。
参数:
- line: SQL 语句行
- expectedEnd: 期望的字符串结束符
- vPlaceholder: 可选的占位符字符串(默认 "___STR___")
返回值:
- string: 处理后的行
- string: 下一个期望的结束符
用法:
line := "SELECT * FROM users WHERE name = 'John'" processed, nextEnd := ReplaceSqlStringContent(line, "") // processed 中字符串内容被替换为占位符
局限:
- 用于 SQL 解析时的字符串处理
- 复杂的 SQL 语句可能无法正确处理
Types ¶
type DelimiterInfo ¶
DelimiterInfo 用于存储找到的分隔符信息
func FindDelimiters ¶
func FindDelimiters(str, sep string) []DelimiterInfo
FindDelimiters 查找字符串中所有连续的分隔符。
参数:
- str: 需要查找的字符串
- sep: 分隔符字符串
返回值:
- []DelimiterInfo: 包含分隔符信息的切片
用法:
delimiters := FindDelimiters("hello,,,world,,test", ",")
// delimiters[0] = DelimiterInfo{S: ",,,", P: 5}
// delimiters[1] = DelimiterInfo{S: ",,", P: 16}
特点:
- 合并连续的分隔符
- 返回分隔符的位置
局限:
- 分隔符为空时返回空切片
- 不支持正则表达式分隔符
Click to show internal directories.
Click to hide internal directories.