本文整理匯總了Golang中github.com/gogo/protobuf/vanity.ForEachFile函數的典型用法代碼示例。如果您正苦於以下問題:Golang ForEachFile函數的具體用法?Golang ForEachFile怎麽用?Golang ForEachFile使用的例子?那麽, 這裏精選的函數代碼示例或許可以為您提供幫助。
在下文中一共展示了ForEachFile函數的10個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Golang代碼示例。
示例1: main
func main() {
req := command.Read()
files := req.GetProtoFile()
files = vanity.FilterFiles(files, vanity.NotInPackageGoogleProtobuf)
vanity.ForEachFile(files, vanity.TurnOnPopulateAll)
vanity.ForEachFile(files, vanity.TurnOnGoStringAll)
vanity.ForEachFile(files, vanity.TurnOnDescriptionAll)
resp := command.Generate(req)
msgs := []string{}
for _, file := range files {
if file.GetPackage() == "fuzztests" {
for _, message := range file.GetMessageType() {
msgs = append(msgs, "NewPopulated"+message.GetName())
}
}
}
content := `
// Code generated by protoc-gen-gogopop.
// DO NOT EDIT!
package fuzztests
var popFuncs = []interface{}{
` +
strings.Join(msgs, ",\n") +
`,
}`
newFile := &plugin.CodeGeneratorResponse_File{
Name: proto.String("./pop.gen.go"),
Content: proto.String(content),
}
resp.File = append(resp.File, newFile)
command.Write(resp)
}
示例2: main
func main() {
req := command.Read()
files := req.GetProtoFile()
files = vanity.FilterFiles(files, vanity.NotGoogleProtobufDescriptorProto)
vanity.ForEachFile(files, vanity.TurnOnMarshalerAll)
vanity.ForEachFile(files, vanity.TurnOnSizerAll)
vanity.ForEachFile(files, vanity.TurnOnUnmarshalerAll)
vanity.ForEachFile(files, vanity.TurnOffGoEnumPrefixAll)
vanity.ForEachFile(files, vanity.TurnOffGoEnumStringerAll)
vanity.ForEachFile(files, vanity.TurnOnEnumStringerAll)
vanity.ForEachFile(files, vanity.TurnOnEqualAll)
vanity.ForEachFile(files, vanity.TurnOnGoStringAll)
vanity.ForEachFile(files, vanity.TurnOffGoStringerAll)
for _, file := range files {
if strings.HasSuffix(file.GetName(), "timestamp.proto") ||
strings.HasSuffix(file.GetName(), "duration.proto") {
continue
}
vanity.TurnOnStringerAll(file)
vanity.TurnOnPopulateAll(file)
}
resp := command.Generate(req)
command.Write(resp)
}
示例3: main
func main() {
req := command.Read()
files := req.GetProtoFile()
vanity.ForEachFile(files, vanity.TurnOnMarshalerAll)
vanity.ForEachFile(files, vanity.TurnOnSizerAll)
vanity.ForEachFile(files, vanity.TurnOnUnmarshalerAll)
resp := command.Generate(req)
command.Write(resp)
}
示例4: main
func main() {
req := command.Read()
files := req.GetProtoFile()
files = vanity.FilterFiles(files, vanity.NotInPackageGoogleProtobuf)
vanity.ForEachFile(files, vanity.TurnOnMarshalerAll)
vanity.ForEachFile(files, vanity.TurnOnSizerAll)
vanity.ForEachFile(files, vanity.TurnOnUnmarshalerAll)
resp := command.Generate(req)
command.Write(resp)
}
示例5: main
func main() {
req := command.Read()
files := req.GetProtoFile()
files = vanity.FilterFiles(files, vanity.NotInPackageGoogleProtobuf)
vanity.ForEachFile(files, vanity.TurnOnMarshalerAll)
vanity.ForEachFile(files, vanity.TurnOnSizerAll)
vanity.ForEachFile(files, vanity.TurnOnUnmarshalerAll)
vanity.ForEachFieldInFilesExcludingExtensions(vanity.OnlyProto2(files), vanity.TurnOffNullableForNativeTypesWithoutDefaultsOnly)
vanity.ForEachFile(files, vanity.TurnOffGoUnrecognizedAll)
resp := command.Generate(req)
command.Write(resp)
}
示例6: main
func main() {
req := command.Read()
files := req.GetProtoFile()
// Forced (to prevent mistake)
vanity.ForEachFile(files, vanity.TurnOffGogoImport)
// Default stuffs.
vanity.ForEachFile(files, vanity.TurnOnSizerAll) // 'Marshal' needs this.
vanity.ForEachFile(files, vanity.TurnOnUnmarshalerAll)
vanity.ForEachFile(files, vanity.TurnOnMarshalerAll)
// Apply custom fixes.
vanity.ForEachFieldInFilesExcludingExtensions(files, fixFieldName)
// vanity.ForEachFieldInFilesExcludingExtensions(files, fixNumericJSONTag)
resp := command.Generate(req)
command.Write(resp)
}
示例7: main
func main() {
req := command.Read()
files := req.GetProtoFile()
files = vanity.FilterFiles(files, vanity.NotGoogleProtobufDescriptorProto)
vanity.ForEachFile(files, vanity.TurnOnMarshalerAll)
vanity.ForEachFile(files, vanity.TurnOnSizerAll)
vanity.ForEachFile(files, vanity.TurnOnUnmarshalerAll)
vanity.ForEachFile(files, vanity.TurnOffGoEnumPrefixAll)
vanity.ForEachFile(files, vanity.TurnOffGoEnumStringerAll)
vanity.ForEachFile(files, vanity.TurnOnEnumStringerAll)
vanity.ForEachFile(files, vanity.TurnOnEqualAll)
vanity.ForEachFile(files, vanity.TurnOnGoStringAll)
vanity.ForEachFile(files, vanity.TurnOffGoStringerAll)
for _, file := range files {
if strings.HasSuffix(file.GetName(), "struct.proto") {
// TODO struct can also get a compare method when
// https://github.com/gogo/protobuf/issues/221 is fixed
continue
}
vanity.TurnOnCompareAll(file)
}
for _, file := range files {
if strings.HasSuffix(file.GetName(), "timestamp.proto") ||
strings.HasSuffix(file.GetName(), "duration.proto") {
continue
}
vanity.TurnOnStringerAll(file)
vanity.TurnOnPopulateAll(file)
}
resp := command.Generate(req)
command.Write(resp)
}
示例8: main
func main() {
req := command.Read()
files := req.GetProtoFile()
files = vanity.FilterFiles(files, vanity.NotGoogleProtobufDescriptorProto)
for _, opt := range []func(*descriptor.FileDescriptorProto){
vanity.TurnOnGoStringAll,
vanity.TurnOffGoGettersAll,
vanity.TurnOffGoStringerAll,
vanity.TurnOnMarshalerAll,
vanity.TurnOnStringerAll,
vanity.TurnOnUnmarshalerAll,
vanity.TurnOnSizerAll,
} {
vanity.ForEachFile(files, opt)
}
resp := command.Generate(req)
command.Write(resp)
}
示例9: main
func main() {
req := command.Read()
files := req.GetProtoFile()
files = vanity.FilterFiles(files, vanity.NotInPackageGoogleProtobuf)
for _, opt := range []func(*descriptor.FileDescriptorProto){
vanity.TurnOffGoGettersAll,
// Currently harms readability.
// vanity.TurnOffGoEnumPrefixAll,
// `String() string` is part of gogoproto.Message, so we need this.
// vanity.TurnOffGoStringerAll,
// Maybe useful for tests? Not using currently.
// vanity.TurnOnVerboseEqualAll,
// Incompatible with oneof, and also not sure what the value is.
// vanity.TurnOnFaceAll,
// Requires that all child messages are generated with this, which
// is not the case for Raft messages which wrap raftpb (which
// doesn't use this).
// vanity.TurnOnGoStringAll,
// Not useful for us.
// vanity.TurnOnPopulateAll,
// Conflicts with `GoStringerAll`, which is enabled.
// vanity.TurnOnStringerAll,
// This generates a method that takes `interface{}`, which sucks.
// vanity.TurnOnEqualAll,
// Not useful for us.
// vanity.TurnOnDescriptionAll,
// vanity.TurnOnTestGenAll,
// vanity.TurnOnBenchGenAll,
vanity.TurnOnMarshalerAll,
vanity.TurnOnUnmarshalerAll,
vanity.TurnOnSizerAll,
// We want marshalled protobufs to be deterministic so that they can be
// compared byte-for-byte. At the time of writing, this is depended upon by
// the consistency checker.
vanity.TurnOnStable_MarshalerAll,
// Enabling these causes `String() string` on Enums to be inlined.
// Not worth it.
// vanity.TurnOffGoEnumStringerAll,
// vanity.TurnOnEnumStringerAll,
// Not clear that this is worthwhile.
// vanity.TurnOnUnsafeUnmarshalerAll,
// vanity.TurnOnUnsafeMarshalerAll,
// Something something extensions; we don't use 'em currently.
// vanity.TurnOffGoExtensionsMapAll,
vanity.TurnOffGoUnrecognizedAll,
// Adds unnecessary dependency on golang/protobuf.
// vanity.TurnOffGogoImport,
} {
vanity.ForEachFile(files, opt)
}
resp := command.Generate(req)
command.Write(resp)
}
示例10: main
func main() {
req := command.Read()
files := req.GetProtoFile()
files = vanity.FilterFiles(files, vanity.NotGoogleProtobufDescriptorProto)
vanity.ForEachFile(files, vanity.TurnOnMarshalerAll)
vanity.ForEachFile(files, vanity.TurnOnSizerAll)
vanity.ForEachFile(files, vanity.TurnOnUnmarshalerAll)
vanity.ForEachFieldInFilesExcludingExtensions(vanity.OnlyProto2(files), vanity.TurnOffNullableForNativeTypesWithoutDefaultsOnly)
vanity.ForEachFile(files, vanity.TurnOffGoUnrecognizedAll)
vanity.ForEachFile(files, vanity.TurnOffGoEnumPrefixAll)
vanity.ForEachFile(files, vanity.TurnOffGoEnumStringerAll)
vanity.ForEachFile(files, vanity.TurnOnEnumStringerAll)
vanity.ForEachFile(files, vanity.TurnOnEqualAll)
vanity.ForEachFile(files, vanity.TurnOnGoStringAll)
vanity.ForEachFile(files, vanity.TurnOffGoStringerAll)
vanity.ForEachFile(files, vanity.TurnOnStringerAll)
resp := command.Generate(req)
command.Write(resp)
}