fix lint
Some checks failed
continuous-integration/drone/push Build is failing

This commit is contained in:
2024-01-25 20:56:21 +03:00
parent 085589a938
commit 126ec4cb88
10 changed files with 18 additions and 11 deletions

View File

@@ -106,7 +106,7 @@ func (p *Provider) Name() string {
return p.name
}
func (p *Provider) Value(ctx context.Context, path ...string) (config.Value, error) {
func (p *Provider) Value(_ context.Context, path ...string) (config.Value, error) {
if err := p.parse(); err != nil {
return nil, err
}
@@ -123,7 +123,11 @@ func (p *Provider) Value(ctx context.Context, path ...string) (config.Value, err
}
return value.Decode(func(v interface{}) error {
return json.Unmarshal(data, v)
if err := json.Unmarshal(data, v); err != nil {
return fmt.Errorf("unmarshal:%w", err)
}
return nil
}), nil
}
}

View File

@@ -58,6 +58,7 @@ func (d *Duration) UnmarshalJSON(in []byte) error {
if err != nil {
return fmt.Errorf("parse:%w", err)
}
d.Duration = o
return nil

View File

@@ -45,7 +45,7 @@ func (p *Provider) Name() string {
return p.name
}
func (p *Provider) Value(ctx context.Context, path ...string) (config.Value, error) {
func (p *Provider) Value(_ context.Context, path ...string) (config.Value, error) {
name := p.prefix + p.key(path...)
if val, ok := os.LookupEnv(name); ok {
return value.JString(val), nil

View File

@@ -67,7 +67,6 @@ func (p *Provider) Watch(ctx context.Context, callback config.WatchCallback, key
return
}
p.logger(ctx, "callback %v:%v", key, err)
}
oldVar = newVar
}

View File

@@ -2,7 +2,7 @@ package watcher_test
import (
"context"
"fmt"
"strconv"
"sync"
"sync/atomic"
"testing"
@@ -14,6 +14,8 @@ import (
"gitoa.ru/go-4devs/config/value"
)
var _ config.Provider = (*provider)(nil)
type provider struct {
cnt int32
}
@@ -25,7 +27,7 @@ func (p *provider) Name() string {
func (p *provider) Value(context.Context, ...string) (config.Value, error) {
p.cnt++
return value.JString(fmt.Sprint(p.cnt)), nil
return value.JString(strconv.Itoa(int(p.cnt))), nil
}
func TestWatcher(t *testing.T) {
@@ -57,6 +59,7 @@ func TestWatcher(t *testing.T) {
},
"tmpname",
)
wg.Wait()
require.NoError(t, err)