go - Go get all dependencies 返回 Terratest 无法识别的导入路径
问题描述
配置
- go1.15.2 达尔文/amd64
- macOS Catalina v10.15.7
.zshrc
文件
export GOPATH=$HOME/go
export GOROOT=/usr/local/opt/go/libexec
export PATH=$PATH:$GOPATH/bin
export PATH=$PATH:$GOROOT/bin
我正在尝试做的事情
我是 Go 新手,正在尝试使用 Terratest 为 Packer 构建编写测试。
尝试运行时,go test my_test.go
我不断收到错误消息,提示我需要安装丢失的软件包。
../../../../../go/src/github.com/gruntwork-io/terratest/modules/aws/sqs.go:10:2:找不到包“github.com/google /uuid”在以下任何一个中:
/usr/local/opt/go/libexec/src/github.com/google/uuid(来自 $GOROOT)/Users/username/go/src/github.com/google/uuid(来自$GOPATH)。
FAIL 命令行参数 [设置失败]
FAIL
谷歌搜索我发现go get -u ./...
从我的测试文件所在的目录运行应该安装这些包
问题
当我运行时,go get -u ./...
我收到以下错误:
包_/Users/username/github.com/my-org/my-repo/packer/tests:无法识别的导入路径“_/Users/username/github.com/my-org/my-repo/packer/tests”:导入路径不以主机名开头
对于其他上下文,这是我正在使用的目录结构:
~
github.com/my-org/my-repo/
packer/
tests/
my_test.go
这是我使用这个 terratest 示例作为参考创建的测试文件:
package test
import (
"testing"
"github.com/gruntwork-io/terratest/modules/packer"
"github.com/stretchr/testify/assert"
terratest_aws "github.com/gruntwork-io/terratest/modules/aws"
)
func TestMyAmiBuild( t *testing.T) {
awsRegion := "us-east-1"
packerOptions := &packer.Options{
// Path to the Packer template under test
Template: "../template/template.json",
// Variables to pass to Packer build
Vars: map[string]string{
"ami_name": "my-ami"
},
// Only build the AWS AMI
Only: "amazon-ebs",
}
// Build the Packer template
amiID := packer.BuildArtifact(t, packerOptions)
// Clean up the AMI after we're done
defer terratest_aws.DeleteAmiAndAllSnapshots(t, awsRegion, amiID)
// Check if AMI is private
amiIsPublic := terratest_aws.GetAmiPubliclyAccessible(t, awsRegion, amiID)
assert.False(t, amiIsPublic)
}
解决方案
推荐阅读
- php - Silex 匹配 GET 但没有 POST
- git - git clone 后 Unity 项目损坏
- python - 如何在需要对每列进行单独查询的表上设置索引?
- java - 在 Spring JMS 模块中获取 BeanNotOfRequiredTypeException
- c# - NHIbernate:获取由父对象的属性过滤的子对象
- .net - 如何在新/旧 RabbitMQ 队列声明/销毁时得到通知
- smtp - Postfix php 邮件问题“CLIENT: 503 5.5.1 Error: authentication not enabled SMTP ERROR: AUTH command failed”
- python - Matplotlib 图形对齐
- c++ - Qt(C++)关于动态分配QProgressbar的两种不同方式的意外结果
- javascript - Node.JS - 用于 Sharp 的 overlayWith() 函数的 SVG 到图像缓冲区?