def (#12)
All checks were successful
Go Action / goaction (push) Successful in 29s

Reviewed-on: #12
This commit was merged in pull request #12.
This commit is contained in:
2025-12-26 14:55:42 +03:00
parent 22dacb741f
commit f9a0411192
129 changed files with 4660 additions and 1456 deletions

View File

@@ -1,6 +1,6 @@
module gitoa.ru/go-4devs/config/provider/yaml
go 1.21
go 1.22
require (
gitoa.ru/go-4devs/config v0.0.1

View File

@@ -36,9 +36,9 @@ func New(yml []byte, opts ...Option) (*Provider, error) {
}
func create(opts ...Option) *Provider {
prov := Provider{
name: Name,
}
var prov Provider
prov.name = Name
for _, opt := range opts {
opt(&prov)
@@ -65,6 +65,7 @@ func (p *Provider) Value(_ context.Context, path ...string) (config.Value, error
func (p *Provider) With(data *yaml.Node) *Provider {
return &Provider{
data: node{Node: data},
name: p.name,
}
}
@@ -85,7 +86,7 @@ func (n *node) read(name string, keys []string) (config.Value, error) {
return value.Decode(val), nil
}
func getData(node []*yaml.Node, keys []string) (func(interface{}) error, error) {
func getData(node []*yaml.Node, keys []string) (func(any) error, error) {
for idx := len(node) - 1; idx > 0; idx -= 2 {
if node[idx-1].Value == keys[0] {
if len(keys) > 1 {