Augment safeRouteList.Append() to return a model.Route with index

Co-authored-by: Roberto Abdelkader Martínez Pérez <robertomartinezp@gmail.com>
This commit is contained in:
pancho horrillo
2019-10-08 17:53:15 +02:00
parent e0dd6f5dd5
commit 037347dbe3
2 changed files with 27 additions and 1 deletions
+4 -1
View File
@@ -18,10 +18,13 @@ func New() safeRouteList {
}
}
func (srl *safeRouteList) Append(r model.Route) {
func (srl *safeRouteList) Append(r model.Route) model.Route {
srl.m.Lock()
srl.rs = append(srl.rs, r)
l := len(srl.rs)
srl.m.Unlock()
return model.Route{Index: l - 1}
}
func (srl *safeRouteList) Snapshot() []model.Route {