Skip to content

Commit 0976a01

Browse files
Rename options.NewOptions() to options.New()
1 parent c0c68d7 commit 0976a01

File tree

10 files changed

+24
-24
lines changed

10 files changed

+24
-24
lines changed

README.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -36,7 +36,7 @@ T1ZprZqwRPOjiLJg9AwA/ArTwCPz7c2vmxlv7sRlRLUI6CdsOqhuO1KfYXrq7idI
3636
-----END PGP SIGNATURE-----
3737
`
3838

39-
info, err := gpgpdump.Parse(strings.NewReader(openpgpStr), options.NewOptions())
39+
info, err := gpgpdump.Parse(strings.NewReader(openpgpStr), options.New())
4040
if err != nil {
4141
return
4242
}

cli/gpgpdump/facade/facade.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -83,7 +83,7 @@ func getBool(cmd *cobra.Command, name string) bool {
8383
}
8484

8585
func parseOpt(cmd *cobra.Command) *options.Options {
86-
return options.NewOptions(
86+
return options.New(
8787
options.Set(options.ArmorOpt, getBool(cmd, options.ArmorOpt)),
8888
//options.Set(options.DebugOpt, getBool(cmd, options.DebugOpt)), //not use
8989
//options.Set(options.GDumpOpt, getBool(cmd, options.GDumpOpt)), //not use

options/options.go

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -38,8 +38,8 @@ type Options struct {
3838
//OptFunc is self-referential function for functional options pattern
3939
type OptFunc func(*Options)
4040

41-
// NewOptions returns a new UI instance
42-
func NewOptions(opts ...OptFunc) *Options {
41+
// New returns a new Options instance
42+
func New(opts ...OptFunc) *Options {
4343
o := &Options{}
4444
o.options(opts...)
4545
return o

options/options_test.go

Lines changed: 11 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,7 @@ func TestMain(m *testing.M) {
1414
}
1515

1616
func TestNewOptions(t *testing.T) {
17-
o := NewOptions()
17+
o := New()
1818
res := "armor:false,debug:false,gdump:false,int:false,literal:false,marker:false,private:false,utc:false"
1919
if o.String() != res {
2020
t.Errorf("Options() = %v, want %v.", o.String(), res)
@@ -23,7 +23,7 @@ func TestNewOptions(t *testing.T) {
2323
}
2424

2525
func TestSetAllOpt(t *testing.T) {
26-
o := NewOptions(
26+
o := New(
2727
Set(ArmorOpt, true),
2828
Set(DebugOpt, true), //not use
2929
Set(GDumpOpt, true), //not use
@@ -40,71 +40,71 @@ func TestSetAllOpt(t *testing.T) {
4040
}
4141

4242
func TestArmorOpt(t *testing.T) {
43-
o := NewOptions(Set(ArmorOpt, true))
43+
o := New(Set(ArmorOpt, true))
4444
res := "armor:true,debug:false,gdump:false,int:false,literal:false,marker:false,private:false,utc:false"
4545
if o.String() != res {
4646
t.Errorf("Options() = %v, want %v.", o.String(), res)
4747
}
4848
}
4949

5050
func TestDebugOpt(t *testing.T) {
51-
o := NewOptions(Set(DebugOpt, true))
51+
o := New(Set(DebugOpt, true))
5252
res := "armor:false,debug:true,gdump:false,int:false,literal:false,marker:false,private:false,utc:false"
5353
if o.String() != res {
5454
t.Errorf("Options() = %v, want %v.", o.String(), res)
5555
}
5656
}
5757

5858
func TestGDumpOpt(t *testing.T) {
59-
o := NewOptions(Set(GDumpOpt, true))
59+
o := New(Set(GDumpOpt, true))
6060
res := "armor:false,debug:false,gdump:true,int:false,literal:false,marker:false,private:false,utc:false"
6161
if o.String() != res {
6262
t.Errorf("Options() = %v, want %v.", o.String(), res)
6363
}
6464
}
6565

6666
func TestIntegerOpt(t *testing.T) {
67-
o := NewOptions(Set(IntegerOpt, true))
67+
o := New(Set(IntegerOpt, true))
6868
res := "armor:false,debug:false,gdump:false,int:true,literal:false,marker:false,private:false,utc:false"
6969
if o.String() != res {
7070
t.Errorf("Options() = %v, want %v.", o.String(), res)
7171
}
7272
}
7373

7474
func TestLiteralOpt(t *testing.T) {
75-
o := NewOptions(Set(LiteralOpt, true))
75+
o := New(Set(LiteralOpt, true))
7676
res := "armor:false,debug:false,gdump:false,int:false,literal:true,marker:false,private:false,utc:false"
7777
if o.String() != res {
7878
t.Errorf("Options() = %v, want %v.", o.String(), res)
7979
}
8080
}
8181

8282
func TestMarkerOpt(t *testing.T) {
83-
o := NewOptions(Set(MarkerOpt, true))
83+
o := New(Set(MarkerOpt, true))
8484
res := "armor:false,debug:false,gdump:false,int:false,literal:false,marker:true,private:false,utc:false"
8585
if o.String() != res {
8686
t.Errorf("Options() = %v, want %v.", o.String(), res)
8787
}
8888
}
8989

9090
func TestPrivateOpt(t *testing.T) {
91-
o := NewOptions(Set(PrivateOpt, true))
91+
o := New(Set(PrivateOpt, true))
9292
res := "armor:false,debug:false,gdump:false,int:false,literal:false,marker:false,private:true,utc:false"
9393
if o.String() != res {
9494
t.Errorf("Options() = %v, want %v.", o.String(), res)
9595
}
9696
}
9797

9898
func TestUTCOpt(t *testing.T) {
99-
o := NewOptions(Set(UTCOpt, true))
99+
o := New(Set(UTCOpt, true))
100100
res := "armor:false,debug:false,gdump:false,int:false,literal:false,marker:false,private:false,utc:true"
101101
if o.String() != res {
102102
t.Errorf("Options() = %v, want %v.", o.String(), res)
103103
}
104104
}
105105

106106
func TestFakeOpt(t *testing.T) {
107-
o := NewOptions(Set("json", true))
107+
o := New(Set("json", true))
108108
res := "armor:false,debug:false,gdump:false,int:false,literal:false,marker:false,private:false,utc:false"
109109
if o.String() != res {
110110
t.Errorf("Options() = %v, want %v.", o.String(), res)

packet/parser.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -28,7 +28,7 @@ func NewParser(reader io.Reader, o *options.Options) (*Parser, error) {
2828
return nil, errors.Wrap(os.ErrInvalid, "error in packet.NewParser() function (null data)")
2929
}
3030
if o == nil {
31-
o = options.NewOptions()
31+
o = options.New()
3232
}
3333
var r io.Reader
3434
var err error

packet/parser_test.go

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -101,7 +101,7 @@ func TestParseNilOption(t *testing.T) {
101101
}
102102

103103
func TestParseNilData(t *testing.T) {
104-
opts := options.NewOptions(
104+
opts := options.New(
105105
options.Set(options.ArmorOpt, true),
106106
options.Set(options.DebugOpt, true),
107107
)
@@ -112,7 +112,7 @@ func TestParseNilData(t *testing.T) {
112112
}
113113

114114
func TestParse(t *testing.T) {
115-
opts := options.NewOptions(
115+
opts := options.New(
116116
options.Set(options.ArmorOpt, true),
117117
options.Set(options.DebugOpt, true),
118118
options.Set(options.UTCOpt, true),

packet/pubkey/parse_sig_test.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,7 @@ var (
1919
pubkeySigName19b = "Multi-precision integer"
2020
)
2121

22-
var cxtSig = context.NewContext(options.NewOptions(
22+
var cxtSig = context.NewContext(options.New(
2323
options.Set(options.DebugOpt, true), //not use
2424
options.Set(options.GDumpOpt, true), //not use
2525
options.Set(options.IntegerOpt, true),

packet/pubkey/pubkey_ses_test.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -27,7 +27,7 @@ var (
2727
pubkeySesNameUn = "Multi-precision integers of Unknown (pub 100)"
2828
)
2929

30-
var cxtPub = context.NewContext(options.NewOptions(
30+
var cxtPub = context.NewContext(options.New(
3131
options.Set(options.DebugOpt, true), //not use
3232
options.Set(options.GDumpOpt, true), //not use
3333
options.Set(options.IntegerOpt, true),

packet/tags/tags_test.go

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,7 @@ var (
2121

2222
func TestTag01(t *testing.T) {
2323
op := &openpgp.OpaquePacket{Tag: 1, Contents: tag01Body}
24-
cxt := context.NewContext(options.NewOptions())
24+
cxt := context.NewContext(options.New())
2525
i, err := NewTag(op, cxt).Parse()
2626
if err != nil {
2727
t.Errorf("NewTag() = %v, want nil error.", err)
@@ -43,7 +43,7 @@ func TestTag01(t *testing.T) {
4343

4444
func TestTag02(t *testing.T) {
4545
op := &openpgp.OpaquePacket{Tag: 2, Contents: tag02Body}
46-
cxt := context.NewContext(options.NewOptions())
46+
cxt := context.NewContext(options.New())
4747
i, err := NewTag(op, cxt).Parse()
4848
if err != nil {
4949
t.Errorf("NewTag() = %v, want nil error.", err)
@@ -65,7 +65,7 @@ func TestTag02(t *testing.T) {
6565

6666
func TestTagUnknown(t *testing.T) {
6767
op := &openpgp.OpaquePacket{Tag: 99, Contents: []byte{0x01, 0x02, 0x03, 0x04}}
68-
cxt := context.NewContext(options.NewOptions(
68+
cxt := context.NewContext(options.New(
6969
options.Set(options.DebugOpt, true),
7070
))
7171
name := "Unknown (tag 99)"

parse_test.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,7 @@ T1ZprZqwRPOjiLJg9AwA/ArTwCPz7c2vmxlv7sRlRLUI6CdsOqhuO1KfYXrq7idI
2222
var (
2323
openpgpData = []byte(openpgpStr)
2424
reader = strings.NewReader(openpgpStr)
25-
optionss = options.NewOptions()
25+
optionss = options.New()
2626
)
2727

2828
func ExampleParse() {

0 commit comments

Comments
 (0)