github.com/daixiang0/gci@v0.13.0/pkg/section/section.go (about)

     1  package section
     2  
     3  import (
     4  	"github.com/daixiang0/gci/pkg/parse"
     5  	"github.com/daixiang0/gci/pkg/specificity"
     6  )
     7  
     8  // Section defines a part of the formatted output.
     9  type Section interface {
    10  	// MatchSpecificity returns how well an Import matches to this Section
    11  	MatchSpecificity(spec *parse.GciImports) specificity.MatchSpecificity
    12  
    13  	// String Implements the stringer interface
    14  	String() string
    15  
    16  	// return section type
    17  	Type() string
    18  }
    19  
    20  type SectionList []Section
    21  
    22  func (list SectionList) String() []string {
    23  	var output []string
    24  	for _, section := range list {
    25  		output = append(output, section.String())
    26  	}
    27  	return output
    28  }
    29  
    30  func DefaultSections() SectionList {
    31  	return SectionList{Standard{}, Default{}}
    32  }
    33  
    34  func DefaultSectionSeparators() SectionList {
    35  	return SectionList{NewLine{}}
    36  }