Skip to content
This repository has been archived by the owner on Jun 27, 2023. It is now read-only.

Inconsistent import names between Docker environments #651

Open
KenxinKun opened this issue Jun 3, 2022 · 0 comments
Open

Inconsistent import names between Docker environments #651

KenxinKun opened this issue Jun 3, 2022 · 0 comments

Comments

@KenxinKun
Copy link

KenxinKun commented Jun 3, 2022

Actual behavior

We have a Docker image running mockgen 1.6.0 that we use both as a "CLI tool" locally and inside our CI/CD pipelines. When running the same command both in Gitlab CI and my Mac M1 (arm64) the import paths differ. For example:

If running in Gitlab CI's Docker or directly outside Docker on my Mac M1 I get the import named with the "package name":

api "http://gitlab.com/[...]/goclient"

Instead if I run the same Docker image on my Mac M1, I get the import names after the "directory name":
goclient "http://gitlab.com/[...]/goclient"

Expected behavior

The imports should be named the same in all environments (no preference on which).

To Reproduce

Minimal Dockerfile used:

ARG GO_VERSION=1.17.6
ARG GO_MOCKGEN_VERSION=v1.6.0


FROM golang:${GO_VERSION}
RUN go install github.com/golang/mock/mockgen@${GO_MOCKGEN_VERSION}

# Run version checks
RUN go version; \
    mockgen --version

WORKDIR /app

Minimal bash script we use:

#!/bin/bash
set -e

FILES=$(find ./gen/goclient -name '*.go')
mkdir -p gen/go_mock

for f in $FILES; do
  FILE=$(echo "$f" | sed "s/\//_/g" | sed "s/._gen_go//g")
  # echo "$f $FILE"
	if grep -q "interface {"'$' $f; then 
    mockgen -package mockapi -source $f -destination "gen/go_mock/$FILE"
	fi
done

Additional Information

  • gomock mode (reflect or source): source
  • gomock version or git ref: v1.6.0
  • golang version: 1.17.6

Triage Notes for the Maintainers

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Projects
None yet
Development

No branches or pull requests

2 participants