Documentation ¶
Overview ¶
Package config implements decoding, encoding and manipulation of git config files.
Index ¶
- Constants
- type Comment
- type Config
- func (s *Config) AddOption(section string, subsection string, key string, value string) *Config
- func (c *Config) RemoveSection(name string) *Config
- func (c *Config) RemoveSubsection(section string, subsection string) *Config
- func (c *Config) Section(name string) *Section
- func (s *Config) SetOption(section string, subsection string, key string, value string) *Config
- type Decoder
- type Encoder
- type Include
- type Includes
- type Option
- type Options
- type Section
- func (s *Section) AddOption(key string, value string) *Section
- func (s *Section) HasSubsection(name string) bool
- func (s *Section) IsName(name string) bool
- func (s *Section) Option(key string) string
- func (s *Section) RemoveOption(key string) *Section
- func (s *Section) SetOption(key string, value string) *Section
- func (s *Section) Subsection(name string) *Subsection
- type Sections
- type Subsection
- type Subsections
Constants ¶
const (
NoSubsection = ""
)
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type Config ¶
func (*Config) AddOption ¶
AddOption is a convenience method to add an option to a given section and subsection.
Use the NoSubsection constant for the subsection argument if no subsection is wanted.
func (*Config) RemoveSection ¶
func (*Config) RemoveSubsection ¶
type Decoder ¶
A Decoder reads and decodes config files from an input stream.
func NewDecoder ¶
NewDecoder returns a new decoder that reads from r.
type Encoder ¶
type Encoder struct {
// contains filtered or unexported fields
}
An Encoder writes config files to an output stream.
func NewEncoder ¶
NewEncoder returns a new encoder that writes to w.
type Option ¶
type Options ¶
type Options []*Option
func (Options) Get ¶
Get gets the value for the given key if set, otherwise it returns the empty string.
Note that there is no difference ¶
This matches git behaviour since git v1.8.1-rc1, if there are multiple definitions of a key, the last one wins.
See: http://article.gmane.org/gmane.linux.kernel/1407184
In order to get all possible values for the same key, use GetAll.
type Section ¶
type Section struct { Name string Options Options Subsections Subsections }
func (*Section) HasSubsection ¶
func (*Section) RemoveOption ¶
func (*Section) Subsection ¶
func (s *Section) Subsection(name string) *Subsection
type Subsection ¶
func (*Subsection) AddOption ¶
func (s *Subsection) AddOption(key string, value string) *Subsection
func (*Subsection) IsName ¶
func (s *Subsection) IsName(name string) bool
func (*Subsection) Option ¶
func (s *Subsection) Option(key string) string
func (*Subsection) RemoveOption ¶
func (s *Subsection) RemoveOption(key string) *Subsection
func (*Subsection) SetOption ¶
func (s *Subsection) SetOption(key string, value string) *Subsection
type Subsections ¶
type Subsections []*Subsection