You cannot select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
39 lines
787 B
Go
39 lines
787 B
Go
5 years ago
|
package sysconf
|
||
|
|
||
|
import (
|
||
|
"fmt"
|
||
|
"testing"
|
||
|
)
|
||
|
|
||
|
func Test_SliceIn(t *testing.T) {
|
||
|
slice := []string{"ok", "11", "22"}
|
||
|
fmt.Println(SliceIn(slice, "ok"))
|
||
|
fmt.Println(SliceIn(slice, []rune("22")))
|
||
|
fmt.Println(SliceIn(slice, "342423r"))
|
||
|
fmt.Println(SliceIn(slice, 444))
|
||
|
}
|
||
|
|
||
|
func Test_Parse(t *testing.T) {
|
||
|
data := `
|
||
|
1.2.3.4 'ok.com'
|
||
|
#2.3.4.5 ppp.eor
|
||
|
2.3.4.5 'pp.com'
|
||
|
5.6.7.8 'ok.com'
|
||
|
`
|
||
|
cfg := new(SysConf)
|
||
|
cfg.SegStart = "["
|
||
|
cfg.SegEnd = "]"
|
||
|
cfg.ValueFlag = "'"
|
||
|
cfg.EqualFlag = " "
|
||
|
//cfg.CommentCR = true
|
||
|
cfg.CommentFlag = []string{"#"}
|
||
|
cfg.EscapeFlag = "\\"
|
||
|
cfg.HaveSegMent = false
|
||
|
cfg.segmap = make(map[string]int64)
|
||
|
fmt.Println(cfg.Parse([]byte(data)))
|
||
|
cfg.Reverse()
|
||
|
cfg.Data[0].Delete(`pp.com`)
|
||
|
//fmt.Println(cfg.Data[0].Comment)
|
||
|
fmt.Println(string(cfg.Build()))
|
||
|
}
|