Agent service discovery

—
It does, but that's not clear unless you do some digging.  For instance
this code:

func a() {
   err := 'foo'
   defer func() {
       fmt.Printf("%s\n", err)
   }()
   err = 'bar'
}

prints out "bar"

Using a rarely used language feature in a way that invokes an even
more-rarely used conflict resolution rule isn't clear code.  You can fix
this by using renaming the exit variable.

And, no, you're not using a single variable.  You're using the same name
for four different variables.  Every time you're using := you're creating a
new variable in its particular scope.







On Wed, Dec 10, 2014 at 6:26 PM, Peter Bourgon <notifications@github.com>
wrote:

> In harpoon-scheduler/registry/registry.go
> <https://github.com/soundcloud/harpoon/pull/150#discussion-diff-21619565>:
>
> > @@ -179,31 +179,41 @@ func (r *Registry) loop(filename string, scheduled map[string]configstore.JobCon
> >  	}
> >  }
> >
> > -func save(filename string, scheduled map[string]configstore.JobConfig) error {
> > +func save(filename string, scheduled map[string]configstore.JobConfig) (err error) {
>
>  There are four different variables name 'err' in various scopes here.
>
> Any return err statement binds the specific err in question to the
> already-declared named return. So, there's only ever 1 error value which
> escapes the function scope.
>
> (Are you sure the defer at line 194 isn't referencing the err variable
> defined in #189?)
>
> Yep. Check it in this playground gist
> <http://play.golang.org/p/zESEF_0Zk5>.
>
> just use the return variable named 'err' throughout the entire function.
>
> That's what I'm doing :)
>
> —
> Reply to this email directly or view it on GitHub
> <https://github.com/soundcloud/harpoon/pull/150/files#r21619565>.
>



-- 
- Jeff Younker - jmy@soundcloud.com - +49 (0) 171 5641365 -