简体   繁体   English

Go 项目和依赖项

[英]Go project and dependencies

I have the following project structure我有以下项目结构

.
├── README.md
├── protos
│   ├── my-proto-output.pb.go
│   └── my-proto.proto
└── grpc-backend
    ├── client
    │   └── client.go
    ├── go.mod
    ├── go.sum
    ├── main.go
    └── a-submodule

Inside grpc-backend/main.go I have:在 grpc-backend/main.go 里面我有:

package main

import (
  pb "github.com/my-user/my-repo/protos"
  "google.golang.org/api/option"
  "google.golang.org/grpc"
)

Inside go.mod I have在 go.mod 里面我有

go 1.13

require (
  google.golang.org/api v0.14.0
  google.golang.org/grpc v1.21.1
)

module github.com/my-user/my-repo/grpc-backend

However, when I run cd grpc-backend && go build I get但是,当我运行cd grpc-backend && go build我得到

go: finding github.com/my-user/my-repo latest
go: finding github.com/my-user/my-repo/protos latest
go: downloading github.com/my-user/my-repo v0.0.0-20200103231607-5a754c449f99
verifying github.com/my-user/my-repo@v0.0.0-20200103231607-5a754c449f99: github.com/my-user/my-repo@v0.0.0-20200103231607-5a754c449f99: reading https://sum.golang.org/lookup/github.com/my-user/my-repo@v0.0.0-20200103231607-5a754c449f99: 410 Gone

I don't have any tags like that, I'm in a private repo only commiting to master at the moment.我没有任何这样的标签,我在一个私人仓库中,目前只承诺掌握。 Furthermore, proto's are in this same git repo under the package myrepo .此外,proto 位于myrepo包下的同一个 git repo 中。

Questions:问题:

Did I organize this incorrectly?我是否错误地组织了这个?
Where did that version come from?那个版本是哪里来的? It's not in go.sum它不在 go.sum 中

Your module does not include the protos package, and thus, the generated grpc source.您的模块不包含protos包,因此不包含生成的 grpc 源。 Move your go.mod one level up, and change the module name to github.com/my-user/my-repo so the module includes all packages.将您的go.mod移一级,并将模块名称更改为github.com/my-user/my-repo以便该模块包含所有包。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM