Movatterモバイル変換


[0]ホーム

URL:


Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

Commit515f112

Browse files
committed
linting
1 parentb9fd441 commit515f112

File tree

3 files changed

+16
-2
lines changed

3 files changed

+16
-2
lines changed

‎cli/clibase/values.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -79,7 +79,7 @@ func (i *Validator[T]) UnmarshalJSON(b []byte) error {
7979
returnjson.Unmarshal(b,i.Value)
8080
}
8181

82-
func (*Validator[T])IsValidator(){}
82+
func (i*Validator[T])Underlying()pflag.Value {returni.Value}
8383

8484
// values.go contains a standard set of value types that can be used as
8585
// Option Values.

‎cli/clibase/yaml.go

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,7 @@ import (
66
"strings"
77

88
"github.com/mitchellh/go-wordwrap"
9+
"github.com/spf13/pflag"
910
"golang.org/x/xerrors"
1011
"gopkg.in/yaml.v3"
1112
)
@@ -75,7 +76,7 @@ func (optSet *OptionSet) MarshalYAML() (any, error) {
7576
HeadComment:comment,
7677
}
7778

78-
_,isValidator:=opt.Value.(interface{IsValidator() })
79+
_,isValidator:=opt.Value.(interface{Underlying() pflag.Value })
7980
varvalueNode yaml.Node
8081
ifopt.Value==nil {
8182
valueNode= yaml.Node{

‎cli/server_test.go

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -29,6 +29,7 @@ import (
2929
"time"
3030

3131
"github.com/go-chi/chi/v5"
32+
"github.com/spf13/pflag"
3233
"github.com/stretchr/testify/assert"
3334
"github.com/stretchr/testify/require"
3435
"go.uber.org/goleak"
@@ -1552,6 +1553,18 @@ func TestServer(t *testing.T) {
15521553
// ValueSource is not going to be correct on the `want`, so just
15531554
// match that field.
15541555
wantConfig.Options[i].ValueSource=gotConfig.Options[i].ValueSource
1556+
1557+
// If there is a wrapped value with a validator, unwrap it.
1558+
// The underlying doesn't compare well since it compares go pointers,
1559+
// and not the actual value.
1560+
ifvalidator,isValidator:=wantConfig.Options[i].Value.(interface{Underlying() pflag.Value });isValidator {
1561+
wantConfig.Options[i].Value=validator.Underlying()
1562+
}
1563+
1564+
ifvalidator,isValidator:=gotConfig.Options[i].Value.(interface{Underlying() pflag.Value });isValidator {
1565+
gotConfig.Options[i].Value=validator.Underlying()
1566+
}
1567+
15551568
assert.Equal(
15561569
t,wantConfig.Options[i],
15571570
gotConfig.Options[i],

0 commit comments

Comments
 (0)

[8]ページ先頭

©2009-2025 Movatter.jp