Skip to content

Commit c0c68d7

Browse files
Rename reader.NewReader() to reader.New()
1 parent 2d5089a commit c0c68d7

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

58 files changed

+105
-105
lines changed

packet/pubkey/parse_sig_test.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -31,7 +31,7 @@ var cxtSig = context.NewContext(options.NewOptions(
3131

3232
func TestPubkeySig19(t *testing.T) {
3333
parent := info.NewItem()
34-
if err := New(cxtSig, values.PubID(19), reader.NewReader(pubkeySig19)).ParseSig(parent); err != nil {
34+
if err := New(cxtSig, values.PubID(19), reader.New(pubkeySig19)).ParseSig(parent); err != nil {
3535
t.Errorf("ParseSig() = %v, want nil error.", err)
3636
}
3737
if len(parent.Items) != 2 {

packet/pubkey/pubkey_ses_test.go

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -39,7 +39,7 @@ var cxtPub = context.NewContext(options.NewOptions(
3939

4040
func TestPubkeySes17(t *testing.T) {
4141
parent := info.NewItem()
42-
New(cxtPub, values.PubID(pubkeySes17[0]), reader.NewReader(pubkeySes17[1:])).ParseSes(parent)
42+
New(cxtPub, values.PubID(pubkeySes17[0]), reader.New(pubkeySes17[1:])).ParseSes(parent)
4343
if len(parent.Items) != 1 {
4444
t.Errorf("Count of Items = %v, want 1.", len(parent.Items))
4545
} else if parent.Items[0].Name != pubkeySesName17 {
@@ -49,7 +49,7 @@ func TestPubkeySes17(t *testing.T) {
4949

5050
func TestPubkeySes18(t *testing.T) {
5151
parent := info.NewItem()
52-
New(cxtPub, values.PubID(pubkeySes18a[0]), reader.NewReader(pubkeySes18a[1:])).ParseSes(parent)
52+
New(cxtPub, values.PubID(pubkeySes18a[0]), reader.New(pubkeySes18a[1:])).ParseSes(parent)
5353
if len(parent.Items) != 2 {
5454
t.Errorf("Count of Items = %v, want 2.", len(parent.Items))
5555
} else if parent.Items[0].Name != pubkeySesName18a {
@@ -61,15 +61,15 @@ func TestPubkeySes18(t *testing.T) {
6161

6262
func TestPubkeySes18Err1(t *testing.T) {
6363
parent := info.NewItem()
64-
New(cxtPub, values.PubID(pubkeySes18b[0]), reader.NewReader(pubkeySes18b[1:])).ParseSes(parent)
64+
New(cxtPub, values.PubID(pubkeySes18b[0]), reader.New(pubkeySes18b[1:])).ParseSes(parent)
6565
if len(parent.Items) != 0 {
6666
t.Errorf("Count of Items = %v, want 0.", len(parent.Items))
6767
}
6868
}
6969

7070
func TestPubkeySes18Err2(t *testing.T) {
7171
parent := info.NewItem()
72-
New(cxtPub, values.PubID(pubkeySes18c[0]), reader.NewReader(pubkeySes18c[1:])).ParseSes(parent)
72+
New(cxtPub, values.PubID(pubkeySes18c[0]), reader.New(pubkeySes18c[1:])).ParseSes(parent)
7373
if len(parent.Items) != 1 {
7474
t.Errorf("Count of Items = %v, want 1.", len(parent.Items))
7575
} else if parent.Items[0].Name != pubkeySesName18a {
@@ -79,7 +79,7 @@ func TestPubkeySes18Err2(t *testing.T) {
7979

8080
func TestPubkeySes19(t *testing.T) {
8181
parent := info.NewItem()
82-
New(cxtPub, values.PubID(pubkeySes19[0]), reader.NewReader(pubkeySes19[1:])).ParseSes(parent)
82+
New(cxtPub, values.PubID(pubkeySes19[0]), reader.New(pubkeySes19[1:])).ParseSes(parent)
8383
if len(parent.Items) != 1 {
8484
t.Errorf("Count of Items = %v, want 1.", len(parent.Items))
8585
} else if parent.Items[0].Name != pubkeySesName19 {
@@ -89,7 +89,7 @@ func TestPubkeySes19(t *testing.T) {
8989

9090
func TestPubkeySesUnknown(t *testing.T) {
9191
parent := info.NewItem()
92-
New(cxtPub, values.PubID(pubkeySesUn[0]), reader.NewReader(pubkeySesUn[1:])).ParseSes(parent)
92+
New(cxtPub, values.PubID(pubkeySesUn[0]), reader.New(pubkeySesUn[1:])).ParseSes(parent)
9393
if len(parent.Items) != 1 {
9494
t.Errorf("Count of Items = %v, want 1.", len(parent.Items))
9595
} else if parent.Items[0].Name != pubkeySesNameUn {

packet/reader/reader.go

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -13,8 +13,8 @@ type Reader struct {
1313
offset int64
1414
}
1515

16-
//NewReader returns Reader instance
17-
func NewReader(data []byte) *Reader {
16+
//New returns Reader instance
17+
func New(data []byte) *Reader {
1818
return &Reader{buffer: data, offset: 0}
1919
}
2020

packet/reader/reader_test.go

Lines changed: 12 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@ var buffer = []byte{0x01, 0x02, 0x03, 0x04}
1111

1212
func TestReadBytes(t *testing.T) {
1313
var res = []byte{0x01, 0x02}
14-
v, err := NewReader(buffer).ReadBytes(2)
14+
v, err := New(buffer).ReadBytes(2)
1515
if err != nil {
1616
t.Errorf("ReadBytes() = \"%v\", want nil.", err)
1717
}
@@ -21,7 +21,7 @@ func TestReadBytes(t *testing.T) {
2121
}
2222

2323
func TestReadBytes0(t *testing.T) {
24-
v, err := NewReader(buffer).ReadBytes(0)
24+
v, err := New(buffer).ReadBytes(0)
2525
if err != nil {
2626
t.Errorf("ReadBytes() = \"%v\", want nil.", err)
2727
}
@@ -31,7 +31,7 @@ func TestReadBytes0(t *testing.T) {
3131
}
3232

3333
func TestReadBytesErr(t *testing.T) {
34-
_, err := NewReader(buffer).ReadBytes(5)
34+
_, err := New(buffer).ReadBytes(5)
3535
if err != io.ErrUnexpectedEOF {
3636
t.Errorf("ReadBytes() = \"%v\", want \"%v\".", err, io.ErrUnexpectedEOF)
3737
}
@@ -40,7 +40,7 @@ func TestReadBytesErr(t *testing.T) {
4040
func TestRead(t *testing.T) {
4141
var res = []byte{0x01, 0x02}
4242
buf := make([]byte, 2)
43-
s, err := NewReader(buffer).Read(buf)
43+
s, err := New(buffer).Read(buf)
4444
if err != nil {
4545
t.Errorf("Read() = \"%v\", want nil.", err)
4646
}
@@ -54,14 +54,14 @@ func TestRead(t *testing.T) {
5454

5555
func TestReadErr(t *testing.T) {
5656
buf := make([]byte, 5)
57-
if _, err := NewReader(buffer).Read(buf); err != io.ErrUnexpectedEOF {
57+
if _, err := New(buffer).Read(buf); err != io.ErrUnexpectedEOF {
5858
t.Errorf("Read() = \"%v\", want \"%v\".", err, io.ErrUnexpectedEOF)
5959
}
6060
}
6161

6262
func TestReadAt(t *testing.T) {
6363
var res = []byte{0x03, 0x04}
64-
reader := NewReader(buffer)
64+
reader := New(buffer)
6565
buf := make([]byte, 2)
6666
s, err := reader.ReadAt(buf, 2)
6767
if err != nil {
@@ -100,7 +100,7 @@ func TestReadAt(t *testing.T) {
100100

101101
func TestWriteTo(t *testing.T) {
102102
var res = []byte{0x01, 0x02, 0x03, 0x04}
103-
reader := NewReader(buffer)
103+
reader := New(buffer)
104104
buf := new(bytes.Buffer)
105105
s, err := reader.WriteTo(buf)
106106
if err != nil {
@@ -116,7 +116,7 @@ func TestWriteTo(t *testing.T) {
116116
}
117117

118118
func TestSeekFromEnd(t *testing.T) {
119-
reader := NewReader(buffer)
119+
reader := New(buffer)
120120
off, err := reader.Seek(0, io.SeekEnd)
121121
if err != nil {
122122
t.Errorf("Seek() = \"%v\", want nil.", err)
@@ -131,7 +131,7 @@ func TestSeekFromEnd(t *testing.T) {
131131
}
132132

133133
func TestSeekErr(t *testing.T) {
134-
reader := NewReader(buffer)
134+
reader := New(buffer)
135135
_, err := reader.Seek(0, 3)
136136
if err != ErrWhence {
137137
t.Errorf("ReadByte() = \"%v\", want \"%v\".", err, ErrWhence)
@@ -140,7 +140,7 @@ func TestSeekErr(t *testing.T) {
140140

141141
func TestRead2EOF(t *testing.T) {
142142
var res = []byte{0x01, 0x02, 0x03, 0x04}
143-
reader := NewReader(buffer)
143+
reader := New(buffer)
144144
v, err := reader.Read2EOF()
145145
if err != nil {
146146
t.Errorf("Read2EOF() = \"%v\", want nil.", err)
@@ -155,7 +155,7 @@ func TestRead2EOF(t *testing.T) {
155155

156156
func TestReadByte(t *testing.T) {
157157
var res = []byte{0x01, 0x02, 0x03, 0x04}
158-
reader := NewReader(buffer)
158+
reader := New(buffer)
159159
for i := 0; i < 4; i++ {
160160
b, err := reader.ReadByte()
161161
if err != nil {
@@ -171,7 +171,7 @@ func TestReadByte(t *testing.T) {
171171
}
172172

173173
func TestDump(t *testing.T) {
174-
reader := NewReader(buffer)
174+
reader := New(buffer)
175175
d := reader.DumpString(2)
176176
if d != "03 04" {
177177
t.Errorf("DumpString() = \"%v\", want \"03 04\".", d)

packet/s2k/s2k_test.go

Lines changed: 12 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,7 @@ func TestS2KNil(t *testing.T) {
2222
func TestS2KEmpty(t *testing.T) {
2323
parent := info.NewItem()
2424
var data = []byte{}
25-
s2k := New(reader.NewReader(data))
25+
s2k := New(reader.New(data))
2626
if err := s2k.Parse(parent, true); err == nil {
2727
t.Error("S2K err = nil, not want nil.")
2828
} else {
@@ -36,7 +36,7 @@ func TestS2KEmpty(t *testing.T) {
3636
func TestSimpleS2K(t *testing.T) {
3737
parent := info.NewItem()
3838
var data = []byte{0x00, 0x08, 0xff, 0xff}
39-
reader := reader.NewReader(data)
39+
reader := reader.New(data)
4040
s2k := New(reader)
4141
if err := s2k.Parse(parent, true); err != nil {
4242
t.Errorf("S2K err = \"%v\", want nil.", err)
@@ -85,7 +85,7 @@ func TestSimpleS2K(t *testing.T) {
8585
func TestSimpleS2Kerr(t *testing.T) {
8686
parent := info.NewItem()
8787
var data = []byte{0x00}
88-
s2k := New(reader.NewReader(data))
88+
s2k := New(reader.New(data))
8989
if err := s2k.Parse(parent, true); err == nil {
9090
t.Error("S2K err = nil, not want nil.")
9191
} else {
@@ -117,7 +117,7 @@ func TestSaltedS2K(t *testing.T) {
117117
parent := info.NewItem()
118118
var data = []byte{0x01, 0x08, 0x01, 0x02, 0x03, 0x04, 0x05, 0x06, 0x07, 0x08, 0xff, 0xff}
119119
saltDump := "01 02 03 04 05 06 07 08"
120-
reader := reader.NewReader(data)
120+
reader := reader.New(data)
121121
s2k := New(reader)
122122
if err := s2k.Parse(parent, true); err != nil {
123123
t.Errorf("S2K err = \"%v\", want nil.", err)
@@ -179,7 +179,7 @@ func TestSaltedS2K(t *testing.T) {
179179
func TestSaltedS2Kerr(t *testing.T) {
180180
parent := info.NewItem()
181181
var data = []byte{0x01, 0x08, 0x01, 0x02, 0x03, 0x04, 0x05, 0x06, 0x07}
182-
reader := reader.NewReader(data)
182+
reader := reader.New(data)
183183
s2k := New(reader)
184184
if err := s2k.Parse(parent, true); err == nil {
185185
t.Error("S2K err = nil, not want nil.")
@@ -223,7 +223,7 @@ func TestIteratedSaltedS2K(t *testing.T) {
223223
parent := info.NewItem()
224224
var data = []byte{0x03, 0x08, 0x01, 0x02, 0x03, 0x04, 0x05, 0x06, 0x07, 0x08, 0xc3, 0xff, 0xff}
225225
saltDump := "01 02 03 04 05 06 07 08"
226-
reader := reader.NewReader(data)
226+
reader := reader.New(data)
227227
s2k := New(reader)
228228
if err := s2k.Parse(parent, true); err != nil {
229229
t.Errorf("S2K err = \"%v\", want nil.", err)
@@ -299,7 +299,7 @@ func TestIteratedSaltedS2Kerr(t *testing.T) {
299299
parent := info.NewItem()
300300
var data = []byte{0x03, 0x08, 0x01, 0x02, 0x03, 0x04, 0x05, 0x06, 0x07, 0x08}
301301
saltDump := "01 02 03 04 05 06 07 08"
302-
reader := reader.NewReader(data)
302+
reader := reader.New(data)
303303
s2k := New(reader)
304304
if err := s2k.Parse(parent, true); err == nil {
305305
t.Error("S2K err = nil, not want nil.")
@@ -358,7 +358,7 @@ func TestIteratedSaltedS2Kerr(t *testing.T) {
358358
func TestUnknownS2K(t *testing.T) {
359359
parent := info.NewItem()
360360
var data = []byte{0x02, 0xff, 0xff}
361-
reader := reader.NewReader(data)
361+
reader := reader.New(data)
362362
s2k := New(reader)
363363
if err := s2k.Parse(parent, true); err != nil {
364364
t.Errorf("S2K err = \"%v\", want nil.", err)
@@ -393,7 +393,7 @@ func TestUnknownS2K(t *testing.T) {
393393
func TestExpS2K(t *testing.T) {
394394
parent := info.NewItem()
395395
var data = []byte{101, 0xff, 0xff, 0xff, 0xff}
396-
reader := reader.NewReader(data)
396+
reader := reader.New(data)
397397
s2k := New(reader)
398398
if err := s2k.Parse(parent, true); err != nil {
399399
t.Errorf("S2K err = \"%v\", want nil.", err)
@@ -428,7 +428,7 @@ func TestExpS2K(t *testing.T) {
428428
func TestExpS2Kb(t *testing.T) {
429429
parent := info.NewItem()
430430
var data = []byte{101, 0xff, 0xff, 0xff}
431-
reader := reader.NewReader(data)
431+
reader := reader.New(data)
432432
s2k := New(reader)
433433
if err := s2k.Parse(parent, true); err != nil {
434434
t.Errorf("S2K err = \"%v\", want nil.", err)
@@ -463,7 +463,7 @@ func TestExpS2Kb(t *testing.T) {
463463
func TestExpS2Kgnu1(t *testing.T) {
464464
parent := info.NewItem()
465465
var data = []byte{101, 'G', 'N', 'U', 0x01, 0xff, 0xff}
466-
reader := reader.NewReader(data)
466+
reader := reader.New(data)
467467
s2k := New(reader)
468468
if err := s2k.Parse(parent, true); err != nil {
469469
t.Errorf("S2K err = \"%v\", want nil.", err)
@@ -516,7 +516,7 @@ func TestExpS2Kgnu2(t *testing.T) {
516516
parent := info.NewItem()
517517
var data = []byte{101, 'G', 'N', 'U', 0x02, 0x04, 0x01, 0x02, 0x03, 0x04, 0xff, 0xff}
518518
snDumo := "01 02 03 04"
519-
reader := reader.NewReader(data)
519+
reader := reader.New(data)
520520
s2k := New(reader)
521521
if err := s2k.Parse(parent, true); err != nil {
522522
t.Errorf("S2K err = \"%v\", want nil.", err)

packet/tags/Tag08.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@ type tag08 tagInfo
1212

1313
//newTag08 return tag08 instance
1414
func newTag08(cxt *context.Context, tag values.TagID, body []byte) Tags {
15-
return &tag08{cxt: cxt, tag: tag, reader: reader.NewReader(body)}
15+
return &tag08{cxt: cxt, tag: tag, reader: reader.New(body)}
1616
}
1717

1818
// Parse parsing Compressed Data Packet

packet/tags/sub01.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,7 @@ type sub01 subInfo
1616

1717
//newSubReserved return subInfo instance
1818
func newSub01(cxt *context.Context, subID values.SuboacketID, body []byte) Subs {
19-
return &subInfo{cxt: cxt, subID: subID, reader: reader.NewReader(body)}
19+
return &subInfo{cxt: cxt, subID: subID, reader: reader.New(body)}
2020
}
2121

2222
// Parse parsing Image Attribute Sub-packet

packet/tags/sub02.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@ type sub02 subInfo
1212

1313
//newSub02 return sub02 instance
1414
func newSub02(cxt *context.Context, subID values.SuboacketID, body []byte) Subs {
15-
return &sub02{cxt: cxt, subID: subID, reader: reader.NewReader(body)}
15+
return &sub02{cxt: cxt, subID: subID, reader: reader.New(body)}
1616
}
1717

1818
// Parse parsing Signature Creation Time Sub-packet

packet/tags/sub03.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@ type sub03 subInfo
1212

1313
//newSub03 return sub03 instance
1414
func newSub03(cxt *context.Context, subID values.SuboacketID, body []byte) Subs {
15-
return &sub03{cxt: cxt, subID: subID, reader: reader.NewReader(body)}
15+
return &sub03{cxt: cxt, subID: subID, reader: reader.New(body)}
1616
}
1717

1818
// Parse parsing Signature Expiration Timee Sub-packet

packet/tags/sub04.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@ type sub04 subInfo
1212

1313
//newSub04 return sub04 instance
1414
func newSub04(cxt *context.Context, subID values.SuboacketID, body []byte) Subs {
15-
return &sub04{cxt: cxt, subID: subID, reader: reader.NewReader(body)}
15+
return &sub04{cxt: cxt, subID: subID, reader: reader.New(body)}
1616
}
1717

1818
// Parse parsing Exportable Certification Sub-packet

0 commit comments

Comments
 (0)