Skip to content

Commit 40e6c18

Browse files
committed
fix go vet error: Id should be ID
1 parent a4c8342 commit 40e6c18

4 files changed

Lines changed: 32 additions & 32 deletions

File tree

apk/apk.go

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -74,7 +74,7 @@ func (k *Apk) Close() error {
7474
// Icon return icon image
7575
func (k *Apk) Icon(resConfig *androidbinary.ResTableConfig) (image.Image, error) {
7676
iconPath := k.getResource(k.manifest.App.Icon, resConfig)
77-
if androidbinary.IsResId(iconPath) {
77+
if androidbinary.IsResID(iconPath) {
7878
return nil, errors.New("unable to convert icon-id to icon path")
7979
}
8080
imgData, err := k.readZipFile(iconPath)
@@ -87,7 +87,7 @@ func (k *Apk) Icon(resConfig *androidbinary.ResTableConfig) (image.Image, error)
8787

8888
func (k *Apk) Label(resConfig *androidbinary.ResTableConfig) (s string, err error) {
8989
s = k.getResource(k.manifest.App.Label, resConfig)
90-
if androidbinary.IsResId(s) {
90+
if androidbinary.IsResID(s) {
9191
err = errors.New("unable to convert label-id to string")
9292
}
9393
return
@@ -140,7 +140,7 @@ func (k *Apk) parseResources() (err error) {
140140
}
141141

142142
func (k *Apk) getResource(id string, resConfig *androidbinary.ResTableConfig) string {
143-
resID, err := androidbinary.ParseResId(id)
143+
resID, err := androidbinary.ParseResID(id)
144144
if err != nil {
145145
return id
146146
}

table.go

Lines changed: 18 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@ import (
99
"unsafe"
1010
)
1111

12-
type ResId uint32
12+
type ResID uint32
1313

1414
type TableFile struct {
1515
stringPool *ResStringPool
@@ -23,7 +23,7 @@ type ResTableHeader struct {
2323

2424
type ResTablePackage struct {
2525
Header ResChunkHeader
26-
Id uint32
26+
ID uint32
2727
Name [128]uint16
2828
TypeStrings uint32
2929
LastPublicType uint32
@@ -40,7 +40,7 @@ type TablePackage struct {
4040

4141
type ResTableType struct {
4242
Header ResChunkHeader
43-
Id uint8
43+
ID uint8
4444
Res0 uint8
4545
Res1 uint16
4646
EntryCount uint32
@@ -157,42 +157,42 @@ type TableEntry struct {
157157

158158
type ResTableTypeSpec struct {
159159
Header ResChunkHeader
160-
Id uint8
160+
ID uint8
161161
Res0 uint8
162162
Res1 uint16
163163
EntryCount uint32
164164
}
165165

166-
// IsResId returns whether s is ResId.
167-
func IsResId(s string) bool {
166+
// IsResID returns whether s is ResId.
167+
func IsResID(s string) bool {
168168
return strings.HasPrefix(s, "@0x")
169169
}
170170

171-
// ParseResId parses ResId.
172-
func ParseResId(s string) (ResId, error) {
173-
if !IsResId(s) {
174-
return 0, fmt.Errorf("androidbinary: %s is not ResId", s)
171+
// ParseResID parses ResId.
172+
func ParseResID(s string) (ResID, error) {
173+
if !IsResID(s) {
174+
return 0, fmt.Errorf("androidbinary: %s is not ResID", s)
175175
}
176176
id, err := strconv.ParseUint(s[3:], 16, 32)
177177
if err != nil {
178178
return 0, err
179179
}
180-
return ResId(id), nil
180+
return ResID(id), nil
181181
}
182182

183-
func (id ResId) String() string {
183+
func (id ResID) String() string {
184184
return fmt.Sprintf("@0x%08X", uint32(id))
185185
}
186186

187-
func (id ResId) Package() int {
187+
func (id ResID) Package() int {
188188
return int(id) >> 24
189189
}
190190

191-
func (id ResId) Type() int {
191+
func (id ResID) Type() int {
192192
return (int(id) >> 16) & 0xFF
193193
}
194194

195-
func (id ResId) Entry() int {
195+
func (id ResID) Entry() int {
196196
return int(id) & 0xFFFF
197197
}
198198

@@ -223,7 +223,7 @@ func (p *TablePackage) findEntry(typeIndex, entryIndex int, config *ResTableConf
223223
var best *TableType
224224
for _, t := range p.TableTypes {
225225
switch {
226-
case int(t.Header.Id) != typeIndex:
226+
case int(t.Header.ID) != typeIndex:
227227
// nothing to do
228228
case !t.Header.Config.Match(config):
229229
// nothing to do
@@ -241,7 +241,7 @@ func (p *TablePackage) findEntry(typeIndex, entryIndex int, config *ResTableConf
241241
return best.Entries[entryIndex]
242242
}
243243

244-
func (f *TableFile) GetResource(id ResId, config *ResTableConfig) (interface{}, error) {
244+
func (f *TableFile) GetResource(id ResID, config *ResTableConfig) (interface{}, error) {
245245
p := f.findPackage(id.Package())
246246
if p == nil {
247247
return nil, fmt.Errorf("androidbinary: package 0x%02X not found", id.Package())
@@ -290,7 +290,7 @@ func (f *TableFile) readChunk(r io.ReaderAt, offset int64) (*ResChunkHeader, err
290290
case RES_TABLE_PACKAGE_TYPE:
291291
var tablePackage *TablePackage
292292
tablePackage, err = readTablePackage(sr)
293-
f.tablePackages[tablePackage.Header.Id] = tablePackage
293+
f.tablePackages[tablePackage.Header.ID] = tablePackage
294294
}
295295
if err != nil {
296296
return nil, err

table_test.go

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -14,14 +14,14 @@ func TestIsResId(t *testing.T) {
1414
{"foo", false},
1515
}
1616
for _, c := range cases {
17-
if got := IsResId(c.input); got != c.want {
17+
if got := IsResID(c.input); got != c.want {
1818
t.Errorf("%s: want %v, got %v", c.input, got, c.want)
1919
}
2020
}
2121
}
2222

2323
func TestParseResId(t *testing.T) {
24-
id, err := ParseResId("@0x12345678")
24+
id, err := ParseResID("@0x12345678")
2525
if err != nil {
2626
t.Error(err)
2727
}
@@ -47,15 +47,15 @@ func TestFindPackage(t *testing.T) {
4747

4848
func TestGetResourceNil(t *testing.T) {
4949
tableFile := loadTestData()
50-
val, _ := tableFile.GetResource(ResId(0x7f040000), nil)
50+
val, _ := tableFile.GetResource(ResID(0x7f040000), nil)
5151
if val != "花火距離計算" {
5252
t.Errorf(`got %v want "花火距離計算"`, val)
5353
}
5454
}
5555

5656
func TestGetResourceDefault(t *testing.T) {
5757
tableFile := loadTestData()
58-
val, _ := tableFile.GetResource(ResId(0x7f040000), &ResTableConfig{})
58+
val, _ := tableFile.GetResource(ResID(0x7f040000), &ResTableConfig{})
5959
if val != "FireworksMeasure" {
6060
t.Errorf(`got %v want "FireworksMeasure"`, val)
6161
}
@@ -66,7 +66,7 @@ func TestGetResourceJA(t *testing.T) {
6666
config := &ResTableConfig{
6767
Language: [2]uint8{'j', 'a'},
6868
}
69-
val, _ := tableFile.GetResource(ResId(0x7f040000), config)
69+
val, _ := tableFile.GetResource(ResID(0x7f040000), config)
7070
if val != "花火距離計算" {
7171
t.Errorf(`got %v want "花火距離計算"`, val)
7272
}
@@ -77,7 +77,7 @@ func TestGetResourceEN(t *testing.T) {
7777
config := &ResTableConfig{
7878
Language: [2]uint8{'e', 'n'},
7979
}
80-
val, _ := tableFile.GetResource(ResId(0x7f040000), config)
80+
val, _ := tableFile.GetResource(ResID(0x7f040000), config)
8181
if val != "FireworksMeasure" {
8282
t.Errorf(`got %v want "FireworksMeasure"`, val)
8383
}

xml.go

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -24,7 +24,7 @@ type ResXMLTreeNode struct {
2424

2525
type ResXMLTreeNamespaceExt struct {
2626
Prefix ResStringPoolRef
27-
Uri ResStringPoolRef
27+
URI ResStringPoolRef
2828
}
2929

3030
type ResXMLTreeAttrExt struct {
@@ -33,7 +33,7 @@ type ResXMLTreeAttrExt struct {
3333
AttributeStart uint16
3434
AttributeSize uint16
3535
AttributeCount uint16
36-
IdIndex uint16
36+
IDIndex uint16
3737
ClassIndex uint16
3838
StyleIndex uint16
3939
}
@@ -129,12 +129,12 @@ func (f *XMLFile) readStartNamespace(sr *io.SectionReader) error {
129129
if f.notPrecessedNS == nil {
130130
f.notPrecessedNS = make(map[ResStringPoolRef]ResStringPoolRef)
131131
}
132-
f.notPrecessedNS[namespace.Uri] = namespace.Prefix
132+
f.notPrecessedNS[namespace.URI] = namespace.Prefix
133133

134134
if f.namespaces == nil {
135135
f.namespaces = make(map[ResStringPoolRef]ResStringPoolRef)
136136
}
137-
f.namespaces[namespace.Uri] = namespace.Prefix
137+
f.namespaces[namespace.URI] = namespace.Prefix
138138

139139
return nil
140140
}
@@ -152,7 +152,7 @@ func (f *XMLFile) readEndNamespace(sr *io.SectionReader) error {
152152
if err := binary.Read(sr, binary.LittleEndian, namespace); err != nil {
153153
return err
154154
}
155-
delete(f.namespaces, namespace.Uri)
155+
delete(f.namespaces, namespace.URI)
156156
return nil
157157
}
158158

0 commit comments

Comments
 (0)