Skip to content

Commit a10f042

Browse files
committed
Use semver.Dependency interface to represent a library dependency
1 parent c593153 commit a10f042

File tree

2 files changed

+18
-3
lines changed

2 files changed

+18
-3
lines changed

arduino/libraries/librariesindex/index.go

+16-1
Original file line numberDiff line numberDiff line change
@@ -45,7 +45,7 @@ type Library struct {
4545
type Release struct {
4646
Author string
4747
Version *semver.Version
48-
Dependencies []*Dependency
48+
Dependencies []semver.Dependency
4949
Maintainer string
5050
Sentence string
5151
Paragraph string
@@ -58,6 +58,21 @@ type Release struct {
5858
Library *Library `json:"-"`
5959
}
6060

61+
// GetName returns the name of this library.
62+
func (r *Release) GetName() string {
63+
return r.Library.Name
64+
}
65+
66+
// GetVersion returns the version of this library.
67+
func (r *Release) GetVersion() *semver.Version {
68+
return r.Version
69+
}
70+
71+
// GetDependencies returns the dependencies of this library.
72+
func (r *Release) GetDependencies() []semver.Dependency {
73+
return r.Dependencies
74+
}
75+
6176
// Dependency is a library dependency
6277
type Dependency struct {
6378
Name string

arduino/libraries/librariesindex/json.go

+2-2
Original file line numberDiff line numberDiff line change
@@ -118,8 +118,8 @@ func (indexLib *indexRelease) extractReleaseIn(library *Library) {
118118
}
119119
}
120120

121-
func (indexLib *indexRelease) extractDependencies() []*Dependency {
122-
res := []*Dependency{}
121+
func (indexLib *indexRelease) extractDependencies() []semver.Dependency {
122+
res := []semver.Dependency{}
123123
if indexLib.Dependencies == nil || len(indexLib.Dependencies) == 0 {
124124
return res
125125
}

0 commit comments

Comments
 (0)