import (
"fmt"
"bufio"
"io"
"os"
"regexp"
)
func main() {
configFile, configErr := os.Open(".\\config.ini")
properties := make(map[string]string)
reader := bufio.NewReader(configFile)
matcher, _ := regexp.Compile("(^\\w+)(\\s*=\\s*)(.*)")
var content string
var err error
for {
content, err = reader.ReadString('\n')
kv := matcher.FindAllStringSubmatch(content, 1)
if len(kv) > 0 {
properties[kv[0][1]] = kv[0][3]
}
if io.EOF == err {
break
}
}
if nil != configErr {
fmt.Println("Failed to configure program -> ", configErr)
fmt.Scanln()
return
}
localMp3Path := properties["saveLocation"]
fmt.Println(localMp3Path + "hello worlddddddddddddddddddddddddddd")
}
the content of config.ini
saveLocation=c:\golang\workspace\helloworld\test\src\
baseUrl=http://test.com/eng/ez/morning
the expected result:
c:\golang\workspace\helloworld\test\src\hello
worlddddddddddddddddddddddddddd
but the actual output result:
hello worlddddddddddhelloworld\test\src\
what's happened to the string from regexp function...
Thanks
--
You received this message because you are subscribed to the Google Groups "golang-nuts" group.
To unsubscribe from this group and stop receiving emails from it, send an email to golang-nuts+unsubscribe@googlegroups.com.
For more options, visit https://groups.google.com/groups/opt_out.