进行构建时,“-gcflags标志的值无效” all -N -l”

时间:2018-08-27 03:04:56

标签: go

我想用delve远程调试Golang bin文件。首先,我需要编译.go文件:

go build -gcflags='all -N -l' main.go

但结果是

invalid value "all -N -l" for flag -gcflags: missing =<value> in <pattern>=<value> usage: build [-o output] [-i] [build flags] [packages] Run 'go help build' for details.

如何解决这个问题?

执行版本:1.10.3 amd64 / linux

1 个答案:

答案 0 :(得分:2)

  

如何解决这个问题?

$ go build -gcflags='all -N -l' main.go
invalid value "all -N -l" for flag -gcflags: missing =<value> in <pattern>=<value>
usage: go build [-o output] [-i] [build flags] [packages]
Run 'go help build' for details.

按照错误消息中的说明进行操作。

  

Run 'go help build' for details.

$ go help build

<<SNIP>>

The -asmflags, -gccgoflags, -gcflags, and -ldflags flags accept a
space-separated list of arguments to pass to an underlying tool
during the build. To embed spaces in an element in the list, surround
it with either single or double quotes. The argument list may be
preceded by a package pattern and an equal sign, which restricts
the use of that argument list to the building of packages matching
that pattern (see 'go help packages' for a description of package
patterns). 

<<SNIP>>

严格按照帮助文本中的说明进行操作。

  

参数列表之前可以有一个包装模式和一个等号   签名。

例如,对于软件包patterm allall=

go build -gcflags='all=-N -l' main.go

参考文献:

Command goCompile packages and dependencies