Skip to content

Commit a321ed8

Browse files
committed
Use easyjson for parsing library_index
1 parent 3bd18fc commit a321ed8

File tree

9 files changed

+883
-2
lines changed

9 files changed

+883
-2
lines changed

arduino/discovery/discovery_client/go.sum

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -192,6 +192,7 @@ github.com/ianlancetaylor/demangle v0.0.0-20200824232613-28f6c0f3b639/go.mod h1:
192192
github.com/inconshreveable/mousetrap v1.0.0/go.mod h1:PxqpIevigyE2G7u3NXJIT2ANytuPF1OarO4DADm73n8=
193193
github.com/jbenet/go-context v0.0.0-20150711004518-d14ea06fba99/go.mod h1:1lJo3i6rXxKeerYnT8Nvf0QmHCRC1n8sfWVwXF2Frvo=
194194
github.com/jessevdk/go-flags v1.4.0/go.mod h1:4FA24M0QyGHXBuZZK/XkWh8h0e1EYbRYJSGM75WSRxI=
195+
github.com/josharian/intern v1.0.0/go.mod h1:5DoeVV0s6jJacbCEi61lwdGj/aVlrQvzHFFd8Hwg//Y=
195196
github.com/json-iterator/go v1.1.11/go.mod h1:KdQUCv79m/52Kvf8AW2vK1V8akMuk1QjK/uOdHXbAo4=
196197
github.com/jstemmer/go-junit-report v0.0.0-20190106144839-af01ea7f8024/go.mod h1:6v2b51hI/fHJwM22ozAgKL4VKDeJcHhJFhtBdhmNjmU=
197198
github.com/jstemmer/go-junit-report v0.9.1/go.mod h1:Brl9GWCQeLvo8nXZwPNNblvFj/XSXhF0NWZEnDohbsk=
@@ -219,6 +220,7 @@ github.com/kr/text v0.2.0/go.mod h1:eLer722TekiGuMkidMxC/pM04lWEeraHUUmBw8l2grE=
219220
github.com/leonelquinteros/gotext v1.4.0 h1:2NHPCto5IoMXbrT0bldPrxj0qM5asOCwtb1aUQZ1tys=
220221
github.com/leonelquinteros/gotext v1.4.0/go.mod h1:yZGXREmoGTtBvZHNcc+Yfug49G/2spuF/i/Qlsvz1Us=
221222
github.com/magiconair/properties v1.8.5/go.mod h1:y3VJvCyxH9uVvJTWEGAELF3aiYNyPKd5NZ3oSwXrF60=
223+
github.com/mailru/easyjson v0.7.7/go.mod h1:xzfreul335JAWq5oZzymOObrkdz5UnU4kGfJJLY9Nlc=
222224
github.com/marcinbor85/gohex v0.0.0-20210308104911-55fb1c624d84/go.mod h1:Pb6XcsXyropB9LNHhnqaknG/vEwYztLkQzVCHv8sQ3M=
223225
github.com/mattn/go-colorable v0.0.9/go.mod h1:9vuHe8Xs5qXnSaW/c/ABM9alt+Vo+STaOChaDxuIBZU=
224226
github.com/mattn/go-colorable v0.1.8/go.mod h1:u6P/XSegPjTcexA+o6vUJrdnUu04hMope9wVRipJSqc=

arduino/libraries/librariesindex/json.go

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -16,19 +16,21 @@
1616
package librariesindex
1717

1818
import (
19-
"encoding/json"
2019
"fmt"
2120

2221
"github.com/arduino/arduino-cli/arduino/resources"
2322
"github.com/arduino/arduino-cli/i18n"
2423
"github.com/arduino/go-paths-helper"
24+
easyjson "github.com/mailru/easyjson"
2525
semver "go.bug.st/relaxed-semver"
2626
)
2727

28+
//easyjson:json
2829
type indexJSON struct {
2930
Libraries []indexRelease `json:"libraries"`
3031
}
3132

33+
//easyjson:json
3234
type indexRelease struct {
3335
Name string `json:"name"`
3436
Version *semver.Version `json:"version"`
@@ -49,6 +51,7 @@ type indexRelease struct {
4951
ProvidesIncludes []string `json:"providesIncludes"`
5052
}
5153

54+
//easyjson:json
5255
type indexDependency struct {
5356
Name string `json:"name"`
5457
Version string `json:"version,omitempty"`
@@ -64,7 +67,7 @@ func LoadIndex(indexFile *paths.Path) (*Index, error) {
6467
}
6568

6669
var i indexJSON
67-
err = json.Unmarshal(buff, &i)
70+
err = easyjson.Unmarshal(buff, &i)
6871
if err != nil {
6972
return nil, fmt.Errorf(tr("parsing library_index.json: %s"), err)
7073
}

0 commit comments

Comments
 (0)