vektra / mockery

A mock code autogenerator for Go
https://vektra.github.io/mockery/
BSD 3-Clause "New" or "Revised" License
6k stars 405 forks source link

Error 'must match format 1.23' while mock generation in docker #713

Closed evsamsonov closed 11 months ago

evsamsonov commented 1 year ago

Description

Error invalid go version '1.21.0': must match format 1.23 while mock generation in docker

Mockery Version

v2.34.0

Golang Version

Go 1.21

Installation Method

Steps to Reproduce

  1. Use go version 1.21
  2. Create go mod go mod init test.com
  3. Create file test.go with interface
    
    package main

type Test interface { }

4. Run generate mock in docker
  `docker run --rm vektra/mockery --name Test --inpackage --case snake`

### Expected Behavior

Successful mock generation

### Actual Behavior

25 Sep 23 09:04 UTC INF couldn't read any config file version=v2.34.0 25 Sep 23 09:04 UTC INF Starting mockery dry-run=false version=v2.34.0 25 Sep 23 09:04 UTC INF Using config: dry-run=false version=v2.34.0 25 Sep 23 09:04 UTC WRN DEPRECATION: use of the packages config will be the only way to generate mocks in v3. Please migrate your config to use the packages feature. dry-run=false migration=https://vektra.github.io/mockery/v2.34/migrating_to_packages/ url=https://vektra.github.io/mockery/v2.34/features/#packages-configuration version=v2.34.0 25 Sep 23 09:04 UTC INF Walking dry-run=false version=v2.34.0 unable to find interface 25 Sep 23 09:04 UTC ERR Error parsing file error="err: exit status 1: stderr: go: errors parsing go.mod:\n/app/go.mod:3: invalid go version '1.21.1': must match format 1.23\n" dry-run=false version=v2.34.0 25 Sep 23 09:04 UTC ERR Unable to find 'Test' in any go files under this path dry-run=false version=v2.34.0

LandonTClipp commented 1 year ago

This likely isn't a mockery issue. Please double check your go.mod file features a valid go version.

https://go.dev/blog/publishing-go-modules

evsamsonov commented 1 year ago

@LandonTClipp It's issue mockery in docker image. Did you try to reproduce it? go.mod have been generated by command go mod init and it is correct:

module example.com

go 1.21.1
LandonTClipp commented 1 year ago

Apologies, you are right. It seems the Dockerfile is pulling in go 1.20 but your go.mod requires at least 1.21.1. Should be as simple as updating the Dockerfile if you want to send in a PR for that.

LandonTClipp commented 12 months ago

@evsamsonov did the new update fix your problem?

evsamsonov commented 11 months ago

Yes, thanks