1 Commits
Author SHA1 Message Date
xiaoqidun c2ceb7dea7 style(代码风格): 保持代码良好的可维护性 2026-08-19 14:37:44 +08:00
+19 -19
View File
@@ -358,6 +358,25 @@ func renderLine(line iniLine) string {
} }
} }
func renderKeyValue(line iniLine) string {
separator := line.separator
if separator == "" {
separator = defaultSeparator
}
return line.indent + line.keyName + separator + formatValue(line.keyValue)
}
func formatValue(value string) string {
if strings.TrimSpace(value) == value && !hasSurroundingQuotes(value) {
return value
}
quote := `"`
if strings.HasPrefix(value, `"`) && strings.HasSuffix(value, `"`) {
quote = "`"
}
return quote + value + quote
}
func (ini *GoINI) formatString() string { func (ini *GoINI) formatString() string {
formattedLines := make([]string, 0, len(ini.fileLines)) formattedLines := make([]string, 0, len(ini.fileLines))
pendingComments := make([]string, 0) pendingComments := make([]string, 0)
@@ -393,25 +412,6 @@ func formatINIComment(comment string) string {
return "# " + comment return "# " + comment
} }
func renderKeyValue(line iniLine) string {
separator := line.separator
if separator == "" {
separator = defaultSeparator
}
return line.indent + line.keyName + separator + formatValue(line.keyValue)
}
func formatValue(value string) string {
if strings.TrimSpace(value) == value && !hasSurroundingQuotes(value) {
return value
}
quote := `"`
if strings.HasPrefix(value, `"`) && strings.HasSuffix(value, `"`) {
quote = "`"
}
return quote + value + quote
}
func matchStrings(items []string, match string) []string { func matchStrings(items []string, match string) []string {
if match == "" { if match == "" {
return cloneStrings(items) return cloneStrings(items)