-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathexample_apps_test.go
More file actions
39 lines (33 loc) · 965 Bytes
/
example_apps_test.go
File metadata and controls
39 lines (33 loc) · 965 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
// (c) Siemens AG 2023
//
// SPDX-License-Identifier: MIT
package ieddata_test
import (
"fmt"
"slices"
"strings"
ieddata "github.com/siemens/ieddata"
)
// List the Industrial Edge Apps installed on this IED, with their titles and
// app IDs.
func Example_listInstalledApps() {
db, err := ieddata.Open("platformbox.db")
if err != nil {
panic(err)
}
defer func() { _ = db.Close() }()
apps, err := db.Apps()
if err != nil {
panic(err)
}
// Sort the apps by their titles in order to get a stable output result that
// can also be tested.
slices.SortFunc(apps, func(a, b ieddata.App) int { return strings.Compare(a.Title, b.Title) })
for _, app := range apps {
fmt.Printf("%q %s %s\n", app.Title, app.Version, app.Id)
}
// Output: "AppA" 1.9.18 195ff5e2e15a149ca5eb7c59d3857cc5
// "AppB" 0.6.66666666666 7bd06d3bbf816d0658d5a871b0a498ff
// "AppC" 1.1.0 1842f53281412f9c657c7765494ff80e
// "AppD" 0.19.1 2a267358a0403fddb039924fbc4f3169
}