-
Notifications
You must be signed in to change notification settings - Fork 16
/
options.go
84 lines (72 loc) · 1.73 KB
/
options.go
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
package ini
import "github.com/gookit/ini/v2/parser"
// Options for config
type Options struct {
// Readonly set to read-only mode. default False
Readonly bool
// TagName for binding struct
TagName string
// ParseEnv parse ENV var name. default True
ParseEnv bool
// ParseVar parse variable reference "%(varName)s". default False
ParseVar bool
// ReplaceNl replace the "\n" to newline
ReplaceNl bool
// VarOpen var left open char. default "%("
VarOpen string
// VarClose var right close char. default ")s"
VarClose string
// IgnoreCase ignore key name case. default False
IgnoreCase bool
// DefSection default section name. default "__default", it's allow empty string.
DefSection string
// SectionSep sep char for split key path. default ".", use like "section.subKey"
SectionSep string
}
// newDefaultOptions create a new default Options
//
// Notice:
//
// Cannot use package var instead it. That will allow multiple instances to use the same Options
func newDefaultOptions() *Options {
return &Options{
ParseEnv: true,
VarOpen: "%(",
VarClose: ")s",
TagName: DefTagName,
DefSection: parser.DefSection,
SectionSep: SepSection,
}
}
// Readonly setting
//
// Usage:
//
// ini.NewWithOptions(ini.Readonly)
func Readonly(opts *Options) {
opts.Readonly = true
}
// ParseVar on get value
//
// Usage:
//
// ini.NewWithOptions(ini.ParseVar)
func ParseVar(opts *Options) {
opts.ParseVar = true
}
// ParseEnv will parse ENV key on get value
//
// Usage:
//
// ini.NewWithOptions(ini.ParseEnv)
func ParseEnv(opts *Options) {
opts.ParseEnv = true
}
// IgnoreCase for get/set value by key
func IgnoreCase(opts *Options) {
opts.IgnoreCase = true
}
// ReplaceNl for parse
func ReplaceNl(opts *Options) {
opts.ReplaceNl = true
}