It's bad practice to define an error globally. Let's say you create a goroutine which uses that same err variable (such as an http handler)--now you have a race condition, as that memory is being modified across threads.
True, and looking at the code, it doesn't make sense to define it as a global, since each potential goroutine (i.e. the HTTP handler functions) is re-defining 'err' whenever it's being used.