假设我的整个存储库都在github.com/ my _repo和本地文件系统中。源文件导入"github.com/my_repo/pkg“。当我运行go run时,go是获取远程文件并将其导入,还是首选本地文件?
如果有一个通用的远程存储库(不是github/launchpad/等),go会更喜欢获取远程存储库还是更喜欢使用本地文件?
我已经编写了一个与数据库(mongodb)通信的Go HTTP服务器应用程序。在服务器运行的情况下,执行CRUD操作,服务器对mongo数据库执行插入、检索、删除等操作。 我的下一步是为我的应用程序创建一个docker镜像,这样我就可以将其推送到docker hub。为了创建映像,我将应用程序的Dockerfile定义为 # Dockerfile References: https://docs.docker.com/engine/reference/builder/
# Start from the latest golang base image
FROM golang:latest
我刚刚开始与戈朗,并试图建立杜松子酒与码头-撰写。这是我的Dockerfile
FROM golang:1.18
WORKDIR /docker-go
# pre-copy/cache go.mod for pre-downloading dependencies and only redownloading them in subsequent builds if they change
# COPY all file go ./
COPY ./app/main.go ./
COPY . /docker-go
# To initialize a project with go modu
问题
go mod tidy能否为本地git存储库生成有意义的提交版本?
背景
我最近注意到,当从本地目录运行时,go mod tidy使用Golang的“零时间”值生成一个版本,如下所示:
require example.com/db_api v0.0.0-00010101000000-000000000000
对于没有提交和版本标记的本地存储库来说,这似乎是合理的..。但是,当我试图将提交和标记添加到本地目录时,我注意到go mod tidy仍然依赖于零时间戳作为require语句的标识符。
示例
让我们从依赖关系开始:
➜ db_api git:(heads/v1.0.0) tree
推到eu.gcr.io/my-project-name/my-image:tag,我得到:
unauthorized: You don't have the needed permissions to perform this operation, and you may have invalid credentials. To authenticate your request, follow the steps in: https://cloud.google.com/container-registry/docs/advanced-authentication
我已经安装了gcl
我正在尝试运行私有docker注册表。我克隆了git存储库并运行它。
然后,我从docker上拉出了基本图像,并按照上的指示对其进行了标记。
sudo docker pull base
sudo docker tag b750fe79269d localhost:5000/base
我将图像推送到本地存储库,下面是我分别从docker和docker注册表获得的内容。
sudo docker push localhost:5000/base
The push refers to a repository [localhost:5000/base] (len: 1)
Processing che