當前位置: 首頁>>代碼示例>>Golang>>正文


Golang vanity.ForEachFile函數代碼示例

本文整理匯總了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)
}
開發者ID:gogo,項目名稱:fuzztests,代碼行數:35,代碼來源:main.go

示例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)
}
開發者ID:rawlingsj,項目名稱:gofabric8,代碼行數:29,代碼來源:main.go

示例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)
}
開發者ID:nolenroyalty,項目名稱:bangarang,代碼行數:11,代碼來源:main.go

示例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)
}
開發者ID:stevvooe,項目名稱:protobuf,代碼行數:12,代碼來源:main.go

示例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)
}
開發者ID:otsimo,項目名稱:otsimoctl,代碼行數:15,代碼來源:main.go

示例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)
}
開發者ID:jerrodrurik,項目名稱:protoc-gen-cleango,代碼行數:19,代碼來源:main.go

示例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)
}
開發者ID:pascaldekloe,項目名稱:colfer,代碼行數:38,代碼來源:main.go

示例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)
}
開發者ID:docker,項目名稱:containerd,代碼行數:19,代碼來源:main.go

示例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)
}
開發者ID:CubeLite,項目名稱:cockroach,代碼行數:71,代碼來源:main.go

示例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)
}
開發者ID:luxas,項目名稱:flannel,代碼行數:24,代碼來源:main.go


注:本文中的github.com/gogo/protobuf/vanity.ForEachFile函數示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。