func channel2rpc(ctx *context.T, src <-chan *spec.Triangle, dst string, errch chan<- error, myScreen chan<- *spec.Triangle) { for t := range src { // This is an "interactive" game, if an RPC doesn't succeed in say ctxTimeout, cancel := context.WithTimeout(ctx, maxTriangleGiveTime) if err := spec.ScreenClient(dst).Give(ctxTimeout, *t, options.ServerAuthorizer{security.AllowEveryone()}); err != nil { cancel() returnTriangle(t, myScreen) ctx.Infof("%q.Give failed: %v, aborting connection with remote screen", dst, err) errch <- err break } cancel() } for t := range src { returnTriangle(t, myScreen) } ctx.VI(1).Infof("Exiting goroutine with connection to %q", dst) }