Skip to content

Commit 6b734db

Browse files
authored
refactor(tag): modify the tag declaration of a structure (#67)
`yomo:"0x10"` to `y3:"0x10"`
1 parent 4318488 commit 6b734db

File tree

10 files changed

+75
-75
lines changed

10 files changed

+75
-75
lines changed

README_CN.md

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -78,8 +78,8 @@ Golang implementation of [YoMo Codec](https://github.com/yomorun/yomo-codec)
7878

7979
```go
8080
type Example struct {
81-
Id int32 `yomo:"0x22"`
82-
Name string `yomo:"0x23"`
81+
Id int32 `y3:"0x22"`
82+
Name string `y3:"0x23"`
8383
}
8484
```
8585

@@ -167,8 +167,8 @@ func main() {
167167
}
168168
169169
type Example struct {
170-
Id int32 `yomo:"0x22"`
171-
Name string `yomo:"0x23"`
170+
Id int32 `y3:"0x22"`
171+
Name string `y3:"0x23"`
172172
}
173173
```
174174

@@ -218,8 +218,8 @@ func main() {
218218
}
219219
220220
type Example struct {
221-
Id int32 `yomo:"0x22"`
222-
Name string `yomo:"0x23"`
221+
Id int32 `y3:"0x22"`
222+
Name string `y3:"0x23"`
223223
}
224224
```
225225

codec_test.go

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -223,16 +223,16 @@ func TestMarshalObjectSlice(t *testing.T) {
223223
}
224224

225225
type exampleData struct {
226-
Name string `yomo:"0x10"`
227-
Noise float32 `yomo:"0x11"`
228-
Therm thermometer `yomo:"0x12"`
226+
Name string `y3:"0x10"`
227+
Noise float32 `y3:"0x11"`
228+
Therm thermometer `y3:"0x12"`
229229
}
230230

231231
type thermometer struct {
232-
Temperature float32 `yomo:"0x13"`
233-
Humidity float32 `yomo:"0x14"`
232+
Temperature float32 `y3:"0x13"`
233+
Humidity float32 `y3:"0x14"`
234234
}
235235

236236
type exampleSlice struct {
237-
Therms []thermometer `yomo:"0x12"`
237+
Therms []thermometer `y3:"0x12"`
238238
}

examples/example1/main.go

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -9,14 +9,14 @@ import (
99
)
1010

1111
type SourceData struct {
12-
Name string `yomo:"0x10"`
13-
Noise float32 `yomo:"0x11"`
14-
Therm Thermometer `yomo:"0x12"`
12+
Name string `y3:"0x10"`
13+
Noise float32 `y3:"0x11"`
14+
Therm Thermometer `y3:"0x12"`
1515
}
1616

1717
type Thermometer struct {
18-
Temperature float32 `yomo:"0x13"`
19-
Humidity float32 `yomo:"0x14"`
18+
Temperature float32 `y3:"0x13"`
19+
Humidity float32 `y3:"0x14"`
2020
}
2121

2222
func main() {

explainer.md

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -36,14 +36,14 @@ Core interfaces include:
3636

3737
```go
3838
type SourceData struct {
39-
Name string `yomo:"0x10"`
40-
Noise float32 `yomo:"0x11"`
41-
Therm Thermometer `yomo:"0x12"`
39+
Name string `y3:"0x10"`
40+
Noise float32 `y3:"0x11"`
41+
Therm Thermometer `y3:"0x12"`
4242
}
4343

4444
type Thermometer struct {
45-
Temperature float32 `yomo:"0x13"`
46-
Humidity float32 `yomo:"0x14"`
45+
Temperature float32 `y3:"0x13"`
46+
Humidity float32 `y3:"0x14"`
4747
}
4848

4949
func main() {

explainer_CN.md

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -36,14 +36,14 @@
3636

3737
```go
3838
type SourceData struct {
39-
Name string `yomo:"0x10"`
40-
Noise float32 `yomo:"0x11"`
41-
Therm Thermometer `yomo:"0x12"`
39+
Name string `y3:"0x10"`
40+
Noise float32 `y3:"0x11"`
41+
Therm Thermometer `y3:"0x12"`
4242
}
4343

4444
type Thermometer struct {
45-
Temperature float32 `yomo:"0x13"`
46-
Humidity float32 `yomo:"0x14"`
45+
Temperature float32 `y3:"0x13"`
46+
Humidity float32 `y3:"0x14"`
4747
}
4848

4949
func main() {

internal/tester/data.go

Lines changed: 44 additions & 44 deletions
Original file line numberDiff line numberDiff line change
@@ -1,84 +1,84 @@
11
package tester
22

33
type BasicTestData struct {
4-
Vstring string `yomo:"0x10"`
5-
Vint32 int32 `yomo:"0x11"`
6-
Vint64 int64 `yomo:"0x12"`
7-
Vuint32 uint32 `yomo:"0x13"`
8-
Vuint64 uint64 `yomo:"0x14"`
9-
Vfloat32 float32 `yomo:"0x15"`
10-
Vfloat64 float64 `yomo:"0x16"`
11-
Vbool bool `yomo:"0x17"`
4+
Vstring string `y3:"0x10"`
5+
Vint32 int32 `y3:"0x11"`
6+
Vint64 int64 `y3:"0x12"`
7+
Vuint32 uint32 `y3:"0x13"`
8+
Vuint64 uint64 `y3:"0x14"`
9+
Vfloat32 float32 `y3:"0x15"`
10+
Vfloat64 float64 `y3:"0x16"`
11+
Vbool bool `y3:"0x17"`
1212
}
1313

1414
type EmbeddedTestData struct {
15-
BasicTestData `yomo:"0x1a"`
16-
Vaction string `yomo:"0x1b"`
15+
BasicTestData `y3:"0x1a"`
16+
Vaction string `y3:"0x1b"`
1717
}
1818

1919
type EmbeddedMoreTestData struct {
20-
EmbeddedTestData `yomo:"0x1c"`
21-
Vanimal string `yomo:"0x1d"`
20+
EmbeddedTestData `y3:"0x1c"`
21+
Vanimal string `y3:"0x1d"`
2222
}
2323

2424
type NamedTestData struct {
25-
Base BasicTestData `yomo:"0x1e"`
26-
Vaction string `yomo:"0x1f"`
25+
Base BasicTestData `y3:"0x1e"`
26+
Vaction string `y3:"0x1f"`
2727
}
2828

2929
type NamedMoreTestData struct {
30-
MyNest NamedTestData `yomo:"0x2a"`
31-
Vanimal string `yomo:"0x2b"`
30+
MyNest NamedTestData `y3:"0x2a"`
31+
Vanimal string `y3:"0x2b"`
3232
}
3333

3434
type ArrayTestData struct {
35-
Vfoo string `yomo:"0x20"`
36-
Vbar [2]string `yomo:"0x21"`
37-
Vint32Array [2]int32 `yomo:"0x22"`
38-
Vint64Array [2]int64 `yomo:"0x23"`
39-
Vuint32Array [2]uint32 `yomo:"0x24"`
40-
Vuint64Array [2]uint64 `yomo:"0x25"`
41-
Vfloat32Array [2]float32 `yomo:"0x26"`
42-
Vfloat64Array [2]float64 `yomo:"0x27"`
35+
Vfoo string `y3:"0x20"`
36+
Vbar [2]string `y3:"0x21"`
37+
Vint32Array [2]int32 `y3:"0x22"`
38+
Vint64Array [2]int64 `y3:"0x23"`
39+
Vuint32Array [2]uint32 `y3:"0x24"`
40+
Vuint64Array [2]uint64 `y3:"0x25"`
41+
Vfloat32Array [2]float32 `y3:"0x26"`
42+
Vfloat64Array [2]float64 `y3:"0x27"`
4343
}
4444

4545
type SliceTestData struct {
46-
Vfoo string `yomo:"0x30"`
47-
Vbar []string `yomo:"0x31"`
48-
Vint32Slice []int32 `yomo:"0x32"`
49-
Vint64Slice []int64 `yomo:"0x33"`
50-
Vuint32Slice []uint32 `yomo:"0x34"`
51-
Vuint64Slice []uint64 `yomo:"0x35"`
52-
Vfloat32Slice []float32 `yomo:"0x36"`
53-
Vfloat64Slice []float64 `yomo:"0x37"`
46+
Vfoo string `y3:"0x30"`
47+
Vbar []string `y3:"0x31"`
48+
Vint32Slice []int32 `y3:"0x32"`
49+
Vint64Slice []int64 `y3:"0x33"`
50+
Vuint32Slice []uint32 `y3:"0x34"`
51+
Vuint64Slice []uint64 `y3:"0x35"`
52+
Vfloat32Slice []float32 `y3:"0x36"`
53+
Vfloat64Slice []float64 `y3:"0x37"`
5454
}
5555

5656
type SliceStructTestData struct {
57-
Vstring string `yomo:"0x2e"`
58-
BaseList []BasicTestData `yomo:"0x2f"`
59-
NamedMoreList []NamedMoreTestData `yomo:"0x3a"`
60-
EmbeddedMoreList []EmbeddedMoreTestData `yomo:"0x3b"`
57+
Vstring string `y3:"0x2e"`
58+
BaseList []BasicTestData `y3:"0x2f"`
59+
NamedMoreList []NamedMoreTestData `y3:"0x3a"`
60+
EmbeddedMoreList []EmbeddedMoreTestData `y3:"0x3b"`
6161
}
6262

6363
type ArrayStructTestData struct {
64-
Vstring string `yomo:"0x2e"`
65-
BaseList [2]BasicTestData `yomo:"0x2f"`
66-
NamedMoreList [2]NamedMoreTestData `yomo:"0x3a"`
67-
EmbeddedMoreList [2]EmbeddedMoreTestData `yomo:"0x3b"`
64+
Vstring string `y3:"0x2e"`
65+
BaseList [2]BasicTestData `y3:"0x2f"`
66+
NamedMoreList [2]NamedMoreTestData `y3:"0x3a"`
67+
EmbeddedMoreList [2]EmbeddedMoreTestData `y3:"0x3b"`
6868
}
6969

7070
type NestedTestData struct {
71-
SubNested Sub1NestedTestData `yomo:"0x3a"`
71+
SubNested Sub1NestedTestData `y3:"0x3a"`
7272
}
7373

7474
type Sub1NestedTestData struct {
75-
SubNested Sub2NestedTestData `yomo:"0x3b"`
75+
SubNested Sub2NestedTestData `y3:"0x3b"`
7676
}
7777

7878
type Sub2NestedTestData struct {
79-
SubNested Sub3NestedTestData `yomo:"0x3c"`
79+
SubNested Sub3NestedTestData `y3:"0x3c"`
8080
}
8181

8282
type Sub3NestedTestData struct {
83-
BasicList []BasicTestData `yomo:"0x3d"`
83+
BasicList []BasicTestData `y3:"0x3d"`
8484
}

structure_decoder.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -52,7 +52,7 @@ func newStructDecoder(mold interface{}, options ...func(*structDecoderImpl)) str
5252
decoder := &structDecoderImpl{
5353
config: &structDecoderConfig{
5454
ZeroFields: true,
55-
TagName: "yomo",
55+
TagName: "y3",
5656
},
5757
result: mold,
5858
}

structure_decoder_test.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -34,7 +34,7 @@ func TestBasic_Struct(t *testing.T) {
3434
func runDecode(t *testing.T, inputBuf []byte, output interface{}) {
3535
_, err := newStructDecoder(output, structDecoderOptionConfig(&structDecoderConfig{
3636
ZeroFields: true,
37-
TagName: "yomo",
37+
TagName: "y3",
3838
})).Decode(inputBuf)
3939
if err != nil {
4040
t.Errorf("got an err: %s", err.Error())

structure_encoder.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -52,7 +52,7 @@ func newStructEncoder(observe byte, options ...func(*structEncoderImpl)) structE
5252
encoder := &structEncoderImpl{
5353
config: &structEncoderConfig{
5454
ZeroFields: true,
55-
TagName: "yomo",
55+
TagName: "y3",
5656
},
5757
observe: observe,
5858
root: utils.EmptyKey,

structure_encoder_test.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,7 @@ func TestStructEncoderWithSignals(t *testing.T) {
1919
encoder := newStructEncoder(0x30, structEncoderOptionRoot(rootToken),
2020
structEncoderOptionConfig(&structEncoderConfig{
2121
ZeroFields: true,
22-
TagName: "yomo",
22+
TagName: "y3",
2323
}))
2424
inputBuf, _ := encoder.Encode(input,
2525
createSignal(0x02).SetString("a"),

0 commit comments

Comments
 (0)