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

Inconsistent import names between Docker environments #651

Open
@KenxinKun

Description

@KenxinKun

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

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions