如何导入导入的包的供应商包

I am using etcd's wal package (https://godoc.org/github.com/coreos/etcd/wal) to do write-ahead logging. wal has go.uber.org/zap in its vendor packages. In wal's create function func Create(lg *zap.Logger, dirpath string, metadata []byte) (*WAL, error), I need to pass in zap.Logger.

I have tried to import go.uber.org/zap but go compiler complains "type mismatch" when I pass in zap.Logger.

package main 

import (
"github.com/coreos/etcd/wal"
)

func check(e error) {
    if e != nil {
        panic(e)
    }
}

func main() {

    metadata := []byte{}
    w, err := wal.Create(zap.NewExample(), "/tmp/hello", metadata)

    // err := w.Save(s, ents)


}

How should I use zap.Logger in my project?

It seems like the package github.com/coreos/etcd/wal is not meant to be used outside of the etcd project. If you really need to use it, please, follow the steps below.

  1. Place the following code in the $GOPATH/src/yourpackage/main.go file.

    package main
    
    import (
        "fmt"
    
        "go.etcd.io/etcd/wal"
        "go.uber.org/zap"
    )
    
    func main() {
        metadata := []byte{}
        w, err := wal.Create(zap.NewExample(), "/tmp/hello", metadata)
        fmt.Println(w, err)
    }
    
  2. mkdir $GOPATH/src/yourpackage/vendor

  3. cp -r $GOPATH/src/go.etcd.io $GOPATH/src/yourpackage/vendor/
  4. mv $GOPATH/src/yourpackage/vendor/go.etcd.io/etcd/vendor/go.uber.org $GOPATH/src/yourpackage/vendor/
  5. go build yourpackage