code: func (s *storage) openForWrite(n int) error {
  	fn := s.filename(n)
  	l, err := lock.Lock(fn + ".lock")
  	if err != nil {
  		return err
  	}
  	f, err := os.OpenFile(fn, os.O_RDWR|os.O_CREATE, 0666)
  	if err != nil {
  		l.Close()
  		return err
  	}
  	openFdsVar.Add(s.root, 1)
  	debug.Printf("diskpacked: opened for write %q", fn)
  
  	s.size, err = f.Seek(0, os.SEEK_END)
  	if err != nil {
  		f.Close()
  		l.Close()
  		return err
  	}
  
  	s.writer = f
  	s.writeLock = l
  	return nil
  }
docs: // openForWrite will create or open pack file n for writes, create a lock
  // visible external to the process and seek to the end of the file ready for
  // appending new data.
  // This function is not thread safe, s.mu should be locked by the caller.