code: func writeBucket(f *os.File, items map[string]bucketItem) error {
  	// Marshal items to disk format.
  	bytes, err := json.Marshal(items)
  	if err != nil {
  		return trace.Wrap(err)
  	}
  
  	// Truncate the file.
  	if _, err := f.Seek(0, 0); err != nil {
  		return trace.ConvertSystemError(err)
  	}
  	if err := f.Truncate(0); err != nil {
  		return trace.ConvertSystemError(err)
  	}
  
  	// Write out the contents to disk.
  	n, err := f.Write(bytes)
  	if err == nil && n < len(bytes) {
  		return trace.Wrap(io.ErrShortWrite)
  	}
  
  	return nil
  }
docs: // writeBucket will truncate the file and write out the items to the file f.