예제 #1
0
func main() {
	args, min := filter(os.Args[1:], "-version")
	if !version.AtLeast(min) {
		fmt.Printf("protoc version not high enough to parse this proto file\n")
		return
	}
	gen := exec.Command("protoc", args...)
	out, err := gen.CombinedOutput()
	if err != nil {
		fmt.Printf("%s\n", string(out))
		panic(err)
	}
}
예제 #2
0
func main() {
	flag.Parse()
	if !version.AtLeast(*min) {
		fmt.Printf("protoc version not high enough to parse this proto file\n")
		return
	}
	args := flag.Args()
	filename := args[0]
	args = append([]string{"--proto_path=" + *proto_path})
	if _, err := exec.LookPath("protoc"); err != nil {
		panic("cannot find protoc in PATH")
	}
	pluginStr := ""
	if len(*plugins) > 0 {
		pluginStr = "plugins=" + *plugins + ":"
	}
	m := MixMatch{
		Old: []string{
			"option (gogoproto.unmarshaler_all) = false;",
			"option (gogoproto.marshaler_all) = false;",
			"option (gogoproto.unsafe_unmarshaler_all) = false;",
			"option (gogoproto.unsafe_marshaler_all) = false;",
		},
		Filename: filename,
		Args:     args,
		Plugins:  pluginStr,
	}
	if *def {
		m.Gen("./combos/neither/", []string{
			"option (gogoproto.unmarshaler_all) = false;",
			"option (gogoproto.marshaler_all) = false;",
			"option (gogoproto.unsafe_unmarshaler_all) = false;",
			"option (gogoproto.unsafe_marshaler_all) = false;",
		})
	}
	m.Gen("./combos/marshaler/", []string{
		"option (gogoproto.unmarshaler_all) = false;",
		"option (gogoproto.marshaler_all) = true;",
		"option (gogoproto.unsafe_unmarshaler_all) = false;",
		"option (gogoproto.unsafe_marshaler_all) = false;",
	})
	m.Gen("./combos/unmarshaler/", []string{
		"option (gogoproto.unmarshaler_all) = true;",
		"option (gogoproto.marshaler_all) = false;",
		"option (gogoproto.unsafe_unmarshaler_all) = false;",
		"option (gogoproto.unsafe_marshaler_all) = false;",
	})
	m.Gen("./combos/both/", []string{
		"option (gogoproto.unmarshaler_all) = true;",
		"option (gogoproto.marshaler_all) = true;",
		"option (gogoproto.unsafe_unmarshaler_all) = false;",
		"option (gogoproto.unsafe_marshaler_all) = false;",
	})
	m.Gen("./combos/unsafemarshaler/", []string{
		"option (gogoproto.unmarshaler_all) = false;",
		"option (gogoproto.marshaler_all) = false;",
		"option (gogoproto.unsafe_unmarshaler_all) = false;",
		"option (gogoproto.unsafe_marshaler_all) = true;",
	})
	m.Gen("./combos/unsafeunmarshaler/", []string{
		"option (gogoproto.unmarshaler_all) = false;",
		"option (gogoproto.marshaler_all) = false;",
		"option (gogoproto.unsafe_unmarshaler_all) = true;",
		"option (gogoproto.unsafe_marshaler_all) = false;",
	})
	m.Gen("./combos/unsafeboth/", []string{
		"option (gogoproto.unmarshaler_all) = false;",
		"option (gogoproto.marshaler_all) = false;",
		"option (gogoproto.unsafe_unmarshaler_all) = true;",
		"option (gogoproto.unsafe_marshaler_all) = true;",
	})
}