Go Can';不要将ldflags与bee pack命令一起使用
我正在尝试使用ldflags选项编译beego:Go Can';不要将ldflags与bee pack命令一起使用,go,Go,我正在尝试使用ldflags选项编译beego: bee pack -v -ba="-ldflags '-s -w'" 去抱怨吧: go build -o /var/folders/XXX/XXX/T/beePack-4329015000/XXXX -ldflags='-s -w' invalid value "'-s" for flag -ldflags: missing =<value> in <pattern>=<value> 我得到: + go
bee pack -v -ba="-ldflags '-s -w'"
去抱怨吧:
go build -o /var/folders/XXX/XXX/T/beePack-4329015000/XXXX -ldflags='-s -w'
invalid value "'-s" for flag -ldflags: missing =<value> in <pattern>=<value>
我得到:
+ go build -o /var/folders/xxx/xxx/T/beePack-2277518000/xxx -ldflags='-s -w'
invalid value "'-s" for flag -ldflags: missing =<value> in <pattern>=<value>
+go build-o/var/folders/xxx/xxx/T/beePack-2277518000/xxx-ldflags='-s-w'
标志-ldflags:missing=in的无效值“'-s”=
我检查了bee工具的源代码。这应该是一个bug,我会在他们的GitHub回购协议中提出一个问题
以下是相关网站的链接。请看下面的评论
args := []string{"build", "-o", binPath}
if len(buildArgs) > 0 {
//Giulio: Here they split the input arguments using whitespace as delimiter.
//In your case it would become: "-ldflags='-s -w'" => ["-ldflags='-s", "-w'"]
args = append(args, strings.Fields(buildArgs)...)
}
if verbose {
//Giulio: The print is fine, reconstruct the same string with strings.Join
fmt.Fprintf(output, "\t%s%s+ go %s%s%s\n", "\x1b[32m", "\x1b[1m", strings.Join(args, " "), "\x1b[21m", "\x1b[0m")
}
//Giulio: but, here, they use the slice with splitted flags, i.e. ["-ldflags='-s", "-w'"], which is the real problem.
execmd := exec.Command("go", args...)
我检查了bee工具的源代码。这应该是一个bug,我会在他们的GitHub回购协议中提出一个问题 以下是相关网站的链接。请看下面的评论
args := []string{"build", "-o", binPath}
if len(buildArgs) > 0 {
//Giulio: Here they split the input arguments using whitespace as delimiter.
//In your case it would become: "-ldflags='-s -w'" => ["-ldflags='-s", "-w'"]
args = append(args, strings.Fields(buildArgs)...)
}
if verbose {
//Giulio: The print is fine, reconstruct the same string with strings.Join
fmt.Fprintf(output, "\t%s%s+ go %s%s%s\n", "\x1b[32m", "\x1b[1m", strings.Join(args, " "), "\x1b[21m", "\x1b[0m")
}
//Giulio: but, here, they use the slice with splitted flags, i.e. ["-ldflags='-s", "-w'"], which is the real problem.
execmd := exec.Command("go", args...)
您是否尝试过:
bee pack-v-ba=“-ldflags='-s-w'
?@GiulioMicheloni查看我的更新。没有任何变化您尝试过:bee pack-v-ba=“-ldflags='-s-w'
?@GiulioMicheloni查看我的更新。没什么变化