草庐IT

module-init-tools

全部标签

mysql - global var out out init.go in revel

(编辑以修复大写和添加上下文)在revel的init.go中,我有一个全局变量:DB。packageappimport("database/sql""fmt"_"github.com/go-sql-driver/mysql""github.com/revel/revel")varDB*sql.DBfuncInitDB(){connstring:=fmt.Sprintf("revel:revel@tcp(localhost:3336)/revel")varerrerrorDB,err=sql.Open("mysql",connstring)iferr!=nil{revel.INFO.Pr

docker - 错误 : hyperledger/fabric:make gotools: unrecognized import path "golang.org/x/tools/go/gcexportdata"

当makepeer时,它无法访问build/docker/gotools/bin/protoc-gen-go,所以我makegotools,但是失败了,这是日志:mkdir-pbuild/bincdgotools&&makeinstallBINDIR=/root/gocode/binmake[1]:Enteringdirectory'/root/gocode/src/github.com/hyperledger/fabric/gotools'make[2]:Enteringdirectory'/root/gocode/src/github.com/hyperledger/fabric/

testing - 在 init 函数中使用相对路径在测试中找不到

在单元测试无法找到的init函数中使用相对路径时,我遇到了一个烦人的问题。假设我有一个结构如下的项目:.├──conf│  └──blacklist├──filter│  ├──filter.go│  └──filter_test.go并且在filter.go的init函数中,我尝试使用相对路径conf/blacklist加载黑名单,避免加载它多次。由于默认工作目录恰好是项目根目录,因此它适用于编译后的二进制文件。然而filter_test.go会panicpanic:openconf/blacklist:nosuchfileordirectory,因为gotest总是使用包目录作为工

Go Modules - 目录和包的命名约定

我明白了GoModules仍然是一个实验性的选择加入功能,也许正因为如此,我找不到关于如何命名目录和package的明确指导。在这些PackagenamesinGoBlog发布和PackagenameinEffectiveGo,他们说目录应该与包名称相匹配——但我不确定GoModules是否会遵循相同的模式。如果我想在packagebusiness中将我的业务逻辑与许多文件捆绑在一起,创建子目录validators/并保持相同的包名称package是否合理业务?someDir├──business│  ├──businessA.go//packagebusiness│  ├──busi

go - standard_init_linux.go :207: exec user process caused "no such file or directory" while trying to statically link c libs

我无法在go中对用c编写的实用程序进行docker化和使用。我已经在没有docker的情况下在本地运行了这个程序并且它有效我尝试像这样使用gccgogobuild-compilergccgo-gccgoflags-static-libgo但我得到了同样的错误调用C函数的序言如下所示:/*#cgoamd64x86LDFLAGS:-L.-lsomelib-lsomeotherlib#include#include#include"someheader.h"*/我的docker文件如下所示:FROMgolang:1.12ASbuildWORKDIR/go/src/appCOPY..ENVGO

使用提交哈希时 Go Modules "unknown revision"错误

我需要拉this提交到我的go项目中。我已经尝试了多个版本的go.mod:...require(github.com/libp2p/go-libp2p-core@v0.0.7-0.20190626134135-aca080dccfc2//and...github.com/libp2p/go-libp2p-corev0.0.0-20190626-aca080dccfc2c9933df66baafe6cf9cc4f429825)...两者在运行$gobuild时都会导致错误:$gobuildgo:findinggithub.com/libp2p/go-libp2p-corev0.0.0-2

python - Google App Engine : ImportError: No module named _md5 的 Go 教程

我正在尝试使用Go语言为Google应用引擎运行helloworld教程。GAESDKforgo基于我安装的python2.5。然后我必须安装openssl,但现在当我尝试在SDK上运行示例应用程序时,出现以下错误:ImportError:Nomodulenamed_md5我什至尝试了一个简单的importmd5&importhashlib从python解释器界面,我仍然得到同样的错误>>>importhashlibTraceback(mostrecentcalllast):File"",line1,inFile"/usr/local/lib/python2.5/hashlib.py"

Golang : After installed revel command tool, 无法正常工作

这里我按照revelFW文档安装成功。但是尝试在Gitbash和cmd中使用revel命令,它不起作用请任何人对此提出一些建议... 最佳答案 运行:去获取github.com/revel/revel运行:gogetgithub.com/revel/cmd/revel现在应该可以从任何地方获得revel。如果没有,请确保您设置了$GOPATH/bin。附言如果在安装github.com/revel/cmd/revel时遇到问题,请尝试完全删除github.com/revel,然后重新安装这两个包。

xml - Win7/64位 : Notepad++ XML Tools Plugin does not load

我在Windows764位机器上使用Notepad++时遇到问题。我已经下载了XML工具插件,但无法运行它。我从64位文件夹下载了.7z扩展:2013年5月28日14:22669KBiconv-1.14-win32-x86_64.7z2013年5月28日14:283.4MBlibxml-2.9.1-win32-x86_64.7z2013年5月28日14:551.0MBlibxslt-1.1.28-win32-x86_64.7z2013年5月28日14:5558KBmingwrt-4.8.0-win32-x86_64.7z29/5/201313:382.3MBopenssl-1.0.1e

java - 无法读取架构文档 'http://www.springframework.org/schema/tool/spring-tool-4.1.xsd'

当加载我的应用程序spring上下文时,我收到以下错误(仅在Linux机器上,在Windows上似乎以某种方式工作):Failedtoreadschemadocument'http://www.springframework.org/schema/tool/spring-tool-4.1.xsd',because1)couldnotfindthedocument;2)thedocumentcouldnotberead;3)therootelementofthedocumentisnotxsd:schema.堆栈跟踪如下:org.springframework.beans.factory