migrate
migrate copied to clipboard
source/iofs/iofs.go doesn't support go1.17
Describe the Bug Builds don't work when using the file driver using go1.17 due to build constraint in the file.
Steps to Reproduce Steps to reproduce the behavior:
- use a file migration
- attempt to build using go 1.17
- See error
golang-migrate/migrate/v4/source/file/file.go:17:2: undefined: iofs.PartialDriver
Expected Behavior It should build as go1.17 is supported in the rest of the repo (that I can see)
Migrate Version e.g. v4.15.0
Loaded Source Drivers
e.g. file
Obtained by running: migrate -help
Loaded Database Drivers e.g. postgres, postgresql, mysql, sqlite
Go Version e.g. go version go1.17.1 darwin/amd64
See also: https://github.com/golang-migrate/migrate/pull/618#issuecomment-920452496
I'm getting caught by this same error. I'm building in a Docker image and it works on my machine, yet running on GitHub Actions fails.
The only difference is i use docker buildx on GHA but docker build on my machine.
# github.com/golang-migrate/migrate/v4/source/file
../../../../go/pkg/mod/github.com/golang-migrate/migrate/[email protected]/source/file/file.go:17:2: undefined: iofs.PartialDriver
note: module requires Go 1.16
FROM --platform=${BUILDPLATFORM} golang:1.17.0-alpine AS build
ENV CGO_ENABLED=0
ARG TARGETOS
ARG TARGETARCH
WORKDIR /app
RUN apk add --no-cache make
COPY ./ ./
RUN GOOS=${TARGETOS} GOARCH=${TARGETARCH} make build
FROM --platform=${TARGETPLATFORM} alpine
WORKDIR /app
COPY --from=build /app/bin/api.
CMD ["/bin/sh", "-c", "/app/api"]
The comment chain points to https://github.com/golang/go/issues/48397#issuecomment-920150805 but it doesn't work for me even at 14.5.0 on a github ci machine (ubuntu-latest)
../../../../go/pkg/mod/github.com/golang-migrate/migrate/[email protected]/source/file/file.go:17:2: undefined: iofs.PartialDriver
same issue with 4.15.1 Dockerfile
FROM golang:1.17 as build
RUN mkdir /app
WORKDIR /app
ENV GO111MODULE=on
COPY ./go.mod ./
COPY ./go.sum ./
RUN go mod download
github action
jobs:
test:
name: test
runs-on: ubuntu-latest
steps:
- name: Checkout
uses: actions/checkout@v2
- name: Run test
run: make test
error
# github.com/golang-migrate/migrate/v4/source/file
../../../go/pkg/mod/github.com/golang-migrate/migrate/[email protected]/source/file/file.go:17:2: undefined: iofs.PartialDriver
note: module requires Go 1.16
FAIL api/test [build failed]
no issue when I run make test locally
I've actually found out that my golang setup on github CI was faulty [0], and printing the go version yield 1.15. I've been using a dedicated github action now and it works well.
# [0] this didn't work somehow, didn't care to investigate back then
curl -LO https://golang.org/dl/go1.17.3.linux-amd64.tar.gz
sudo rm -rf /usr/local/go && sudo tar -C /usr/local -xzf go1.17.3.linux-amd64.tar.gz
export GOPATH=/usr/local/go
export PATH=$PATH:$GOPATH/bin
export GO111MODULE=on
Sorry I was stupid, I didn't specify go version on Github CI
jobs:
test:
name: test
runs-on: ubuntu-18.04
steps:
- name: Install Go
uses: actions/setup-go@v2
with:
go-version: '^1.17.0'
- name: Check Go version
run: go version
- name: Checkout
uses: actions/checkout@v2
- name: Run test
run: make test
this works now