Skip to content

Commit 103dd8d

Browse files
per1234Massimiliano Pippi
authored and
Massimiliano Pippi
committed
[skip changelog] Demonstrate gRPC interface's LibraryResolveDependencies method in client_example (#552)
1 parent 23e4d70 commit 103dd8d

File tree

2 files changed

+25
-1
lines changed

2 files changed

+25
-1
lines changed

Diff for: client_example/go.mod

+1-1
Original file line numberDiff line numberDiff line change
@@ -6,4 +6,4 @@ require (
66
github.com/arduino/arduino-cli v0.0.0-20200109150215-ffa84fdaab21
77
github.com/gosuri/uitable v0.0.0-20160404203958-36ee7e946282 // indirect
88
google.golang.org/grpc v1.23.0
9-
)
9+
)

Diff for: client_example/main.go

+24
Original file line numberDiff line numberDiff line change
@@ -164,6 +164,10 @@ func main() {
164164
log.Println("calling LibrarySearch(audio)")
165165
callLibSearch(client, instance)
166166

167+
// List the dependencies of the ArduinoIoTCloud library
168+
log.Println("calling LibraryResolveDependencies(ArduinoIoTCloud)")
169+
callLibraryResolveDependencies(client, instance)
170+
167171
// List installed libraries
168172
log.Println("calling LibraryList")
169173
callLibList(client, instance)
@@ -734,6 +738,26 @@ func callLibSearch(client rpc.ArduinoCoreClient, instance *rpc.Instance) {
734738
}
735739
}
736740

741+
func callLibraryResolveDependencies(client rpc.ArduinoCoreClient, instance *rpc.Instance) {
742+
libraryResolveDependenciesResp, err := client.LibraryResolveDependencies(context.Background(),
743+
&rpc.LibraryResolveDependenciesReq{
744+
Instance: instance,
745+
Name: "ArduinoIoTCloud",
746+
})
747+
748+
if err != nil {
749+
log.Fatalf("Error listing library dependencies: %s", err)
750+
}
751+
752+
for _, resp := range libraryResolveDependenciesResp.GetDependencies() {
753+
log.Printf("Dependency Name: %s", resp.GetName())
754+
log.Printf("Version Required: %s", resp.GetVersionRequired())
755+
if resp.GetVersionInstalled() != "" {
756+
log.Printf("Version Installed: %s\n", resp.GetVersionInstalled())
757+
}
758+
}
759+
}
760+
737761
func callLibList(client rpc.ArduinoCoreClient, instance *rpc.Instance) {
738762
libLstResp, err := client.LibraryList(context.Background(),
739763
&rpc.LibraryListReq{

0 commit comments

Comments
 (0)