Documentation ¶
Index ¶
Examples ¶
Constants ¶
This section is empty.
Variables ¶
var ErrInvalidEscapeSequence = errors.New("unknown escape sequence")
ErrInvalidEscapeSequence indicates that the escape character ('\') was followed by an invalid character.
var ErrInvalidKeyChar = errors.New("invalid key character")
ErrInvalidKeyChar indicates that there was an invalid key character
var ErrInvalidSectionChar = errors.New("invalid character in section")
ErrInvalidSectionChar indicates that there was an invalid character in section
var ErrMissingClosingBracket = errors.New("missing closing section bracket")
ErrMissingClosingBracket indicates that there was a missing closing bracket in section
var ErrMissingEquals = errors.New("expected '='")
ErrMissingEquals indicates that an equals sign ('=') was expected but not found
var ErrMissingStartQuote = errors.New("missing start quote")
ErrMissingStartQuote indicates that there was a missing start quote
var ErrPartialBOM = errors.New("partial UTF8-BOM")
ErrPartialBOM indicates that the file begins with a partial UTF8-BOM
var ErrSectionNewLine = errors.New("newline in section")
ErrSectionNewLine indicates that there was a newline in section
var ErrUnexpectedEOF = errors.New("unexpected EOF")
ErrUnexpectedEOF indicates that there was an unexpected EOF
var ErrUnfinishedQuote = errors.New("unfinished quote")
ErrUnfinishedQuote indicates that a value has an odd number of (unescaped) quotes
Functions ¶
func Parse ¶
Parse takes given bytes as configuration file (according to gitconfig syntax)
Example ¶
gitconfig := "configs/danyel.gitconfig" bytes, err := ioutil.ReadFile(gitconfig) if err != nil { log.Fatalf("Couldn't read file %v\n", gitconfig) } config, lineno, err := Parse(bytes) if err != nil { log.Fatalf("Error on line %d: %v\n", lineno, err) } fmt.Println() fmt.Println(lineno) fmt.Println(config["user.name"]) fmt.Println(config["user.email"])
Output: 10 Danyel Bayraktar cydrop@gmail.com
Types ¶
This section is empty.