code: func (f *autoclosedFile) ensureOpen() error {
  	if f.fd != nil {
  		// File is already open
  		return nil
  	}
  
  	// We open the file for write only, and create it if it doesn't exist.
  	flags := os.O_WRONLY | os.O_CREATE
  	if f.opened.IsZero() {
  		// This is the first time we are opening the file. We should truncate
  		// it to better emulate an os.Create() call.
  		flags |= os.O_TRUNC
  	} else {
  		// The file was already opened once, so we should append to it.
  		flags |= os.O_APPEND
  	}
  
  	fd, err := os.OpenFile(f.name, flags, 0644)
  	if err != nil {
  		return err
  	}
  
  	f.fd = fd
  	f.opened = time.Now()
  	return nil
  }
docs: // Must be called with f.mut held!