fw_lab_triage_helper: refine labstation list impl
Avoids two nearly identical lists.
BUG=None, because it's implementing a TODO
TEST=built and ran against the faft_cr50 pool
Change-Id: Ib410e3609ec3640cdf11dfcee1ee5c22d932085d
Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/crostestutils/+/1869565
Tested-by: Kevin Shelton <kmshelton@chromium.org>
Reviewed-by: Greg Edelston <gredelston@google.com>
Commit-Queue: Kevin Shelton <kmshelton@chromium.org>
diff --git a/provingground/firmware/fw_lab_triage_helper.go b/provingground/firmware/fw_lab_triage_helper.go
index 69289f3..ca1ac4b 100644
--- a/provingground/firmware/fw_lab_triage_helper.go
+++ b/provingground/firmware/fw_lab_triage_helper.go
@@ -131,13 +131,18 @@
w.Flush()
log.Print("Gathering and displaying key telemetry for labstations.")
- // TODO(kmshelton): Do this without keeping two approximately-identical memos.
+ containsElement := func(array []string, element string) bool {
+ for _, x := range array {
+ if x == element {
+ return true
+ }
+ }
+ return false
+ }
labstations := []string{}
- labstationsSeen := make(map[string]bool)
for _, dut := range duts {
- if _, ok := labstationsSeen[dut.Labstation]; !ok && dut.Labstation != "" {
+ if !containsElement(labstations, dut.Labstation) && dut.Labstation != "" {
labstations = append(labstations, dut.Labstation)
- labstationsSeen[dut.Labstation] = true
}
}