code: func (k *Store) Save() error {
  	k.mu.Lock()
  	defer k.mu.Unlock()
  
  	// Short-circuit if we have no changes
  	if len(k.log) == 0 {
  		return nil
  	}
  
  	// firstly peek at version; open read/write to keep lock between check & write
  	f, err := os.OpenFile(k.filename, os.O_RDWR|os.O_CREATE, 0664)
  	if err != nil {
  		return err
  	}
  
  	defer f.Close()
  
  	// Only try to merge if > 0 bytes, ignore empty files (decoder will fail)
  	if stat, _ := f.Stat(); stat.Size() > 0 {
  		k.loadAndMergeReaderIfNeeded(f)
  		// Now we overwrite the file
  		f.Seek(0, os.SEEK_SET)
  		f.Truncate(0)
  	}
  
  	k.version++
  
  	enc := gob.NewEncoder(f)
  	if err := enc.Encode(k.version); err != nil {
  		return fmt.Errorf("Error while writing version data to %v: %v", k.filename, err)
  	}
  	if err := enc.Encode(k.db); err != nil {
  		return fmt.Errorf("Error while writing new key/value data to %v: %v", k.filename, err)
  	}
  	// Clear log now that it's saved
  	k.log = nil
  
  	return nil
  }
docs: // Save persists the changes made to disk
  // If any changes have been written by other code they will be merged