From 565c2f3f5316d8a70cdbf0706f385644a35ed8a4 Mon Sep 17 00:00:00 2001 From: Dave Brophy Date: Fri, 18 Mar 2022 16:44:14 -0300 Subject: [PATCH] fix: installation of plugins for Go `v1.18` and above (#2174) MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit * Run go install after go get to install plugins This fixes https://github.com/tendermint/starport/issues/1163, but is not ideal... tooling binaries should be installed by running `go install [path]@[version]`, but protoc-gen-gocosmos uses a replace directive in the `go.mod` which is [incompatible with this method](https://github.com/golang/go/issues/44840#issuecomment-792789581). This fixes the problem for now, but adds plugin specific items to the go.mod of the scaffolded project, which shouldn't be there. * Update starport/pkg/cosmosgen/install.go Co-authored-by: İlker G. Öztürk --- starport/pkg/cosmosgen/install.go | 31 +++++++++++++++---------------- 1 file changed, 15 insertions(+), 16 deletions(-) diff --git a/starport/pkg/cosmosgen/install.go b/starport/pkg/cosmosgen/install.go index 6f0a3f2de3..aeb9555b07 100644 --- a/starport/pkg/cosmosgen/install.go +++ b/starport/pkg/cosmosgen/install.go @@ -12,6 +12,19 @@ import ( // InstallDependencies installs protoc dependencies needed by Cosmos ecosystem. func InstallDependencies(ctx context.Context, appPath string) error { + plugins := []string{ + // installs the gocosmos plugin. + "github.com/regen-network/cosmos-proto/protoc-gen-gocosmos", + + // install Go code generation plugin. + "github.com/golang/protobuf/protoc-gen-go", + + // install grpc-gateway plugins. + "github.com/grpc-ecosystem/grpc-gateway/protoc-gen-grpc-gateway", + "github.com/grpc-ecosystem/grpc-gateway/protoc-gen-swagger", + "github.com/grpc-ecosystem/grpc-gateway/v2/protoc-gen-openapiv2", + } + errb := &bytes.Buffer{} err := cmdrunner. New( @@ -19,22 +32,8 @@ func InstallDependencies(ctx context.Context, appPath string) error { cmdrunner.DefaultWorkdir(appPath), ). Run(ctx, - step.New( - step.Exec( - "go", - "get", - // installs the gocosmos plugin. - "github.com/regen-network/cosmos-proto/protoc-gen-gocosmos", - - // install Go code generation plugin. - "github.com/golang/protobuf/protoc-gen-go", - - // install grpc-gateway plugins. - "github.com/grpc-ecosystem/grpc-gateway/protoc-gen-grpc-gateway", - "github.com/grpc-ecosystem/grpc-gateway/protoc-gen-swagger", - "github.com/grpc-ecosystem/grpc-gateway/v2/protoc-gen-openapiv2", - ), - ), + step.New(step.Exec("go", append([]string{"get"}, plugins...)...)), + step.New(step.Exec("go", append([]string{"install"}, plugins...)...)), ) return errors.Wrap(err, errb.String()) }