code: func Create(dirpath string, metadata []byte) (*WAL, error) {
  	if Exist(dirpath) {
  		return nil, os.ErrExist
  	}
  
  	if err := os.MkdirAll(dirpath, privateDirMode); err != nil {
  		return nil, err
  	}
  
  	p := path.Join(dirpath, walName(0, 0))
  	f, err := os.OpenFile(p, os.O_WRONLY|os.O_APPEND|os.O_CREATE, 0600)
  	if err != nil {
  		return nil, err
  	}
  	l, err := fileutil.NewLock(f.Name())
  	if err != nil {
  		return nil, err
  	}
  	if err = l.Lock(); err != nil {
  		return nil, err
  	}
  
  	w := &WAL{
  		dir:      dirpath,
  		metadata: metadata,
  		seq:      0,
  		f:        f,
  		encoder:  newEncoder(f, 0),
  	}
  	w.locks = append(w.locks, l)
  	if err := w.saveCrc(0); err != nil {
  		return nil, err
  	}
  	if err := w.encoder.encode(&walpb.Record{Type: metadataType, Data: metadata}); err != nil {
  		return nil, err
  	}
  	if err := w.SaveSnapshot(walpb.Snapshot{}); err != nil {
  		return nil, err
  	}
  	return w, nil
  }
docs: // Create creates a WAL ready for appending records. The given metadata is
  // recorded at the head of each WAL file, and can be retrieved with ReadAll.