INNER CODE UNIT · Go

getProtoIndex

rigdev/rig · cmd/rig-proto-gen/main.go:136

func getProtoIndex(f reflect.StructField) (int, error) {
	tag, ok := f.Tag.Lookup("protobuf")
	if !ok {
		return 0, errors.New("no protobuf tag")
	}
	splits := strings.Split(tag, ",")
	var ints []int
	for _, s := range splits {
		if i, err := strconv.Atoi(s); err == nil {
			ints = append(ints, i)
		}
	}
	if len(ints) != 1 {
		return 0, fmt.Errorf("expected exactly one integer element of the protobuf tag, got %v", len(ints))
	}

	return ints[0], nil
}

View source record →

📰 Research Paper
Loading…
⏳ Fetching content…