Skip to content

Commit 9020cdd

Browse files
committed
Use element instead of index in loops
1 parent cb7012b commit 9020cdd

File tree

1 file changed

+6
-10
lines changed

1 file changed

+6
-10
lines changed

commands/show.go

Lines changed: 6 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -124,10 +124,8 @@ func showDefaultFormatter(env *Env, snapshot *bug.Snapshot) error {
124124

125125
// Labels
126126
var labels = make([]string, len(snapshot.Labels()))
127-
//TODO can I replace the index here?
128-
//TODO What about using Label::String() instead of string()?
129-
for i := range snapshot.Labels() {
130-
labels[i] = string(snapshot.Labels()[i])
127+
for _, label := range snapshot.Labels() {
128+
labels = append(labels, label.String())
131129
}
132130

133131
env.out.Printf("labels: %s\n",
@@ -136,20 +134,18 @@ func showDefaultFormatter(env *Env, snapshot *bug.Snapshot) error {
136134

137135
// Actors
138136
var actors = make([]string, len(snapshot.Actors()))
139-
//TODO can I replace the index here?
140-
for i := range snapshot.Actors() {
141-
actors[i] = snapshot.Actors()[i].DisplayName()
137+
for _, actor := range snapshot.Actors() {
138+
actors = append(actors, actor.DisplayName())
142139
}
143140

144141
env.out.Printf("actors: %s\n",
145142
strings.Join(actors, ", "),
146143
)
147144

148145
// Participants
149-
//TODO can I replace the index here?
150146
var participants = make([]string, len(snapshot.Participants()))
151-
for i := range snapshot.Participants() {
152-
participants[i] = snapshot.Participants()[i].DisplayName()
147+
for _, participant := range snapshot.Participants() {
148+
participants = append(participants, participant.DisplayName())
153149
}
154150

155151
env.out.Printf("participants: %s\n\n",

0 commit comments

Comments
 (0)