Skip to content

go-1.19.3 tag starts complaining about missing go.mod file #187

@m90

Description

@m90

I've been using xgo for a while now to build cross-platform binaries for my application. Currently, I'm on techknowlogick/xgo:go-1.19.x.

Starting today, builds would start failing with the following error message:

 > [compiler 10/12] RUN chmod +x ./compile.sh && ./compile.sh && rm ./compile.sh:
#77 0.388 Cross compiling github.com/offen/offen/server/cmd/offen...
#77 0.431 Go modules are enabled but go.mod was not found in the source folder.
#77 0.431 2022/11/24 10:03:14 Failed to cross compile package: exit status 10.

The command from compile.sh looks like this:

  xgo \
    --targets=$TARGETS \
    --tags 'osusergo netgo static_build sqlite_omit_load_extension' \
    --ldflags="-linkmode external -extldflags '$LDFLAGS' -s -w -X github.com/offen/offen/server/config.Revision=$GIT_REVISION" \
    github.com/offen/offen/server/cmd/offen

When this error is raised, there is a go.mod file in github.com/offen/offen/server/go.mod.

I assume this behavior was introduced in the recent go-1.19.3 release as downgrading to go-1.19.2 makes the build pass again.

Am I doing something wrong when building my binaries or does go-1.19.3 contain a regression somehow?

This is how assets are copied into building image:

FROM techknowlogick/xgo:go-1.19.x as compiler

ARG rev
ENV GIT_REVISION=$rev
ARG targets
ENV TARGETS=$targets

COPY ./server /go/src/github.com/offen/offen/server

ENV GOPATH /go
WORKDIR /build

COPY ./build/compile.sh .
RUN chmod +x ./compile.sh && ./compile.sh && rm ./compile.sh

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions