sync.Once with Reset()
Switch branches/tags
Nothing to show
Clone or download
Latest commit d39c09a Dec 12, 2016
Failed to load latest commit information.
.gitignore Initial commit Mar 30, 2015
LICENSE Create LICENSE Jun 30, 2016 Update Dec 11, 2016
once.go tweaks Mar 30, 2015
once_test.go added Once (twice really) Mar 30, 2015


sync.Once with Reset()

Rather than adding this project as a dependency, consider dropping this file into your project.


The following example examines how resync.Once could be used in a HTTP server situation.

// use it just like sync.Once
var once resync.Once

// handle a web request
func handleRequest(w http.ResponseWriter, r *http.Request) {
		// load templates or something
	// TODO: respond

// handle some request that indicates things have changed
func handleResetRequest(w http.ResponseWriter, r *http.Request) {
	once.Reset() // call Reset to cause initialisation to happen again above