func (sec *Section) get(key, def string) (val string, ok bool) {
	val = def
	if len(sec.vars) == 0 || len(key) == 0 {
		return
	}
	x := len(sec.vars) - 1
	key = strings.ToLower(key)
	for ; x >= 0; x-- {
		if sec.vars[x].keyLower != key {
			continue
		}
		val = sec.vars[x].value
		ok = true
		break
	}
	return
}
get will return the last variable value based on key.
If no key found it will return default value and false.
package ini
import (
	"bytes"
	"fmt"
	"strings"
)
type Section struct {
	mode      lineMode
	lineNum   int
	name      string
	sub       string
	format    string
	nameLower string
	others    string
	vars      []*variable
}
func newSection(name, subName string) (sec *Section) {
	if len(name) == 0 {
		return
	}
	sec = &Section{
		mode: lineModeSection,
		name: name,
	}
	sec.nameLower = strings.ToLower(sec.name)
	if len(subName) > 0 {
		sec.mode |= lineModeSubsection
		sec.sub = subName
	}
	return
}
func (sec *Section) Name() string {
	return sec.name
}
func (sec *Section) SubName() string {
	return sec.sub
}
func (sec *Section) String() string {
	var buf bytes.Buffer
	switch sec.mode {
	case lineModeSection:
		if len(sec.format) > 0 {
			_, _ = fmt.Fprintf(&buf, sec.format, sec.name)
		} else {
			_, _ = fmt.Fprintf(&buf, "[%s]\n", sec.name)
		}
	case lineModeSection | lineModeComment:
		if len(sec.format) > 0 {
			_, _ = fmt.Fprintf(&buf, sec.format, sec.name, sec.others)
		} else {
			_, _ = fmt.Fprintf(&buf, "[%s] %s\n", sec.name, sec.others)
		}
	case lineModeSection | lineModeSubsection:
		if len(sec.format) > 0 {
			_, _ = fmt.Fprintf(&buf, sec.format, sec.name, sec.sub)
		} else {
			_, _ = fmt.Fprintf(&buf, "[%s \"%s\"]\n", sec.name, sec.sub)
		}
	case lineModeSection | lineModeSubsection | lineModeComment:
		if len(sec.format) > 0 {
			_, _ = fmt.Fprintf(&buf, sec.format, sec.name, sec.sub, sec.others)
		} else {
			_, _ = fmt.Fprintf(&buf, "[%s \"%s\"] %s\n", sec.name, sec.sub, sec.others)
		}
	}
	return buf.String()
}
func (sec *Section) Val(key string) string {
	val, _ := sec.get(key, "")
	return val
}
func (sec *Section) Vals(key string) []string {
	vals, _ := sec.gets(key, nil)
	return vals
}
func (sec *Section) add(key, value string) bool {
	if len(key) == 0 {
		return false
	}
	keyLower := strings.ToLower(key)
	idx := -1
	for x := 0; x < len(sec.vars); x++ {
		if !isLineModeVar(sec.vars[x].mode) {
			continue
		}
		if sec.vars[x].keyLower != keyLower {
			continue
		}
		if sec.vars[x].value == value {
			return false
		}
		idx = x
	}
	v := &variable{
		mode:     lineModeValue,
		key:      key,
		keyLower: keyLower,
		value:    value,
	}
	sec.vars = append(sec.vars, v)
	if idx >= 0 {
		idx++
		copy(sec.vars[idx+1:], sec.vars[idx:])
		sec.vars[idx] = v
	}
	return true
}
func (sec *Section) addUniqValue(key, value string) {
	keyLower := strings.ToLower(key)
	for x := 0; x < len(sec.vars); x++ {
		if sec.vars[x].keyLower == keyLower {
			if sec.vars[x].value == value {
				tmp := sec.vars[x]
				sec.vars = append(sec.vars[:x], sec.vars[x+1:]...)
				sec.vars = append(sec.vars, tmp)
				return
			}
		}
	}
	v := &variable{
		mode:     lineModeValue,
		key:      key,
		keyLower: keyLower,
		value:    value,
	}
	sec.vars = append(sec.vars, v)
}
func (sec *Section) addVariable(v *variable) {
	if v == nil {
		return
	}
	if v.mode&lineModeValue == lineModeValue ||
		v.mode&lineModeMulti == lineModeMulti {
		v.keyLower = strings.ToLower(v.key)
	}
	sec.vars = append(sec.vars, v)
}