rewrite of decurse in golang/angular