file: add DefaultFormat option around equal sign (#164)

Add option to have padding spaces around equal sign when PrettyFormat is disabled #161

eg:

> ini.PrettyFormat = false
>         ini.DefaultFormatLeft = "  "
>         ini.DefaultFormatRight = " "
This commit is contained in:
haroldHT
2018-09-30 13:33:52 -04:00
committed by 无闻
parent fa25069db3
commit 5b4a947444
2 changed files with 6 additions and 1 deletions
+2 -1
View File
@@ -227,7 +227,8 @@ func (f *File) Append(source interface{}, others ...interface{}) error {
} }
func (f *File) writeToBuffer(indent string) (*bytes.Buffer, error) { func (f *File) writeToBuffer(indent string) (*bytes.Buffer, error) {
equalSign := "=" equalSign := DefaultFormatLeft + "=" + DefaultFormatRight
if PrettyFormat || PrettyEqual { if PrettyFormat || PrettyEqual {
equalSign = " = " equalSign = " = "
} }
+4
View File
@@ -48,6 +48,10 @@ var (
// at package init time. // at package init time.
LineBreak = "\n" LineBreak = "\n"
// Place custom spaces when PrettyFormat and PrettyEqual are both disabled
DefaultFormatLeft = ""
DefaultFormatRight = ""
// Variable regexp pattern: %(variable)s // Variable regexp pattern: %(variable)s
varPattern = regexp.MustCompile(`%\(([^\)]+)\)s`) varPattern = regexp.MustCompile(`%\(([^\)]+)\)s`)