Exemplo n.º 1
0
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)
}
Exemplo n.º 2
0
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)
}