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

Commit1ebc2df

Browse files
committed
fix: Allow setting STUN to an empty string (#1502)
This allows users to entirely disable STUN.
1 parenta1a3d24 commit1ebc2df

File tree

2 files changed

+15
-1
lines changed

2 files changed

+15
-1
lines changed

‎cli/cliflag/cliflag.go

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -40,7 +40,11 @@ func StringVarP(flagset *pflag.FlagSet, p *string, name string, shorthand string
4040
funcStringArrayVarP(flagset*pflag.FlagSet,ptr*[]string,namestring,shorthandstring,envstring,def []string,usagestring) {
4141
val,ok:=os.LookupEnv(env)
4242
ifok {
43-
def=strings.Split(val,",")
43+
ifval=="" {
44+
def= []string{}
45+
}else {
46+
def=strings.Split(val,",")
47+
}
4448
}
4549
flagset.StringArrayVarP(ptr,name,shorthand,def,usage)
4650
}

‎cli/cliflag/cliflag_test.go

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -96,6 +96,16 @@ func TestCliflag(t *testing.T) {
9696
require.Equal(t, []string{"wow","test"},got)
9797
})
9898

99+
t.Run("StringArrayEnvVarEmpty",func(t*testing.T) {
100+
varptr []string
101+
flagset,name,shorthand,env,usage:=randomFlag()
102+
t.Setenv(env,"")
103+
cliflag.StringArrayVarP(flagset,&ptr,name,shorthand,env,nil,usage)
104+
got,err:=flagset.GetStringArray(name)
105+
require.NoError(t,err)
106+
require.Equal(t, []string{},got)
107+
})
108+
99109
t.Run("IntDefault",func(t*testing.T) {
100110
varptruint8
101111
flagset,name,shorthand,env,usage:=randomFlag()

0 commit comments

Comments
 (0)

[8]ページ先頭

©2009-2025 Movatter.jp