From 811dc071aae355775131d3e6f9325a076995aca2 Mon Sep 17 00:00:00 2001 From: Emmanuel T Odeke Date: Tue, 19 Dec 2017 11:29:59 -0700 Subject: [PATCH] protoc: "//nolint: gas" directive after pb generation (#164) * protoc: "//nolint: gas" directive after pb generation Fixes #138 Since we can't add package directives through the protoc compiler, yet we need to "//nolint: gas" the Go generated protobuf file, added a script whose purpose is to go find the "package (\w+)$" declaration after go fmt was run by protoc. The competing solutions were more complex and can be examined by visiting https://github.com/tendermint/abci/issues/138#issuecomment-352226217 * simplify script * rewrite script to work on Mac --- Makefile | 3 +++ types/types.pb.go | 1 + 2 files changed, 4 insertions(+) diff --git a/Makefile b/Makefile index 7176ab101..9324570fd 100644 --- a/Makefile +++ b/Makefile @@ -28,6 +28,9 @@ protoc: ## ldconfig (may require sudo) ## https://stackoverflow.com/a/25518702 protoc $(INCLUDE) --gogo_out=plugins=grpc:. --lint_out=. types/*.proto + @echo "--> adding nolint declarations to protobuf generated files" + @awk '/package types/ { print "//nolint: gas"; print; next }1' types/types.pb.go > types/types.pb.go.new + @mv types/types.pb.go.new types/types.pb.go install: @ go install ./cmd/... diff --git a/types/types.pb.go b/types/types.pb.go index 69777d6d5..e75496650 100644 --- a/types/types.pb.go +++ b/types/types.pb.go @@ -40,6 +40,7 @@ It has these top-level messages: Evidence KVPair */ +//nolint: gas package types import proto "github.com/gogo/protobuf/proto"