diff options
| author | Shulhan <ms@kilabit.info> | 2022-07-25 21:47:18 +0700 |
|---|---|---|
| committer | Shulhan <ms@kilabit.info> | 2022-07-25 21:47:18 +0700 |
| commit | b2230a98735fd6c9d608981bdb22711aa98f8fb2 (patch) | |
| tree | 3663c8c093a9a242f5c80c27487971ac1ea65619 | |
| parent | e5171b60a91e5d212ef93725d46f977d24be007f (diff) | |
| download | pakakeh.go-b2230a98735fd6c9d608981bdb22711aa98f8fb2.tar.xz | |
lib/ini: export the function to parse tag
| -rw-r--r-- | lib/ini/common.go | 4 | ||||
| -rw-r--r-- | lib/ini/common_test.go | 4 | ||||
| -rw-r--r-- | lib/ini/ini.go | 2 | ||||
| -rw-r--r-- | lib/ini/ini_test.go | 2 | ||||
| -rw-r--r-- | lib/ini/tag_struct_field.go | 2 |
5 files changed, 7 insertions, 7 deletions
diff --git a/lib/ini/common.go b/lib/ini/common.go index 5a9d4813..0feab91b 100644 --- a/lib/ini/common.go +++ b/lib/ini/common.go @@ -44,10 +44,10 @@ func IsValueBoolTrue(v string) bool { return false } -// parseTag parse the ini field tag as used in the struct's field. +// ParseTag parse the ini field tag as used in the struct's field. // This returned slice always have 4 string element: section, subsection, key, // and default value. -func parseTag(in string) (tags []string) { +func ParseTag(in string) (tags []string) { var ( sb strings.Builder r rune diff --git a/lib/ini/common_test.go b/lib/ini/common_test.go index 470b02b1..a8fd4518 100644 --- a/lib/ini/common_test.go +++ b/lib/ini/common_test.go @@ -82,7 +82,7 @@ func TestParseTag(t *testing.T) { got []string ) for _, c = range cases { - got = parseTag(c.in) + got = ParseTag(c.in) test.Assert(t, c.in, c.exp, got) } } @@ -120,7 +120,7 @@ func TestParseTag_fromStruct(t *testing.T) { tag, _, _ = libreflect.Tag(field, "ini") - got = parseTag(tag) + got = ParseTag(tag) test.Assert(t, tag, exp[x], got) } } diff --git a/lib/ini/ini.go b/lib/ini/ini.go index c32a59f4..c6262cb8 100644 --- a/lib/ini/ini.go +++ b/lib/ini/ini.go @@ -140,7 +140,7 @@ func (in *Ini) marshalStruct( var sec, sub, key, value string - tags = parseTag(tag) + tags = ParseTag(tag) sec = tags[0] sub = tags[1] if len(tags[2]) == 0 { diff --git a/lib/ini/ini_test.go b/lib/ini/ini_test.go index 639b97be..114fe353 100644 --- a/lib/ini/ini_test.go +++ b/lib/ini/ini_test.go @@ -272,7 +272,7 @@ func TestIni_Get(t *testing.T) { continue } - tags = parseTag(string(key)) + tags = ParseTag(string(key)) def = tags[3] got, _ = cfg.Get(tags[0], tags[1], tags[2], def) diff --git a/lib/ini/tag_struct_field.go b/lib/ini/tag_struct_field.go index 7d99c9e4..0bad87a3 100644 --- a/lib/ini/tag_struct_field.go +++ b/lib/ini/tag_struct_field.go @@ -74,7 +74,7 @@ func unpackTagStructField(rtype reflect.Type, rval reflect.Value) (out tagStruct sfield.layout = time.RFC3339 } - tags = parseTag(tag) + tags = ParseTag(tag) sfield.sec = tags[0] sfield.sub = tags[1] sfield.key = strings.ToLower(tags[2]) |
