我正在嘗試使用 gRPC 編寫(xiě)一個(gè)服務(wù),當(dāng)我導(dǎo)入 protobuff 文件時(shí),出現(xiàn)錯(cuò)誤。我嘗試刪除 go 路徑中的所有模塊并重新初始化 go 模塊build _/Users/tibinlukose/cart-service/pb: cannot find module for path _/Users/tibinlukose/cart-service/pb代碼package mainimport ( pbcart "../pb/" "log" "fmt" "google.golang.org/grpc" "net")var ( port = 1000;)type CartServiceServer struct {}func main() { log.SetFlags(log.LstdFlags | log.Lshortfile) fmt.Println("Server Starting ..") lis, err := net.Listen("tcp", fmt.Sprintf("localhost:%d", 10000)) if err != nil { log.Fatal("unable to listen on the port") } serverOptions := []grpc.ServerOption{} grpcServer := grpc.NewServer(serverOptions...) srv := &CartServiceServer{} pbcart.RegisterCartServiceServer(grpcServer, srv)}環(huán)境GOCACHE="/Users/tibinlukose/Library/Caches/go-build"GOENV="/Users/tibinlukose/Library/Application Support/go/env"GOPATH="/Users/tibinlukose/go"GOROOT="/usr/local/Cellar/go/1.13.4/libexec"GOTOOLDIR="/usr/local/Cellar/go/1.13.4/libexec/pkg/tool/darwin_amd64"GOMOD="/Users/tibinlukose/cart-service/server/go.mod"倉(cāng)庫(kù)https://github.com/zycon/cart-service
Go 中 protobuf 的相對(duì)導(dǎo)入,找不到模塊路徑
qq_花開(kāi)花謝_0
2023-08-14 15:15:35