Replace the section component from entries in favor of parser state
This commit is contained in:
		
							parent
							
								
									d68ddf1164
								
							
						
					
					
						commit
						01e7b4f450
					
				
							
								
								
									
										9
									
								
								ini.go
									
									
									
									
									
								
							
							
						
						
									
										9
									
								
								ini.go
									
									
									
									
									
								
							@ -14,7 +14,6 @@ type Builder struct {
 | 
			
		||||
 | 
			
		||||
// Singular key-value pair under the given section within an INI file.
 | 
			
		||||
type Entry struct {
 | 
			
		||||
	Section string
 | 
			
		||||
	Key   string
 | 
			
		||||
	Value string
 | 
			
		||||
}
 | 
			
		||||
@ -87,7 +86,6 @@ func (parser *Parser) Parse() Entry {
 | 
			
		||||
		if assignmentIndex := strings.Index(line, "="); assignmentIndex > -1 {
 | 
			
		||||
			// Key with value.
 | 
			
		||||
			return Entry{
 | 
			
		||||
				Section: parser.section,
 | 
			
		||||
				Key:   unquote(strings.TrimSpace(line[0:assignmentIndex])),
 | 
			
		||||
				Value: unquote(strings.TrimSpace(line[assignmentIndex+1:])),
 | 
			
		||||
			}
 | 
			
		||||
@ -97,7 +95,6 @@ func (parser *Parser) Parse() Entry {
 | 
			
		||||
		var keyValue = unquote(line[1:lineTail])
 | 
			
		||||
 | 
			
		||||
		return Entry{
 | 
			
		||||
			Section: parser.section,
 | 
			
		||||
			Key:   keyValue,
 | 
			
		||||
			Value: keyValue,
 | 
			
		||||
		}
 | 
			
		||||
@ -117,6 +114,12 @@ type Parser struct {
 | 
			
		||||
	isEnd   bool
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
// Returns the name of the section last parsed, which will an empty string if currently in the
 | 
			
		||||
// default section.
 | 
			
		||||
func (parser *Parser) Section() string {
 | 
			
		||||
	return parser.section
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
// Appends a new section titled `name` in the `builder`.
 | 
			
		||||
func (builder *Builder) Section(name string) error {
 | 
			
		||||
	var _, printError = fmt.Fprintf(builder.writer, "[%s]\n", name)
 | 
			
		||||
 | 
			
		||||
		Loading…
	
	
			
			x
			
			
		
	
		Reference in New Issue
	
	Block a user