go有sql 格式化的相关包么?

feloxx · · 2483 次点击
https://github.com/jackc/sqlfmt 这个?
#1
更多评论
busgo
爱美女、爱大长腿!
这样? ``` go func CompressSQL(sqlStatement string) string { // Remove leading and trailing white spaces sqlStatement = strings.TrimSpace(sqlStatement) // Replace multiple spaces and newlines with a single space sqlStatement = regexp.MustCompile(`\s+`).ReplaceAllString(sqlStatement, " ") // Remove comments starting with '--' or '/*' and ending with '*/' sqlStatement = regexp.MustCompile(`--.*$|/\*.*?\*/`).ReplaceAllString(sqlStatement, "") // Remove unnecessary spaces around parentheses sqlStatement = regexp.MustCompile(`\s*([(),])\s*`).ReplaceAllString(sqlStatement, "$1") return sqlStatement } ```
#2
你猜这个2018年的兄弟还在写代码么
#3