Skip to content

Conversation

@FlowingSPDG
Copy link
Contributor

golang/mock がメンテナンス停止したため、uber.go/mock に変更しました。
既にgo.mod には入っていたため、Makefileの修正とgo mod tidy の実行後となります。
よろしくお願いします!

bootstrap:
mkdir -p bin
GOBIN=$(PWD)/bin go install github.com/golang/mock/mockgen@latest
GOBIN=$(PWD)/bin go install go.uber.org/mock/mockgen@latest
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

既にgolang/mockgo install している人は、go generateした際にgolang/mock 側が使われる可能性があるので、そこまで対策する場合

//go:generate mockgen -source $GOFILE -destination mock/mock_history_gen/mock_history_gen.go

//go:generate go run go.uber.org/mock/mockgen@latest -source $GOFILE -destination mock/mock_history_gen/mock_history_gen.go

とするのも手かもしれません!

Copy link
Member

@54m 54m Aug 7, 2024

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

そうですね!
もしくは生成時のオプションで、golang/mock or uber/mockのパスを指定できるようにしてもいいかもですね
GOBIN指定して./bin/などに入れている人もいるかもしれないので

uberの方強制でも良さそうですね
ファイルが大量にあることもあるので、毎回 go run させるのもな...と思ったりしてます!

Copy link
Contributor Author

@FlowingSPDG FlowingSPDG Aug 7, 2024

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

そういえば、 mockgen のパス指定オプションは存在しますね 🤔 → 使われていない...?
https://github.com/go-generalize/volcago/blob/master/generator/generator.go#L57-L64
なんとかGOBIN を指定することができれば、uberのものを矯正することも出来そうなので少し試してみます!

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

あ...すみません、その存在を忘れてました😅

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

お、折角であればこのPRでそのまま作業してしまおうかと思いますがいかがでしょう?
吐き出されるコードの

//go:generate mockgen -source $GOFILE -destination mock/mock_history_gen/mock_history_gen.go

mockgen の部分をGenerateOption.MockGenPath に置き換える形で良いでしょうかね?
(ただ、その場合、uber/mock 対応とはまた別の趣旨になってしまいますね... 🤔 )

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

大丈夫です!
よろしくお願いします🙏

@FlowingSPDG FlowingSPDG marked this pull request as ready for review August 6, 2024 17:25
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Gomockの乗り換え

2 participants