automatic parsing after loading

This commit is contained in:
xiaoqidun 2018-12-13 10:01:06 +08:00 committed by GitHub
parent 944b2650ed
commit 2658673b6f
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

@ -56,6 +56,7 @@ func (ini *GoINI) String() string {
} }
func (ini *GoINI) SetData(fileData []byte) { func (ini *GoINI) SetData(fileData []byte) {
ini.data = bytes.TrimSpace(fileData) ini.data = bytes.TrimSpace(fileData)
ini.ParseIni()
} }
func (ini *GoINI) LoadFile(fileName string) error { func (ini *GoINI) LoadFile(fileName string) error {
b, err := ioutil.ReadFile(fileName) b, err := ioutil.ReadFile(fileName)
@ -63,6 +64,7 @@ func (ini *GoINI) LoadFile(fileName string) error {
return err return err
} }
ini.data = bytes.TrimSpace(b) ini.data = bytes.TrimSpace(b)
ini.ParseIni()
return nil return nil
} }
func (ini *GoINI) ParseIni() { func (ini *GoINI) ParseIni() {