Skip to content

Commit

Permalink
fix: installation of plugins for Go v1.18 and above (#2174)
Browse files Browse the repository at this point in the history
* Run go install after go get to install plugins

This fixes #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](golang/go#44840 (comment)). 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 <ilkergoktugozturk@gmail.com>
  • Loading branch information
dave and ilgooz committed Mar 18, 2022
1 parent f9442e3 commit 565c2f3
Showing 1 changed file with 15 additions and 16 deletions.
31 changes: 15 additions & 16 deletions starport/pkg/cosmosgen/install.go
Original file line number Diff line number Diff line change
Expand Up @@ -12,29 +12,28 @@ 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(
cmdrunner.DefaultStderr(errb),
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())
}

0 comments on commit 565c2f3

Please sign in to comment.