github.com/cockroachdb/cockroach@v20.2.0-alpha.1+incompatible/pkg/cmd/protoc-gen-gogoroach/main.go (about) 1 // Copyright 2015 The Cockroach Authors. 2 // 3 // Use of this software is governed by the Business Source License 4 // included in the file licenses/BSL.txt. 5 // 6 // As of the Change Date specified in that file, in accordance with 7 // the Business Source License, use of this software will be governed 8 // by the Apache License, Version 2.0, included in the file 9 // licenses/APL.txt. 10 11 package main 12 13 import ( 14 "github.com/gogo/protobuf/protoc-gen-gogo/descriptor" 15 "github.com/gogo/protobuf/vanity" 16 "github.com/gogo/protobuf/vanity/command" 17 ) 18 19 func main() { 20 req := command.Read() 21 files := req.GetProtoFile() 22 files = vanity.FilterFiles(files, vanity.NotGoogleProtobufDescriptorProto) 23 24 for _, opt := range []func(*descriptor.FileDescriptorProto){ 25 vanity.TurnOffGoGettersAll, 26 27 // Currently harms readability. 28 // vanity.TurnOffGoEnumPrefixAll, 29 30 // `String() string` is part of gogoproto.Message, so we need this. 31 // vanity.TurnOffGoStringerAll, 32 33 // Maybe useful for tests? Not using currently. 34 // vanity.TurnOnVerboseEqualAll, 35 36 // Incompatible with oneof, and also not sure what the value is. 37 // vanity.TurnOnFaceAll, 38 39 // Requires that all child messages are generated with this, which 40 // is not the case for Raft messages which wrap raftpb (which 41 // doesn't use this). 42 // vanity.TurnOnGoStringAll, 43 44 // Not useful for us. 45 // vanity.TurnOnPopulateAll, 46 47 // Conflicts with `GoStringerAll`, which is enabled. 48 // vanity.TurnOnStringerAll, 49 50 // This generates a method that takes `interface{}`, which sucks. 51 // vanity.TurnOnEqualAll, 52 53 // Not useful for us. 54 // vanity.TurnOnDescriptionAll, 55 // vanity.TurnOnTestGenAll, 56 // vanity.TurnOnBenchGenAll, 57 58 vanity.TurnOnMarshalerAll, 59 vanity.TurnOnUnmarshalerAll, 60 vanity.TurnOnSizerAll, 61 62 // We want marshaled protobufs to be deterministic so that they can be 63 // compared byte-for-byte. At the time of writing, this is depended upon by 64 // the consistency checker. 65 vanity.TurnOnStable_MarshalerAll, 66 67 // Enabling these causes `String() string` on Enums to be inlined. 68 // Not worth it. 69 // vanity.TurnOffGoEnumStringerAll, 70 // vanity.TurnOnEnumStringerAll, 71 72 // Not clear that this is worthwhile. 73 // vanity.TurnOnUnsafeUnmarshalerAll, 74 // vanity.TurnOnUnsafeMarshalerAll, 75 76 // Something something extensions; we don't use 'em currently. 77 // vanity.TurnOffGoExtensionsMapAll, 78 79 // Disable generation of the following fields, which aren't worth 80 // their associated runtime cost: 81 // - XXX_unrecognized 82 // - XXX_NoUnkeyedLiteral 83 // - XXX_sizecache 84 vanity.TurnOffGoUnrecognizedAll, 85 vanity.TurnOffGoUnkeyedAll, 86 vanity.TurnOffGoSizecacheAll, 87 88 // Adds unnecessary dependency on golang/protobuf. 89 // vanity.TurnOffGogoImport, 90 } { 91 vanity.ForEachFile(files, opt) 92 } 93 94 resp := command.Generate(req) 95 command.Write(resp) 96 }