You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
syntax = "proto3";
// A broken example of the official reference
// See https://developers.google.com/protocol-buffers/docs/reference/proto3-spec#proto_file
package examplePb;
option java_package = "com.example.foo";
import "other.proto";
import public "new.proto";
import "google/protobuf/empty.proto";
import "google/protobuf/timestamp.proto";
import "myproject/other_protos.proto";
import "myproject/main_protos.proto";
enum enumAllowingAlias {
option allow_alias = true;
UNKNOWN = 0;
STARTED = 1;
RUNNING = 2 [(custom_option) = "hello world"];
}
message outer {
option (my_option).a = true;
// inner is an inner message.
message innerAAA { // Level 2
int64 ival = 1;
}
repeated inner inner_message = 2;
EnumAllowingAlias enum_field =3;
map<int32, string> my_map = 4;
string reason_for_error = 5;
string end_of_support_version= 6;
message AccountForAdmin {}
message SpecialEndOfSupport {}
required inner inner_message = 7;
group Result = 8 {
string url = 9;
}
repeated group Result = 10 {
}
repeated inner paper = 11;
repeated group Regular = 12 {
}
}
service SearchApi {
rpc search (SearchRequest) returns (SearchResponse) {};
};
So I create a custom linter rule custumrule/enumrule.go:
package custumrule
import (
"github.com/yoheimuta/go-protoparser/v4/parser"
"github.com/yoheimuta/protolint/linter/report"
"github.com/yoheimuta/protolint/linter/strs"
"github.com/yoheimuta/protolint/linter/visitor"
)
// EnumNamesLowerSnakeCaseRule verifies that all enum names are LowerSnakeCase.
type EnumNamesLowerSnakeCaseRule struct{}
// NewEnumNamesLowerSnakeCaseRule creates a new EnumNamesLowerSnakeCaseRule.
func NewEnumNamesLowerSnakeCaseRule() EnumNamesLowerSnakeCaseRule {
return EnumNamesLowerSnakeCaseRule{}
}
// ID returns the ID of this rule.
func (r EnumNamesLowerSnakeCaseRule) ID() string {
return "ENUM_NAMES_LOWER_SNAKE_CASE"
}
// Purpose returns the purpose of this rule.
func (r EnumNamesLowerSnakeCaseRule) Purpose() string {
return "Verifies that all enum names are LowerSnakeCase."
}
// IsOfficial decides whether or not this rule belongs to the official guide.
func (r EnumNamesLowerSnakeCaseRule) IsOfficial() bool {
return true
}
// Apply applies the rule to the proto.
func (r EnumNamesLowerSnakeCaseRule) Apply(proto *parser.Proto) ([]report.Failure, error) {
v := &enumNamesLowerSnakeCaseVisitor{
BaseAddVisitor: visitor.NewBaseAddVisitor(r.ID()),
}
return visitor.RunVisitor(v, proto, r.ID())
}
type enumNamesLowerSnakeCaseVisitor struct {
*visitor.BaseAddVisitor
}
// VisitEnum checks the enum field.
func (v *enumNamesLowerSnakeCaseVisitor) VisitEnum(e *parser.Enum) bool {
if !strs.IsLowerSnakeCase(e.EnumName) {
v.AddFailuref(e.Meta.Pos, "Enum name %q must be underscore_separated_names", e.EnumName)
}
return false
}
I build project on windows and Linux subsystem by go buil main.go and try to run the command: protolint -plugin ./main.exe .. However, I receive failed client.Client(), err=exec: "sh": executable file not found in %PATH%
The text was updated successfully, but these errors were encountered:
rost5000
changed the title
Protolint doesn't work -plugin in windows
Protolint doesn't work with -plugin in windows
Jan 15, 2021
I have a following proto file:
So I create a custom linter rule
custumrule/enumrule.go
:and
main.go
:I build project on windows and Linux subsystem by
go buil main.go
and try to run the command:protolint -plugin ./main.exe .
. However, I receivefailed client.Client(), err=exec: "sh": executable file not found in %PATH%
The text was updated successfully, but these errors were encountered: