code: func (m *lockingMap) AddOrGet(key string, creator LockingMapAddFunc) (interface{}, error) {
  	// Fast and easy path: key exists just return it.
  	if val, ok := m.Get(key); ok {
  		return val, nil
  	}
  
  	// Does not exist. Prepare to add it by upgrading key lock to a write lock.
  	// This is potentially held for a long time but it's only on the key.
  	m.keyLocker.Lock(key)
  	defer m.keyLocker.Unlock(key)
  
  	// Reverify that the key has not already been set, but we want to only do this
  	// briefly with a read lock on the main map.
  	val, exists := func() (interface{}, bool) {
  		m.lock.RLock()
  		defer m.lock.RUnlock()
  
  		// Must also reverify against the check function
  		val, ok := m.data[key]
  		if ok && (m.checkFunc == nil || m.checkFunc(key, val)) {
  			return val, true
  		}
  		return nil, false
  	}()
  	if exists {
  		return val, nil
  	}
  
  	// With the key write lock held (but NOT the map lock), call the user specified
  	// create function.
  	val, err := creator(key)
  	if err != nil {
  		return nil, err
  	}
  
  	// Now we need the map's write lock to set this key...
  	m.lock.Lock()
  	defer m.lock.Unlock()
  
  	// Set and return and we're done!
  	m.data[key] = val
  	return val, nil
  }
docs: // AddOrGet returns the current value. You must pass in a LockingMapAddFunc
  // as the second parameter: if the key you are requesting is not present in the
  // map then we will call your function and you must return the value or an
  // error. The LockingMap guarantees that the Get-to-Add phase is done atomically,
  // i.e., it will hold a lock on this key through as long as your function takes
  // to run. Returns the value for the key or an error.