* roger peppe <[email protected]> [171120 09:35]: > This trick is used in the standard library (see net.http.envOnce.reset), and > for > testing purposes it's just about OK (though still dubious IMHO) but you should > never use it in production code, as you're writing atomic state with > non-atomic > operations.
When I read this, I was afraid something might be wrong in the net.http code. But by looking at the code, it is clear that what you meant by "this trick" was replacing an existing instance of sync.Once with a new instance, as opposed to copying an already-used instance of sync.Once and using both the copy and the original. The latter is completely broken. The former might be safe as long as the assignment to the variable containing the Once is properly synchronized with any other assignments or reads. It is not clear from the code in transport.go whether any synchronization is necessary; there is none in envOnce. ...Marvin -- You received this message because you are subscribed to the Google Groups "golang-nuts" group. To unsubscribe from this group and stop receiving emails from it, send an email to [email protected]. For more options, visit https://groups.google.com/d/optout.
