dongzhong1929 2018-08-27 03:04
浏览 654
已采纳

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

I want to remote debug Golang bin file with delve. First, I need to compile the .go file:

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

but the outcome is

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.

How to solve this problem?

go version: 1.10.3 amd64/linux

  • 写回答

1条回答 默认 最新

  • dqwh1219 2018-08-27 06:29
    关注

    How to solve this problem?

    $ 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.
    

    Follow the instructions in the error message.

    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>>
    

    Follow the instructions in the help text precisely.

    The argument list may be preceded by a package pattern and an equal sign.

    For example, for package patterm all: all=.

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

    References:

    Command go: Compile packages and dependencies

    本回答被题主选为最佳回答 , 对您是否有帮助呢?
    评论

报告相同问题?