草庐IT

compiler-flags

全部标签

go - 使用 go-flags 命令的全局参数

我正在使用这个库https://github.com/jessevdk/go-flags我的应用的命令可能是这样的:ex列表事件所以我有我的包装命令typeExCommandstruct{Listlist.ListCommand`command:"list"description:"listevents"subcommands-optional:"true"`}列表命令typeListCommandstruct{ExCommandExCommand`command:"events"description:"listevents"`Configstring`short:"c"long:"

apache - 通过 'compiling on the fly' 从源代码在 Apache 下运行一个 .go 文件

我可以使用以下代码通过Apache将Go应用程序作为网站运行。hello.go:packagemainimport("os")funcmain(){os.Stdout.WriteString("Content-Type:text/html;charset=UTF-8\n\n")os.Stdout.WriteString("Hello!\n")}.htaccess:AddHandlercgi-script.exe我使用gobuildhello.go编译应用程序并转到http://localhost/hello.exe按预期工作。但现在我必须在对源代码进行每次更改后重新编译。访问http:

compiler-errors - Go 中奇怪的编译器错误

当我运行以下代码(它应该反转字符串的内容)时,我从编译器中得到了奇怪的错误。packagemainimport"fmt"funcmain(){argString:="Iamastring"arrayPointer:=len(argString)outputString:="string"forarrayPointer>=0;arrayPointer--{outputString:=fmt.Sprintf("%s%s",outputString,argString[arrayPointer])}}它抛出以下错误:prog.go:9:syntaxerror:missing{afterfor

go - log.Flags() 应该与 write 共享相同的 sync.Mutex 吗?

我有以下代码:packagemainimport("log""os")typeLogFilterstruct{}func(t*LogFilter)Write(p[]byte)(int,error){_=log.Flags()returnos.Stderr.Write(p)}funcmain(){log.SetOutput(&LogFilter{})log.Println("Hello,playground")}哪些死锁是因为http://golang.org/src/pkg/log/log.go第135行将锁定推迟到写入之后。在本文中,我正在调用试图获取锁的Flags。是否有任何理由认

go - 使用 go-flags 理解子命令

我正在构建一个CLI工具来开始学习一些Go。我找到了这个流行的包,我想将它用于一些这样的命令:http://godoc.org/github.com/jessevdk/go-flags#Grouphttps://github.com/jessevdk/go-flagsexlisttodosexlisttodos--completedexlisteventsexlisttodoseventsexauthenticate我的理解是ex将是我的主要命令。list和authenticate是子命令。但在这种情况下,todos和events是什么?--completed会是什么。--comple

compiler-errors - gccgo 不知道 -fgo-relative-import-path

我尝试在我的机器上用gccgo编译一些代码:$exportLANG=C$goget-dgithub.com/fuzxxl/ppm$cd$GOPATH/src/github.com/fuzxxl/ppm$gobuild-compilergccgccgo:error:unrecognizedcommandlineoption'-fgo-relative-import-path=_/home/fuz/src/go/src/github.com/fuzxxl/ppm'这些是我机器上的工具:$goversiongoversiondevel+dda87c8bcba1WedApr1713:25:28

戈朗 : How can I use pflag with other packages that use flag?

如何在使用pflag的同时使用其他使用flag的包?其中一些包为flag包定义了标志(例如在它们的init函数中)-并且需要调用flag.Parse()。使用pflag包定义标志,需要调用pflag.Parse()。当参数混合时,对flag.Parse()和pflag.Parse()的调用之一将失败。如何将pflag与其他使用标志的软件包一起使用? 最佳答案 我找到了两种方法。一个带有pflags的AddGoFlags()。浏览器。f:=pflag.NewFlagSet("goFlags",pflag.ExitOnError)f.A

go - 如何引用go-flag IsSet,需要功能代码示例

Go的新手,有一个基本的概念问题(我认为)...尝试使用github.com/jessevdk/go-flags并使其大部分正常工作。--help和诸如此类的东西工作正常,正在传递标志等。我需要了解选项是通过标志设置的,还是通过使用提供的默认值的go-flags解析器设置的。看起来go-flags有一个“IsSet”函数,但我不知道如何引用它。假设:varoptsstruct{Portint`short:"p"long:"Port"description:"IPport"default:"1111"}_,err:=flags.Parse(&opts)我可以通过“opts.Port”引用

Golang boolean flag 解析限制

有人可以详细说明官方golang文档中关于bool标志的cmd语法的解释吗。Oneortwominussignsmaybeused;theyareequivalent.Thelastformisnotpermittedforbooleanflagsbecausethemeaningofthecommandcmd-x*willchangeifthereisafilecalled0,false,etc.Youmustusethe-flag=falseformtoturnoffabooleanflag.我不明白。你能解释一下或举个例子吗? 最佳答案

compiler-construction - 在 Windows 中编译 Go 文件?

我正在尝试学习Go并安装了GoMinGW但我无法找到如何在任何地方实际编译.go文件。这是直接从Windows支持的Gowiki链接的程序,但所有教程都在谈论使用6g和gccgo等进行编译,但这些都不能在我的Windows机器上运行。 最佳答案 我很笨,链接的文件是32位的,我使用“6g”进行编译,因为我的系统是64位的。"8g"可以编译。“8gmyfile.go”"8lmyfile.8"“我的文件.out”努力让它运行。 关于compiler-construction-在Windows