草庐IT

static-compilation

全部标签

regex - 我使用 regexp.Compile (`^123(?:4)` ) 尝试从 "123"获取 "1234abcd"而结果是 "1234"

我正在使用go1.8.3进行编码,我想使用正则表达式包从"1234abcd"获取"123"。当我使用regexp.Compile("^123(?:4)")时,它变成了"1234"。在此编码:https://play.golang.org/p/jB7FmxWz9rpackagemainimport("regexp""fmt")funcmain(){test,err:=regexp.Compile(`^123(?:4)`)iferr!=nil{fmt.Println(err)return}input:="1234|wserw"fmt.Println(test.FindString(inpu

compiler-errors - Go 编译器说 "declared and not used"但它们正在被使用

我有以下函数给我“变量已声明但未使用”错误:typeComparisonstruct{Left[]byteRight[]byteNamestring}funcimg(whttp.ResponseWriter,r*http.Request,cappengine.Context,u*user.User){key:=datastore.NewKey("Comparison",r.FormValue("id"),0,nil)side:=r.FormValue("side")comparison:=new(Comparison)err:=datastore.Get(c,key,compariso

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

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

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

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

Golang 枸杞 : How to serve static content and api at the same time

过去两周我一直在玩Golang,终于可以制作一个真正的应用程序了。它使用NGINX提供的静态HTML文件,API使用GojiWebFramework作为后端。我不使用任何Golang模板,因为一切都是Angular.Js,所以静态可以满足我的需要。我希望可以选择是在生产环境中使用NGINX,还是让Go使用应用程序使用的相同端口(8000)在根目录下提供静态内容。这样开发环境就不需要安装NGINX。因此,尝试像这样向默认多路复用器添加句柄goji.DefaultMux.Handle("/*",serveStatic)funcserveStatic(whttp.ResponseWriter

dynamic - 转到接口(interface) : static vs dynamic binding

Go同时使用动态和静态绑定(bind)。据我了解,如果您需要使用类型断言,那么它是动态的。我想验证我的假设。typeXerinterface{X()}typeXYerinterface{XerY()}typeFoostruct{}func(Foo)X(){println("Foo#X()")}func(Foo)Y(){println("Foo#Y()")}假设:foo:=Foo{}//static:Foo->XYervarxyXYer=foo//static:XYer->XervarxXer=xy//static:Xer->interface{}varemptyinterface{}=

regex - regexp.Compile 和 regexp.CompilePOSIX 有什么区别?

谁能提供一些例子来解释regexp.Compile之间的区别?和regexp.CompilePOSIX?我阅读了文档。但是我无法得到直观的理解。 最佳答案 Perl和POSIX兼容的正则表达式在很大程度上相似,但在某些关键方面有所不同,例如submatching。这个提到here:POSIXdefinesthattoresolvesubmatches,firstchosethematchthatstartsleftmostinthestring.(ThisistraditionalPerlbehaviorbutherethingsd

go - 突然go tool : no such tool "compile"

我已经在我的Ubuntu桌面上安装了go,在我关闭计算机之前它运行良好。现在,当我启动我的机器并继续我的项目工作时,我明白了$gobuildgotool:nosuchtool"compile"gotool:nosuchtool"compile"gotool:nosuchtool"compile"gotool:nosuchtool"compile"gotool:nosuchtool"compile"当我尝试构建一个项目时。我在关机之前做的唯一可能有一些影响的事情是使用安装godocsudoapt-getinstallgolang-doc我通过下载go1.10.1.linux-amd64.