我已经安装了mingw-w64.

gcc --version:
gcc (Homebrew GCC 11.2.0_3) 11.2.0.

g++ --version:
g++ (Homebrew GCC 11.2.0_3) 11.2.0

I also run which gcc:
/opt/homebrew/bin/gcc

然后我用图像golang:latest运行docker compose.还没有错误

up to date, audited 370 packages in 10m

9 packages are looking for funding
  run `npm fund` for details

6 high severity vulnerabilities

To address issues that do not require attention, run:
  npm audit fix

To address all issues (including breaking changes), run:
  npm audit fix --force

Run `npm audit` for details.
Unlinking stale socket /tmp/supervisor.sock
[15:30:39] Using gulpfile /go/src/github.com/projectname/src/api/gulpfile.js
[15:30:39] Starting 'default'...
[15:30:39] Starting 'watch'...

当我保存一个.go file下载所有MOD,错误如下:

 # github.com/projectname/api
 /usr/local/go/pkg/tool/linux_arm64/link: running gcc failed: exit status 1
 collect2: fatal error: cannot find 'ld'
 compilation terminated.

 [15:46:23] 'build-binary' errored after 1.98 s
 [15:46:23] Error in plugin "gulp-shell"
 Message:
     Command `go build` failed with exit code 2

这是我的Dockerfile:

FROM golang:1.17.0-alpine3.14 AS builder
    
RUN apk update && apk add gcc make git libc-dev binutils-gold

# Install dependencies
RUN apk add --update tzdata \
    --no-cache ca-certificates git wget \
    nodejs npm \
    g++ \
    supervisor \
    && update-ca-certificates \
    && npm install -g gulp gulp-shell
RUN npm install -g yarn


COPY ops/api/local/supervisor /etc
ENV PATH $PATH:/go/bin
WORKDIR /go/src/github.com/projectname/src/api

推荐答案

试着判断一下,如果是in this Dockerfile,加上binutils-gold是否允许你使用ld.

RUN apk update && apk add gcc make git libc-dev binutils-gold

(首次出现于nodejs/node issue 4212年)

Go相关问答推荐

Golang ==错误:OCI运行时创建失败:无法启动容器进程:exec:./" bin:stat./" bin:没有这样的文件或目录:未知

消费者在NAT中是如何实现的

golang 的条件储存库

未对GoFr中的所有请求进行跟踪

理解Golang中的IOTA和常量

go-chi: 接受带有反斜杠的 url 路径参数

如何在 `hashicorp / terraform-exec` 中将 `ApplyConfig` 传递给 `tf.Apply()`?

GoLang: gocui 边框 colored颜色

无法使用 gocsv 读取引用字段

仅在工作日运行 cron

查找、解析和验证邮箱地址

如何在 Golang 中使用具有相同名称或特定关键字的行或列重新排列/排序 CSV

Go GCP 同时模拟两个服务帐户

golang jwt.MapClaims 获取用户ID

Terraform 自定义提供程序 - 数据源架构

如何使用带有Electron 表格 ID、Electron 表格名称、表格 ID 和值的 golang 在 googlesheet 中插入数据

Beego - 我需要context.Context而不是 Beego 上下文

如何在程序退出时使用 golang 删除文件?

如果在调用 http.Get(url) 时发生错误,我们是否需要关闭响应对象?

更改单个像素的 colored颜色 - Golang 图像