Я проверил исходный код инструмента пчелы. Это должна быть ошибка, и я бы открыл проблему в их репозитории 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...)