From 1e70916ca7e4d5c0ad00edbfd1877e06d7587fc6 Mon Sep 17 00:00:00 2001 From: "Santiago M. Mola" Date: Thu, 27 Jul 2017 17:16:34 +0200 Subject: format/config: add GoString This is more convenient for testing and debugging. --- plumbing/format/config/section.go | 23 ++++++++++++++++++++++- 1 file changed, 22 insertions(+), 1 deletion(-) (limited to 'plumbing/format/config/section.go') diff --git a/plumbing/format/config/section.go b/plumbing/format/config/section.go index 547da1e..eeefe84 100644 --- a/plumbing/format/config/section.go +++ b/plumbing/format/config/section.go @@ -1,6 +1,9 @@ package config -import "strings" +import ( + "fmt" + "strings" +) // Section is the representation of a section inside git configuration files. // Each Section contains Options that are used by both the Git plumbing @@ -36,8 +39,26 @@ type Subsection struct { type Sections []*Section +func (s Sections) GoString() string { + var strs []string + for _, ss := range s { + strs = append(strs, fmt.Sprintf("%#v", ss)) + } + + return strings.Join(strs, ", ") +} + type Subsections []*Subsection +func (s Subsections) GoString() string { + var strs []string + for _, ss := range s { + strs = append(strs, fmt.Sprintf("%#v", ss)) + } + + return strings.Join(strs, ", ") +} + // IsName checks if the name provided is equals to the Section name, case insensitive. func (s *Section) IsName(name string) bool { return strings.ToLower(s.Name) == strings.ToLower(name) -- cgit