草庐IT

EasyExcel导入

全部标签

go - 如何导入自己的包?

看完https://golang.org/doc/code.html,并查看有关该主题的几个StackOverflow问题,我仍然无法构建包含多个文件的程序。我的GOPATH是:C:/go_dev/,我的目录结构是:go_dev/src/github.com/aurelienCastel/crashTest/main.goparser/parser.goma​​in.go:packagemainimport"github.com/aurelienCastel/crashTest/parser"funcmain(){info:=parser.get_info_from("file.go"

go - 使用 Golang 导出导入

不确定这对Golang来说是否不可能。使用Node.js,我会这样做:import*aspersonfrom'./person';export{person};使用Golang我有models.go:packagemodelsimport("huru/models/person")是否可以从这个models.go文件导出person,在person命名空间中,例如TypeScript/node.js? 最佳答案 [I]sitpossibletoexportpersonfromthismodels.gofile,inapersonna

Go 子包函数未正确导入

尝试着手研究Golang中的包。这是我的工作空间/bin/pkg/src/github.com/esbenp/testrepo/subpackagesomefuncs.gomain.goma​​in.gopackagemainimport"github.com/esbenp/testrepo/subpackage"funcmain(){Somefunc()}somefuncs.gopackagesubpackageimport"fmt"funcSomefunc(){fmt.Printf("yo")}我的印象是,由于Somefunc以大写字母开头,因此它会被导出以用于导入它的其他文件。我

go - 是否可以从模块导入 ~/go/src/中的本地包?

关闭。这个问题是notreproducibleorwascausedbytypos.它目前不接受答案。这个问题是由于错别字或无法再重现的问题引起的。虽然类似的问题可能是on-topic在这里,这个问题的解决方式不太可能帮助future的读者。关闭3年前。Improvethisquestion我使用的是go模块,文件结构是这样的:~/some_path/goapp/go.mod~/some_path/goapp/go.sum~/some_path/goapp/main.go~/go/src/fakedomain.com/fakeuser/foo/foo.go在main.go中,我尝试做i

go - 如何在 Go 源代码目录中列出导入的模块

是否有工具或最简单的方法来列出go源代码目录中的所有导入包?例如:$golist_importsa_directory/github.com/bla/blagithub.com/foo/barLOCAL/module/path 最佳答案 啊找到了way..golist-f'{{join.Deps"\n"}}'|xargsgolist-f'{{ifnot.Standard}}{{.ImportPath}}{{end}}'|sort|uniq 关于go-如何在Go源代码目录中列出导入的模块,

go - 如何更改导入文件?

我在golang中有以下功能:import("github.com/aws/aws-sdk-go/service/iam""github.com/aws/aws-sdk-go/aws/session""fmt")funcNewIAM()*SphinxIAM{//awsConfig:=aws.NewConfig()sess,err:=session.NewSession()iferr!=nil{fmt.Println("Failedtocreatesession,",err)returnnil}session:=&SphinxIAM{iam:iam.New(sess)}returnses

Go导入返回 "unused import"

我是goLang的新手。我正在尝试从intellij构建一个项目,该项目使用git库中的一个包:import("github.com/aerospike/aerospike-client-go")但我得到:“未使用的导入”我已经将我的gopath设置为\users\myuser\go并将其添加到intelij设置中,但我现在unusedimport并且项目无法识别第3方对象。我应该将模块导入我的解决方案吗?我看到它存在于文件系统中:\users\myuser\src\github.com\aerospike\aerospike-client-go你能帮帮我吗?谢谢

postgresql - 非标准导入 github.com/lib/pq"in statdard package

这个问题在这里已经有了答案:golangwhatisimportsideeffect(1个回答)Whatdoesanunderscoreinfrontofanimportstatementmean?(5个答案)Importsideeffects(1个回答)关闭4年前。我一直遇到这个问题,我不明白为什么封装模型import("database/sql""fmt"_"github.com/lib/pq")const(host="localhost"port=5432user="postgres"password="postgres"dbname="postgres")vardb*sql.D

go - 单元测试不覆盖本地导入包

我是golang的新手,想了解如何让这个场景发挥作用?这是我的结构GOPATH设置为/Users/xyz/project/Users/xyz/project/src/main.go//importcalculatorandcallSUMwithtwointegeres/Users/xyz/project/src/main_test.go//testfunction/Users/xyz/project/src/calculator/sum.go//SUMfunction(addtwointegers)我有一个主要的go文件,它导入“计算器”,这是一个本地包。当我运行时gotest-cov

go - 在 IntelliJ 中,即使启用了 go 模块集成,导入也不会加载

当使用带有Go插件的IntelliJIDEA或GoLand并使用Go1.11或更新版本时,您可以通过转到Preferences->Languages&Frameworks->Go->GoModules(vgo)并选中复选框'启用Go模块(vgo)集成”。当你有一个由gomodinit正确初始化的项目,因此有一个go.mod和go.sum文件,当使用gobuild从命令行构建时或通过按绿色播放图标从IntelliJ构建时,它将下载依赖项。但是,远程依赖项的导入语句可能仍然是红色的,即使它们似乎已经下载并出现在go.mod文件中。奇怪的是,go项目实际上将从命令行运行,而不是从Intell