From 6e2cb00008cbf09e556b00f87603797fcaa47e09 Mon Sep 17 00:00:00 2001 From: Christopher Speller Date: Mon, 16 Apr 2018 05:37:14 -0700 Subject: Depenancy upgrades and movign to dep. (#8630) --- vendor/github.com/go-ini/ini/file.go | 15 ++++++++++++--- 1 file changed, 12 insertions(+), 3 deletions(-) (limited to 'vendor/github.com/go-ini/ini/file.go') diff --git a/vendor/github.com/go-ini/ini/file.go b/vendor/github.com/go-ini/ini/file.go index ce26c3b31..d7982c323 100644 --- a/vendor/github.com/go-ini/ini/file.go +++ b/vendor/github.com/go-ini/ini/file.go @@ -140,9 +140,14 @@ func (f *File) Section(name string) *Section { // Section returns list of Section. func (f *File) Sections() []*Section { + if f.BlockMode { + f.lock.RLock() + defer f.lock.RUnlock() + } + sections := make([]*Section, len(f.sectionList)) - for i := range f.sectionList { - sections[i] = f.Section(f.sectionList[i]) + for i, name := range f.sectionList { + sections[i] = f.sections[name] } return sections } @@ -223,7 +228,7 @@ func (f *File) Append(source interface{}, others ...interface{}) error { func (f *File) writeToBuffer(indent string) (*bytes.Buffer, error) { equalSign := "=" - if PrettyFormat { + if PrettyFormat || PrettyEqual { equalSign = " = " } @@ -300,6 +305,10 @@ func (f *File) writeToBuffer(indent string) (*bytes.Buffer, error) { } else { key.Comment = key.Comment[:1] + " " + strings.TrimSpace(key.Comment[1:]) } + + // Support multiline comments + key.Comment = strings.Replace(key.Comment, "\n", "\n; ", -1) + if _, err := buf.WriteString(key.Comment + LineBreak); err != nil { return nil, err } -- cgit v1.2.3-1-g7c22