magiconair / properties

Java properties scanner for Go
BSD 2-Clause "Simplified" License
323 stars 77 forks source link

Bugs LoadFile will lose the first '\' when config file's value is '\1\n\t%p\t%r\t%u\t%d\t%t\t%e\t%T\t%S\t%U\t%E\t\t' #68

Open xlife8 opened 1 year ago

xlife8 commented 1 year ago

example.conf

log_line_prefix='\1\n\t%p\t%r\t%u\t%d\t%t\t%e\t%T\t%S\t%U\t%E\t\t'

After I run this golang code:

import (
    "fmt"
    "github.com/magiconair/properties"
        "os"
)

func main() {
        confName := "example.conf"
        filePros, _ := properties.LoadFile(confName, properties.UTF8)
        stat, _ := os.Stat(confName)
        writer, _ := os.OpenFile(confName, os.O_WRONLY|os.O_TRUNC, stat.Mode())
        defer writer.Close()
        filePros.WriteSeparator = "="
        filePros.Write(writer, properties.UTF8)
}

The example.conf content is change to this:

log_line_prefix='1\n\t%p\t%r\t%u\t%d\t%t\t%e\t%T\t%S\t%U\t%E\t\t'

The value's first '\' character lost, I think this is a bug.