Browse Source

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
pull/1780/head
Emmanuel T Odeke 7 years ago
committed by Anton Kaliaev
parent
commit
811dc071aa
2 changed files with 4 additions and 0 deletions
  1. +3
    -0
      Makefile
  2. +1
    -0
      types/types.pb.go

+ 3
- 0
Makefile View File

@ -28,6 +28,9 @@ protoc:
## ldconfig (may require sudo) ## ldconfig (may require sudo)
## https://stackoverflow.com/a/25518702 ## https://stackoverflow.com/a/25518702
protoc $(INCLUDE) --gogo_out=plugins=grpc:. --lint_out=. types/*.proto 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: install:
@ go install ./cmd/... @ go install ./cmd/...


+ 1
- 0
types/types.pb.go View File

@ -40,6 +40,7 @@ It has these top-level messages:
Evidence Evidence
KVPair KVPair
*/ */
//nolint: gas
package types package types
import proto "github.com/gogo/protobuf/proto" import proto "github.com/gogo/protobuf/proto"


Loading…
Cancel
Save