草庐IT

run_func

全部标签

go - 使用 exec.Cmd.Run() 运行命令时如何获取所有输出行?

我正在使用glide管理对我的项目的依赖。我创建了一个脚本,为我运行gotest$(glidenovendor)(测试所有目录,不包括vendor/目录)。虽然它有效,但运行命令的输出不会超出第一行:okmy/project/scripts0.005s这是运行它的脚本部分://Getthepathstotest(excludingthe"vendor/"directory)cmd:=exec.Command("glide","novendor")varoutbytes.Buffercmd.Stdout=&outerr=cmd.Run()iferr!=nil{log.Fatal("Cou

go - 从另一个文件访问在 main func 中创建的运行时配置实例

我有一个应用程序其他部分需要的运行时配置实例,但它只能在main()中创建。理想情况下,我想避免使用全局变量。//main.gotypeRuntimeConfigstruct{db*DatabaseInstanceapp_namestring...etc...}funcmain(){dbInstance=ConnectToDB(...args)//returns*DatabaseInstanceruntimeConfig:=*Config{dbInstance,"Myapp",...etc...}}//elsewhere.gofuncSomeUtilityFuncThatNeedsRu

go - "go run"使用 sublime text 3 进入无限循环

我正在尝试在sublimetext3中运行go代码。packagemainimport("fmt")funcmain(){fmt.Println("Hello,playground")}但是,当我进入Tools->Build下时,我看到程序进入了无限循环。GoSublimer17.03.05-19o:type`help`forhelpandcommanddocumentation[`gorunmain.go`⌛][~/Documents/SublimeWorkspace/]#请让我知道我在这里可能遗漏了什么。 最佳答案 打开subl

linux - 最小起订量 : running "moq": exec: "moq": executable file not found in $PATH

在尝试moq框架的示例时,当我输入“gogenerate”时出现以下异常:example.go:5:running"moq":exec:"moq":executablefilenotfoundin$PATH我该怎么办?我正在使用Kubuntu16.04PS:我试过了exportPATH=$PATH:/home/[...]/go/src/github.com/matryer/moq没有成功 最佳答案 @sprabhakaran得到了正确的答案。我只需要将go二进制文件夹添加到PATH全局变量:exportPATH=$PATH:/hom

go - 如何使 func main() 中设置的数据库实例对其他包可用?

我正在编写我的第一个goweb应用程序,我有以下结构:.├──main.go├──model│├──model.go│└──book.go├──route│└──route.go└──view└──view.go/main.go是我的ma​​in()所在的位置。在该文件中,我还定义了一个变量Env,我将在其中保存我的数据库实例(至少这是计划)。在/main.go我做import"project/view"typeEnvstruct{dbmodels.Collection}//restofthecodefuncmain(){db,err:=models.NewDB()//etcMyEnv

go - 如何使用类型 func(*dialOptions)

我正在尝试使用GoLanggrpc库来制作拨号盘。GRPC.dial有一个像这样的方法签名:funcDial(targetstring,opts...DialOption)(*ClientConn,error)DialOption是这样的类型:DialOptionsfunc(*dialOptions)dialOptions本身是一个带有其他参数的结构,但我想在transport.ConnectOptions中传递userAgent字符串,这是另一个结构:typedialOptionsstruct{unaryIntUnaryClientInterceptorstreamIntStream

go - 以太坊简单存储 : get() func always returns zero?

https://github.com/ethereum/go-ethereum/wiki/Native-DApps:-Go-bindings-to-Ethereum-contractshttps://decentralize.today/introducing-perigord-golang-tools-for-ethereum-dapp-development-60556c2d9fd简单存储.sol:pragmasolidity^0.4.4;contractSimpleStorage{uintstoredData;functionset(uintx)public{storedData

google-app-engine - 戈朗 : Audio to FLAC conversion without running a executable

我正在尝试制作一个从存储中获取文件并将任意音频文件转换为FLAC的GoogleAppEngine。但是,AppEngine不允许运行可执行文件。我当前的代码看起来像这样:cmd:=exec.CommandContext(ctx,`./ffmpeg`,`-i`,`pipe:0`,`pipe:1`,`-ac`,`1`,`-c:a`,`flac`,`-f`,`flac`)cmd.Stdin=rccmd.Stdout=wcvarerrOutputbytes.Buffercmd.Stderr=&errOutputerr=cmd.Run()fmt.Printf("Runningffmpeg:%v.

html - zserge/lorca HTML 提交到 go func

github.com/zserge/lorca库允许您通过chrome的开发协议(protocol)将gofuncs绑定(bind)到javascript。有了这个,您可以将参数从浏览器传递到gofunc。由于开发需要,我正在尝试将HTML直接提交到gofunc,而不是使用嵌入式http服务器。(请不要跑题问为什么不使用服务器。)这是我可以做的一个例子:varinputformstring=``funcmain(){ui,err:=lorca.New("data:text/html,"+url.PathEscape(inputform),"",480,320)ui.Bind("gola

转到/pkg/工具/linux_amd64/链接 : running gcc failed: exit status 1/usr/bin/ld: cannot find -lgdal

我正在尝试在我的源代码上运行gobuild。go/pkg/tool/linux_amd64/link:runninggccfailed:exitstatus1/usr/bin/ld:cannotfind-lgdalcollect2:error:ldreturned1exitstatus我的LD_LIBRARY_PATH变量包含/home/fzd/project/lib64,libgdal.so文件目录的路径。我的PKG_CONFIG_PATH包含指向具有以下内容的.pc文件目录的路径:prefix=/home/fzd/projectexec_prefix=${prefix}libdir