获取所有依赖关系,返回Terratest无法识别的导入路径

问题描述

配置

  • go1.15.2 darwin / 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命令行参数[设置失败]
失败

谷歌搜索发现从测试文件所在的目录运行go get -u ./...应该安装这些软件包

问题

运行go get -u ./...时出现以下错误

package _ / Users / username / github.com / my-org / my-repo / packer / tests:无法识别的导入路径“ _ / Users / username / github.com / my-org / my-repo / packer /测试”:导入路径不是以主机名开头

对于其他上下文,这是我正在使用的目录结构:

~ 
    github.com/my-org/my-repo/
        packer/
            tests/
                my_test.go

这是测试文件,我使用this terratest example作为参考创建了该文件

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,amiID)
    assert.False(t,amiIsPublic)
}

解决方法

暂无找到可以解决该程序问题的有效方法,小编努力寻找整理中!

如果你已经找到好的解决方法,欢迎将解决方案带上本链接一起发送给小编。

小编邮箱:dio#foxmail.com (将#修改为@)

相关问答

Selenium Web驱动程序和Java。元素在(x,y)点处不可单击。其...
Python-如何使用点“。” 访问字典成员?
Java 字符串是不可变的。到底是什么意思?
Java中的“ final”关键字如何工作?(我仍然可以修改对象。...
“loop:”在Java代码中。这是什么,为什么要编译?
java.lang.ClassNotFoundException:sun.jdbc.odbc.JdbcOdbc...