Small fixes for protogen plugin #107
11 changed files with 489 additions and 75 deletions
1
Makefile
1
Makefile
|
@ -79,6 +79,7 @@ $(BIN)/protogen:
|
|||
|
||||
protoc-test: protoc $(BIN)/protogen
|
||||
@$(PROTOC_DIR)/bin/protoc \
|
||||
--go_out=. --go_opt=paths=source_relative \
|
||||
--plugin=protoc-gen-go-frostfs=$(abspath $(BIN)/protogen) \
|
||||
--go-frostfs_opt=Mutil/proto/test/test.proto=git.frostfs.info/TrueCloudLab/frostfs-api-go/v2/util/proto/test/custom \
|
||||
--go-frostfs_opt=module=git.frostfs.info/TrueCloudLab/frostfs-api-go/v2 \
|
||||
|
|
6
ape/grpc/types_frostfs.pb.go
generated
6
ape/grpc/types_frostfs.pb.go
generated
|
@ -303,9 +303,9 @@ func (x *Chain) GetKind() isChain_Kind {
|
|||
func (x *Chain) SetKind(v isChain_Kind) {
|
||||
x.Kind = v
|
||||
}
|
||||
func (x *Chain) GetRaw() *Chain_Raw {
|
||||
func (x *Chain) GetRaw() []byte {
|
||||
if xx, ok := x.GetKind().(*Chain_Raw); ok {
|
||||
return xx
|
||||
return xx.Raw
|
||||
}
|
||||
return nil
|
||||
}
|
||||
|
@ -341,8 +341,6 @@ func (x *Chain) MarshalEasyJSON(out *jwriter.Writer) {
|
|||
out.RawString(prefix[1:])
|
||||
out.Base64Bytes(xx.Raw)
|
||||
}
|
||||
default:
|
||||
out.RawString("null")
|
||||
}
|
||||
out.RawByte('}')
|
||||
}
|
||||
|
|
20
object/grpc/service_frostfs.pb.go
generated
20
object/grpc/service_frostfs.pb.go
generated
|
@ -739,9 +739,9 @@ func (x *GetResponse_Body) GetInit() *GetResponse_Body_Init {
|
|||
func (x *GetResponse_Body) SetInit(v *GetResponse_Body_Init) {
|
||||
x.ObjectPart = &GetResponse_Body_Init_{Init: v}
|
||||
}
|
||||
func (x *GetResponse_Body) GetChunk() *GetResponse_Body_Chunk {
|
||||
func (x *GetResponse_Body) GetChunk() []byte {
|
||||
if xx, ok := x.GetObjectPart().(*GetResponse_Body_Chunk); ok {
|
||||
return xx
|
||||
return xx.Chunk
|
||||
}
|
||||
return nil
|
||||
}
|
||||
|
@ -813,8 +813,6 @@ func (x *GetResponse_Body) MarshalEasyJSON(out *jwriter.Writer) {
|
|||
out.RawString(prefix[1:])
|
||||
xx.EcInfo.MarshalEasyJSON(out)
|
||||
}
|
||||
default:
|
||||
out.RawString("null")
|
||||
}
|
||||
out.RawByte('}')
|
||||
}
|
||||
|
@ -1486,9 +1484,9 @@ func (x *PutRequest_Body) GetInit() *PutRequest_Body_Init {
|
|||
func (x *PutRequest_Body) SetInit(v *PutRequest_Body_Init) {
|
||||
x.ObjectPart = &PutRequest_Body_Init_{Init: v}
|
||||
}
|
||||
func (x *PutRequest_Body) GetChunk() *PutRequest_Body_Chunk {
|
||||
func (x *PutRequest_Body) GetChunk() []byte {
|
||||
if xx, ok := x.GetObjectPart().(*PutRequest_Body_Chunk); ok {
|
||||
return xx
|
||||
return xx.Chunk
|
||||
}
|
||||
return nil
|
||||
}
|
||||
|
@ -1530,8 +1528,6 @@ func (x *PutRequest_Body) MarshalEasyJSON(out *jwriter.Writer) {
|
|||
out.RawString(prefix[1:])
|
||||
out.Base64Bytes(xx.Chunk)
|
||||
}
|
||||
default:
|
||||
out.RawString("null")
|
||||
}
|
||||
out.RawByte('}')
|
||||
}
|
||||
|
@ -3674,8 +3670,6 @@ func (x *HeadResponse_Body) MarshalEasyJSON(out *jwriter.Writer) {
|
|||
out.RawString(prefix[1:])
|
||||
xx.EcInfo.MarshalEasyJSON(out)
|
||||
}
|
||||
default:
|
||||
out.RawString("null")
|
||||
}
|
||||
out.RawByte('}')
|
||||
}
|
||||
|
@ -5706,9 +5700,9 @@ func (x *GetRangeResponse_Body) GetRangePart() isGetRangeResponse_Body_RangePart
|
|||
func (x *GetRangeResponse_Body) SetRangePart(v isGetRangeResponse_Body_RangePart) {
|
||||
x.RangePart = v
|
||||
}
|
||||
func (x *GetRangeResponse_Body) GetChunk() *GetRangeResponse_Body_Chunk {
|
||||
func (x *GetRangeResponse_Body) GetChunk() []byte {
|
||||
if xx, ok := x.GetRangePart().(*GetRangeResponse_Body_Chunk); ok {
|
||||
return xx
|
||||
return xx.Chunk
|
||||
}
|
||||
return nil
|
||||
}
|
||||
|
@ -5774,8 +5768,6 @@ func (x *GetRangeResponse_Body) MarshalEasyJSON(out *jwriter.Writer) {
|
|||
out.RawString(prefix[1:])
|
||||
xx.EcInfo.MarshalEasyJSON(out)
|
||||
}
|
||||
default:
|
||||
out.RawString("null")
|
||||
}
|
||||
out.RawByte('}')
|
||||
}
|
||||
|
|
2
session/grpc/types_frostfs.pb.go
generated
2
session/grpc/types_frostfs.pb.go
generated
|
@ -1121,8 +1121,6 @@ func (x *SessionToken_Body) MarshalEasyJSON(out *jwriter.Writer) {
|
|||
out.RawString(prefix)
|
||||
xx.Container.MarshalEasyJSON(out)
|
||||
}
|
||||
default:
|
||||
out.RawString("null")
|
||||
}
|
||||
out.RawByte('}')
|
||||
}
|
||||
|
|
|
@ -49,6 +49,8 @@ func TestStableMarshalSingle(t *testing.T) {
|
|||
{name: "fixed32", input: &generated.Primitives{FieldK: nonZero[uint32]()}},
|
||||
{name: "enum, positive", input: &generated.Primitives{FieldH: generated.Primitives_POSITIVE}},
|
||||
{name: "enum, negative", input: &generated.Primitives{FieldH: generated.Primitives_NEGATIVE}},
|
||||
{name: "oneof, first", input: &generated.Primitives{FieldM: &generated.Primitives_FieldMa{FieldMa: []byte{4, 2}}}},
|
||||
{name: "oneof, second", input: &generated.Primitives{FieldM: &generated.Primitives_FieldMe{FieldMe: nonZero[uint32]()}}},
|
||||
}
|
||||
for _, tc := range marshalCases {
|
||||
t.Run(tc.name, func(t *testing.T) {
|
||||
|
@ -97,6 +99,9 @@ func primitivesEqual(t *testing.T, a *generated.Primitives, b *test.Primitives)
|
|||
require.Equal(t, a.FieldJ, b.FieldJ)
|
||||
require.Equal(t, a.FieldK, b.FieldK)
|
||||
require.EqualValues(t, a.FieldH, b.FieldH)
|
||||
require.Equal(t, a.GetFieldMa(), b.GetFieldMa())
|
||||
require.Equal(t, a.GetFieldMe(), b.GetFieldMe())
|
||||
require.Equal(t, a.GetFieldAux().GetInnerField(), b.GetFieldAux().GetInnerField())
|
||||
}
|
||||
|
||||
func repPrimitivesEqual(t *testing.T, a *generated.RepPrimitives, b *test.RepPrimitives) {
|
||||
|
|
303
util/proto/test/custom/test_frostfs.pb.go
generated
303
util/proto/test/custom/test_frostfs.pb.go
generated
|
@ -18,9 +18,9 @@ import (
|
|||
type Primitives_SomeEnum int32
|
||||
|
||||
const (
|
||||
Primitives_UNKNOWN = 0
|
||||
Primitives_POSITIVE = 1
|
||||
Primitives_NEGATIVE = -1
|
||||
Primitives_UNKNOWN Primitives_SomeEnum = 0
|
||||
Primitives_POSITIVE Primitives_SomeEnum = 1
|
||||
Primitives_NEGATIVE Primitives_SomeEnum = -1
|
||||
)
|
||||
|
||||
var (
|
||||
|
@ -50,6 +50,135 @@ func (x *Primitives_SomeEnum) FromString(s string) bool {
|
|||
return false
|
||||
}
|
||||
|
||||
type Primitives_Aux struct {
|
||||
InnerField uint32 `json:"innerField"`
|
||||
}
|
||||
|
||||
var (
|
||||
_ encoding.ProtoMarshaler = (*Primitives_Aux)(nil)
|
||||
_ encoding.ProtoUnmarshaler = (*Primitives_Aux)(nil)
|
||||
_ json.Marshaler = (*Primitives_Aux)(nil)
|
||||
_ json.Unmarshaler = (*Primitives_Aux)(nil)
|
||||
)
|
||||
|
||||
// StableSize returns the size of x in protobuf format.
|
||||
//
|
||||
// Structures with the same field values have the same binary size.
|
||||
func (x *Primitives_Aux) StableSize() (size int) {
|
||||
if x == nil {
|
||||
return 0
|
||||
}
|
||||
size += proto.UInt32Size(1, x.InnerField)
|
||||
return size
|
||||
}
|
||||
|
||||
// MarshalProtobuf implements the encoding.ProtoMarshaler interface.
|
||||
func (x *Primitives_Aux) MarshalProtobuf(dst []byte) []byte {
|
||||
m := pool.MarshalerPool.Get()
|
||||
defer pool.MarshalerPool.Put(m)
|
||||
x.EmitProtobuf(m.MessageMarshaler())
|
||||
dst = m.Marshal(dst)
|
||||
return dst
|
||||
}
|
||||
|
||||
func (x *Primitives_Aux) EmitProtobuf(mm *easyproto.MessageMarshaler) {
|
||||
if x == nil {
|
||||
return
|
||||
}
|
||||
if x.InnerField != 0 {
|
||||
mm.AppendUint32(1, x.InnerField)
|
||||
}
|
||||
}
|
||||
|
||||
// UnmarshalProtobuf implements the encoding.ProtoUnmarshaler interface.
|
||||
func (x *Primitives_Aux) UnmarshalProtobuf(src []byte) (err error) {
|
||||
var fc easyproto.FieldContext
|
||||
for len(src) > 0 {
|
||||
src, err = fc.NextField(src)
|
||||
if err != nil {
|
||||
return fmt.Errorf("cannot read next field in %s", "Primitives_Aux")
|
||||
}
|
||||
switch fc.FieldNum {
|
||||
case 1: // InnerField
|
||||
data, ok := fc.Uint32()
|
||||
if !ok {
|
||||
return fmt.Errorf("cannot unmarshal field %s", "InnerField")
|
||||
}
|
||||
x.InnerField = data
|
||||
}
|
||||
}
|
||||
return nil
|
||||
}
|
||||
func (x *Primitives_Aux) GetInnerField() uint32 {
|
||||
if x != nil {
|
||||
return x.InnerField
|
||||
}
|
||||
return 0
|
||||
}
|
||||
func (x *Primitives_Aux) SetInnerField(v uint32) {
|
||||
x.InnerField = v
|
||||
}
|
||||
|
||||
// MarshalJSON implements the json.Marshaler interface.
|
||||
func (x *Primitives_Aux) MarshalJSON() ([]byte, error) {
|
||||
w := jwriter.Writer{}
|
||||
x.MarshalEasyJSON(&w)
|
||||
return w.Buffer.BuildBytes(), w.Error
|
||||
}
|
||||
func (x *Primitives_Aux) MarshalEasyJSON(out *jwriter.Writer) {
|
||||
if x == nil {
|
||||
out.RawString("null")
|
||||
return
|
||||
}
|
||||
out.RawByte('{')
|
||||
{
|
||||
const prefix string = ",\"innerField\":"
|
||||
out.RawString(prefix[1:])
|
||||
out.Uint32(x.InnerField)
|
||||
}
|
||||
out.RawByte('}')
|
||||
}
|
||||
|
||||
// UnmarshalJSON implements the json.Unmarshaler interface.
|
||||
func (x *Primitives_Aux) UnmarshalJSON(data []byte) error {
|
||||
r := jlexer.Lexer{Data: data}
|
||||
x.UnmarshalEasyJSON(&r)
|
||||
return r.Error()
|
||||
}
|
||||
func (x *Primitives_Aux) UnmarshalEasyJSON(in *jlexer.Lexer) {
|
||||
isTopLevel := in.IsStart()
|
||||
if in.IsNull() {
|
||||
if isTopLevel {
|
||||
in.Consumed()
|
||||
}
|
||||
in.Skip()
|
||||
return
|
||||
}
|
||||
in.Delim('{')
|
||||
for !in.IsDelim('}') {
|
||||
key := in.UnsafeFieldName(false)
|
||||
in.WantColon()
|
||||
if in.IsNull() {
|
||||
in.Skip()
|
||||
in.WantComma()
|
||||
continue
|
||||
}
|
||||
switch key {
|
||||
case "innerField":
|
||||
{
|
||||
var f uint32
|
||||
f = in.Uint32()
|
||||
x.InnerField = f
|
||||
}
|
||||
}
|
||||
in.WantComma()
|
||||
}
|
||||
in.Delim('}')
|
||||
if isTopLevel {
|
||||
in.Consumed()
|
||||
}
|
||||
}
|
||||
|
||||
type Primitives struct {
|
||||
FieldA []byte `json:"fieldA"`
|
||||
FieldB string `json:"fieldB"`
|
||||
|
@ -62,6 +191,7 @@ type Primitives struct {
|
|||
FieldJ float64 `json:"fieldJ"`
|
||||
FieldK uint32 `json:"fieldK"`
|
||||
FieldH Primitives_SomeEnum `json:"fieldH"`
|
||||
FieldM isPrimitives_FieldM
|
||||
}
|
||||
|
||||
var (
|
||||
|
@ -89,6 +219,15 @@ func (x *Primitives) StableSize() (size int) {
|
|||
size += proto.Float64Size(206, x.FieldJ)
|
||||
size += proto.Fixed32Size(207, x.FieldK)
|
||||
size += proto.EnumSize(300, int32(x.FieldH))
|
||||
if inner, ok := x.FieldM.(*Primitives_FieldMa); ok {
|
||||
size += proto.BytesSize(401, inner.FieldMa)
|
||||
}
|
||||
if inner, ok := x.FieldM.(*Primitives_FieldMe); ok {
|
||||
size += proto.UInt32Size(402, inner.FieldMe)
|
||||
}
|
||||
if inner, ok := x.FieldM.(*Primitives_FieldAux); ok {
|
||||
size += proto.NestedStructureSize(403, inner.FieldAux)
|
||||
}
|
||||
return size
|
||||
}
|
||||
|
||||
|
@ -138,6 +277,21 @@ func (x *Primitives) EmitProtobuf(mm *easyproto.MessageMarshaler) {
|
|||
if int32(x.FieldH) != 0 {
|
||||
mm.AppendInt32(300, int32(x.FieldH))
|
||||
}
|
||||
if inner, ok := x.FieldM.(*Primitives_FieldMa); ok {
|
||||
if len(inner.FieldMa) != 0 {
|
||||
mm.AppendBytes(401, inner.FieldMa)
|
||||
}
|
||||
}
|
||||
if inner, ok := x.FieldM.(*Primitives_FieldMe); ok {
|
||||
if inner.FieldMe != 0 {
|
||||
mm.AppendUint32(402, inner.FieldMe)
|
||||
}
|
||||
}
|
||||
if inner, ok := x.FieldM.(*Primitives_FieldAux); ok {
|
||||
if inner.FieldAux != nil && inner.FieldAux.StableSize() != 0 {
|
||||
inner.FieldAux.EmitProtobuf(mm.AppendMessage(403))
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// UnmarshalProtobuf implements the encoding.ProtoUnmarshaler interface.
|
||||
|
@ -215,6 +369,28 @@ func (x *Primitives) UnmarshalProtobuf(src []byte) (err error) {
|
|||
return fmt.Errorf("cannot unmarshal field %s", "FieldH")
|
||||
}
|
||||
x.FieldH = Primitives_SomeEnum(data)
|
||||
case 401: // FieldMa
|
||||
data, ok := fc.Bytes()
|
||||
if !ok {
|
||||
return fmt.Errorf("cannot unmarshal field %s", "FieldMa")
|
||||
}
|
||||
x.FieldM = &Primitives_FieldMa{FieldMa: data}
|
||||
case 402: // FieldMe
|
||||
data, ok := fc.Uint32()
|
||||
if !ok {
|
||||
return fmt.Errorf("cannot unmarshal field %s", "FieldMe")
|
||||
}
|
||||
x.FieldM = &Primitives_FieldMe{FieldMe: data}
|
||||
case 403: // FieldAux
|
||||
data, ok := fc.MessageData()
|
||||
if !ok {
|
||||
return fmt.Errorf("cannot unmarshal field %s", "FieldAux")
|
||||
}
|
||||
oneofField := &Primitives_FieldAux{FieldAux: new(Primitives_Aux)}
|
||||
if err := oneofField.FieldAux.UnmarshalProtobuf(data); err != nil {
|
||||
return fmt.Errorf("unmarshal: %w", err)
|
||||
}
|
||||
x.FieldM = oneofField
|
||||
}
|
||||
}
|
||||
return nil
|
||||
|
@ -318,6 +494,60 @@ func (x *Primitives) GetFieldH() Primitives_SomeEnum {
|
|||
func (x *Primitives) SetFieldH(v Primitives_SomeEnum) {
|
||||
x.FieldH = v
|
||||
}
|
||||
func (x *Primitives) GetFieldM() isPrimitives_FieldM {
|
||||
if x != nil {
|
||||
return x.FieldM
|
||||
}
|
||||
return nil
|
||||
}
|
||||
func (x *Primitives) SetFieldM(v isPrimitives_FieldM) {
|
||||
x.FieldM = v
|
||||
}
|
||||
func (x *Primitives) GetFieldMa() []byte {
|
||||
if xx, ok := x.GetFieldM().(*Primitives_FieldMa); ok {
|
||||
return xx.FieldMa
|
||||
}
|
||||
return nil
|
||||
}
|
||||
func (x *Primitives) SetFieldMa(v *Primitives_FieldMa) {
|
||||
x.FieldM = v
|
||||
}
|
||||
func (x *Primitives_FieldMa) GetFieldMa() []byte {
|
||||
if x != nil {
|
||||
return x.FieldMa
|
||||
}
|
||||
return nil
|
||||
}
|
||||
func (x *Primitives_FieldMa) SetFieldMa(v []byte) {
|
||||
x.FieldMa = v
|
||||
}
|
||||
func (x *Primitives) GetFieldMe() uint32 {
|
||||
if xx, ok := x.GetFieldM().(*Primitives_FieldMe); ok {
|
||||
return xx.FieldMe
|
||||
}
|
||||
return 0
|
||||
}
|
||||
func (x *Primitives) SetFieldMe(v *Primitives_FieldMe) {
|
||||
x.FieldM = v
|
||||
}
|
||||
func (x *Primitives_FieldMe) GetFieldMe() uint32 {
|
||||
if x != nil {
|
||||
return x.FieldMe
|
||||
}
|
||||
return 0
|
||||
}
|
||||
func (x *Primitives_FieldMe) SetFieldMe(v uint32) {
|
||||
x.FieldMe = v
|
||||
}
|
||||
func (x *Primitives) GetFieldAux() *Primitives_Aux {
|
||||
if xx, ok := x.GetFieldM().(*Primitives_FieldAux); ok {
|
||||
return xx.FieldAux
|
||||
}
|
||||
return nil
|
||||
}
|
||||
func (x *Primitives) SetFieldAux(v *Primitives_Aux) {
|
||||
x.FieldM = &Primitives_FieldAux{FieldAux: v}
|
||||
}
|
||||
|
||||
// MarshalJSON implements the json.Marshaler interface.
|
||||
func (x *Primitives) MarshalJSON() ([]byte, error) {
|
||||
|
@ -386,6 +616,26 @@ func (x *Primitives) MarshalEasyJSON(out *jwriter.Writer) {
|
|||
out.RawString(prefix)
|
||||
out.Int32(int32(x.FieldH))
|
||||
}
|
||||
switch xx := x.FieldM.(type) {
|
||||
case *Primitives_FieldMa:
|
||||
{
|
||||
const prefix string = ",\"fieldMa\":"
|
||||
out.RawString(prefix)
|
||||
out.Base64Bytes(xx.FieldMa)
|
||||
}
|
||||
case *Primitives_FieldMe:
|
||||
{
|
||||
const prefix string = ",\"fieldMe\":"
|
||||
out.RawString(prefix)
|
||||
out.Uint32(xx.FieldMe)
|
||||
}
|
||||
case *Primitives_FieldAux:
|
||||
{
|
||||
const prefix string = ",\"fieldAux\":"
|
||||
out.RawString(prefix)
|
||||
xx.FieldAux.MarshalEasyJSON(out)
|
||||
}
|
||||
}
|
||||
out.RawByte('}')
|
||||
}
|
||||
|
||||
|
@ -496,6 +746,31 @@ func (x *Primitives) UnmarshalEasyJSON(in *jlexer.Lexer) {
|
|||
f = parsedValue
|
||||
x.FieldH = f
|
||||
}
|
||||
case "fieldMa":
|
||||
xx := new(Primitives_FieldMa)
|
||||
x.FieldM = xx
|
||||
{
|
||||
var f []byte
|
||||
f = in.Bytes()
|
||||
xx.FieldMa = f
|
||||
}
|
||||
case "fieldMe":
|
||||
xx := new(Primitives_FieldMe)
|
||||
x.FieldM = xx
|
||||
{
|
||||
var f uint32
|
||||
f = in.Uint32()
|
||||
xx.FieldMe = f
|
||||
}
|
||||
case "fieldAux":
|
||||
xx := new(Primitives_FieldAux)
|
||||
x.FieldM = xx
|
||||
{
|
||||
var f *Primitives_Aux
|
||||
f = new(Primitives_Aux)
|
||||
f.UnmarshalEasyJSON(in)
|
||||
xx.FieldAux = f
|
||||
}
|
||||
}
|
||||
in.WantComma()
|
||||
}
|
||||
|
@ -505,6 +780,28 @@ func (x *Primitives) UnmarshalEasyJSON(in *jlexer.Lexer) {
|
|||
}
|
||||
}
|
||||
|
||||
type isPrimitives_FieldM interface {
|
||||
isPrimitives_FieldM()
|
||||
}
|
||||
|
||||
type Primitives_FieldMa struct {
|
||||
FieldMa []byte
|
||||
}
|
||||
|
||||
type Primitives_FieldMe struct {
|
||||
FieldMe uint32
|
||||
}
|
||||
|
||||
type Primitives_FieldAux struct {
|
||||
FieldAux *Primitives_Aux
|
||||
}
|
||||
|
||||
func (*Primitives_FieldMa) isPrimitives_FieldM() {}
|
||||
|
||||
func (*Primitives_FieldMe) isPrimitives_FieldM() {}
|
||||
|
||||
func (*Primitives_FieldAux) isPrimitives_FieldM() {}
|
||||
|
||||
type RepPrimitives struct {
|
||||
FieldA [][]byte `json:"fieldA"`
|
||||
FieldB []string `json:"fieldB"`
|
||||
|
|
186
util/proto/test/test.pb.go
generated
186
util/proto/test/test.pb.go
generated
|
@ -85,6 +85,12 @@ type Primitives struct {
|
|||
FieldJ float64 `protobuf:"fixed64,206,opt,name=field_j,json=fieldJ,proto3" json:"field_j,omitempty"`
|
||||
FieldK uint32 `protobuf:"fixed32,207,opt,name=field_k,json=fieldK,proto3" json:"field_k,omitempty"`
|
||||
FieldH Primitives_SomeEnum `protobuf:"varint,300,opt,name=field_h,json=fieldH,proto3,enum=test.Primitives_SomeEnum" json:"field_h,omitempty"`
|
||||
// Types that are assignable to FieldM:
|
||||
//
|
||||
// *Primitives_FieldMa
|
||||
// *Primitives_FieldMe
|
||||
// *Primitives_FieldAux
|
||||
FieldM isPrimitives_FieldM `protobuf_oneof:"field_m"`
|
||||
}
|
||||
|
||||
func (x *Primitives) Reset() {
|
||||
|
@ -196,6 +202,56 @@ func (x *Primitives) GetFieldH() Primitives_SomeEnum {
|
|||
return Primitives_UNKNOWN
|
||||
}
|
||||
|
||||
func (m *Primitives) GetFieldM() isPrimitives_FieldM {
|
||||
if m != nil {
|
||||
return m.FieldM
|
||||
}
|
||||
return nil
|
||||
}
|
||||
|
||||
func (x *Primitives) GetFieldMa() []byte {
|
||||
if x, ok := x.GetFieldM().(*Primitives_FieldMa); ok {
|
||||
return x.FieldMa
|
||||
}
|
||||
return nil
|
||||
}
|
||||
|
||||
func (x *Primitives) GetFieldMe() uint32 {
|
||||
if x, ok := x.GetFieldM().(*Primitives_FieldMe); ok {
|
||||
return x.FieldMe
|
||||
}
|
||||
return 0
|
||||
}
|
||||
|
||||
func (x *Primitives) GetFieldAux() *Primitives_Aux {
|
||||
if x, ok := x.GetFieldM().(*Primitives_FieldAux); ok {
|
||||
return x.FieldAux
|
||||
}
|
||||
return nil
|
||||
}
|
||||
|
||||
type isPrimitives_FieldM interface {
|
||||
isPrimitives_FieldM()
|
||||
}
|
||||
|
||||
type Primitives_FieldMa struct {
|
||||
FieldMa []byte `protobuf:"bytes,401,opt,name=field_ma,json=fieldMa,proto3,oneof"`
|
||||
}
|
||||
|
||||
type Primitives_FieldMe struct {
|
||||
FieldMe uint32 `protobuf:"varint,402,opt,name=field_me,json=fieldMe,proto3,oneof"`
|
||||
}
|
||||
|
||||
type Primitives_FieldAux struct {
|
||||
FieldAux *Primitives_Aux `protobuf:"bytes,403,opt,name=field_aux,json=fieldAux,proto3,oneof"`
|
||||
}
|
||||
|
||||
func (*Primitives_FieldMa) isPrimitives_FieldM() {}
|
||||
|
||||
func (*Primitives_FieldMe) isPrimitives_FieldM() {}
|
||||
|
||||
func (*Primitives_FieldAux) isPrimitives_FieldM() {}
|
||||
|
||||
type RepPrimitives struct {
|
||||
state protoimpl.MessageState
|
||||
sizeCache protoimpl.SizeCache
|
||||
|
@ -291,12 +347,59 @@ func (x *RepPrimitives) GetFieldFu() []uint64 {
|
|||
return nil
|
||||
}
|
||||
|
||||
type Primitives_Aux struct {
|
||||
state protoimpl.MessageState
|
||||
sizeCache protoimpl.SizeCache
|
||||
unknownFields protoimpl.UnknownFields
|
||||
|
||||
InnerField uint32 `protobuf:"varint,1,opt,name=inner_field,json=innerField,proto3" json:"inner_field,omitempty"`
|
||||
}
|
||||
|
||||
func (x *Primitives_Aux) Reset() {
|
||||
*x = Primitives_Aux{}
|
||||
if protoimpl.UnsafeEnabled {
|
||||
mi := &file_util_proto_test_test_proto_msgTypes[2]
|
||||
ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x))
|
||||
ms.StoreMessageInfo(mi)
|
||||
}
|
||||
}
|
||||
|
||||
func (x *Primitives_Aux) String() string {
|
||||
return protoimpl.X.MessageStringOf(x)
|
||||
}
|
||||
|
||||
func (*Primitives_Aux) ProtoMessage() {}
|
||||
|
||||
func (x *Primitives_Aux) ProtoReflect() protoreflect.Message {
|
||||
mi := &file_util_proto_test_test_proto_msgTypes[2]
|
||||
if protoimpl.UnsafeEnabled && x != nil {
|
||||
ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x))
|
||||
if ms.LoadMessageInfo() == nil {
|
||||
ms.StoreMessageInfo(mi)
|
||||
}
|
||||
return ms
|
||||
}
|
||||
return mi.MessageOf(x)
|
||||
}
|
||||
|
||||
// Deprecated: Use Primitives_Aux.ProtoReflect.Descriptor instead.
|
||||
func (*Primitives_Aux) Descriptor() ([]byte, []int) {
|
||||
return file_util_proto_test_test_proto_rawDescGZIP(), []int{0, 0}
|
||||
}
|
||||
|
||||
func (x *Primitives_Aux) GetInnerField() uint32 {
|
||||
if x != nil {
|
||||
return x.InnerField
|
||||
}
|
||||
return 0
|
||||
}
|
||||
|
||||
var File_util_proto_test_test_proto protoreflect.FileDescriptor
|
||||
|
||||
var file_util_proto_test_test_proto_rawDesc = []byte{
|
||||
0x0a, 0x1a, 0x75, 0x74, 0x69, 0x6c, 0x2f, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x2f, 0x74, 0x65, 0x73,
|
||||
0x74, 0x2f, 0x74, 0x65, 0x73, 0x74, 0x2e, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x12, 0x04, 0x74, 0x65,
|
||||
0x73, 0x74, 0x22, 0x81, 0x03, 0x0a, 0x0a, 0x50, 0x72, 0x69, 0x6d, 0x69, 0x74, 0x69, 0x76, 0x65,
|
||||
0x73, 0x74, 0x22, 0xa6, 0x04, 0x0a, 0x0a, 0x50, 0x72, 0x69, 0x6d, 0x69, 0x74, 0x69, 0x76, 0x65,
|
||||
0x73, 0x12, 0x17, 0x0a, 0x07, 0x66, 0x69, 0x65, 0x6c, 0x64, 0x5f, 0x61, 0x18, 0x01, 0x20, 0x01,
|
||||
0x28, 0x0c, 0x52, 0x06, 0x66, 0x69, 0x65, 0x6c, 0x64, 0x41, 0x12, 0x17, 0x0a, 0x07, 0x66, 0x69,
|
||||
0x65, 0x6c, 0x64, 0x5f, 0x62, 0x18, 0x02, 0x20, 0x01, 0x28, 0x09, 0x52, 0x06, 0x66, 0x69, 0x65,
|
||||
|
@ -316,25 +419,35 @@ var file_util_proto_test_test_proto_rawDesc = []byte{
|
|||
0x6c, 0x64, 0x4b, 0x12, 0x33, 0x0a, 0x07, 0x66, 0x69, 0x65, 0x6c, 0x64, 0x5f, 0x68, 0x18, 0xac,
|
||||
0x02, 0x20, 0x01, 0x28, 0x0e, 0x32, 0x19, 0x2e, 0x74, 0x65, 0x73, 0x74, 0x2e, 0x50, 0x72, 0x69,
|
||||
0x6d, 0x69, 0x74, 0x69, 0x76, 0x65, 0x73, 0x2e, 0x53, 0x6f, 0x6d, 0x65, 0x45, 0x6e, 0x75, 0x6d,
|
||||
0x52, 0x06, 0x66, 0x69, 0x65, 0x6c, 0x64, 0x48, 0x22, 0x3c, 0x0a, 0x08, 0x53, 0x6f, 0x6d, 0x65,
|
||||
0x45, 0x6e, 0x75, 0x6d, 0x12, 0x0b, 0x0a, 0x07, 0x55, 0x4e, 0x4b, 0x4e, 0x4f, 0x57, 0x4e, 0x10,
|
||||
0x00, 0x12, 0x0c, 0x0a, 0x08, 0x50, 0x4f, 0x53, 0x49, 0x54, 0x49, 0x56, 0x45, 0x10, 0x01, 0x12,
|
||||
0x15, 0x0a, 0x08, 0x4e, 0x45, 0x47, 0x41, 0x54, 0x49, 0x56, 0x45, 0x10, 0xff, 0xff, 0xff, 0xff,
|
||||
0xff, 0xff, 0xff, 0xff, 0xff, 0x01, 0x22, 0xc4, 0x01, 0x0a, 0x0d, 0x52, 0x65, 0x70, 0x50, 0x72,
|
||||
0x69, 0x6d, 0x69, 0x74, 0x69, 0x76, 0x65, 0x73, 0x12, 0x17, 0x0a, 0x07, 0x66, 0x69, 0x65, 0x6c,
|
||||
0x64, 0x5f, 0x61, 0x18, 0x01, 0x20, 0x03, 0x28, 0x0c, 0x52, 0x06, 0x66, 0x69, 0x65, 0x6c, 0x64,
|
||||
0x41, 0x12, 0x17, 0x0a, 0x07, 0x66, 0x69, 0x65, 0x6c, 0x64, 0x5f, 0x62, 0x18, 0x02, 0x20, 0x03,
|
||||
0x28, 0x09, 0x52, 0x06, 0x66, 0x69, 0x65, 0x6c, 0x64, 0x42, 0x12, 0x17, 0x0a, 0x07, 0x66, 0x69,
|
||||
0x65, 0x6c, 0x64, 0x5f, 0x63, 0x18, 0x03, 0x20, 0x03, 0x28, 0x05, 0x52, 0x06, 0x66, 0x69, 0x65,
|
||||
0x6c, 0x64, 0x43, 0x12, 0x17, 0x0a, 0x07, 0x66, 0x69, 0x65, 0x6c, 0x64, 0x5f, 0x64, 0x18, 0x04,
|
||||
0x20, 0x03, 0x28, 0x0d, 0x52, 0x06, 0x66, 0x69, 0x65, 0x6c, 0x64, 0x44, 0x12, 0x17, 0x0a, 0x07,
|
||||
0x66, 0x69, 0x65, 0x6c, 0x64, 0x5f, 0x65, 0x18, 0x05, 0x20, 0x03, 0x28, 0x03, 0x52, 0x06, 0x66,
|
||||
0x69, 0x65, 0x6c, 0x64, 0x45, 0x12, 0x17, 0x0a, 0x07, 0x66, 0x69, 0x65, 0x6c, 0x64, 0x5f, 0x66,
|
||||
0x18, 0x06, 0x20, 0x03, 0x28, 0x04, 0x52, 0x06, 0x66, 0x69, 0x65, 0x6c, 0x64, 0x46, 0x12, 0x1d,
|
||||
0x0a, 0x08, 0x66, 0x69, 0x65, 0x6c, 0x64, 0x5f, 0x66, 0x75, 0x18, 0x07, 0x20, 0x03, 0x28, 0x04,
|
||||
0x42, 0x02, 0x10, 0x00, 0x52, 0x07, 0x66, 0x69, 0x65, 0x6c, 0x64, 0x46, 0x75, 0x42, 0x11, 0x5a,
|
||||
0x0f, 0x75, 0x74, 0x69, 0x6c, 0x2f, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x2f, 0x74, 0x65, 0x73, 0x74,
|
||||
0x62, 0x06, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x33,
|
||||
0x52, 0x06, 0x66, 0x69, 0x65, 0x6c, 0x64, 0x48, 0x12, 0x1c, 0x0a, 0x08, 0x66, 0x69, 0x65, 0x6c,
|
||||
0x64, 0x5f, 0x6d, 0x61, 0x18, 0x91, 0x03, 0x20, 0x01, 0x28, 0x0c, 0x48, 0x00, 0x52, 0x07, 0x66,
|
||||
0x69, 0x65, 0x6c, 0x64, 0x4d, 0x61, 0x12, 0x1c, 0x0a, 0x08, 0x66, 0x69, 0x65, 0x6c, 0x64, 0x5f,
|
||||
0x6d, 0x65, 0x18, 0x92, 0x03, 0x20, 0x01, 0x28, 0x0d, 0x48, 0x00, 0x52, 0x07, 0x66, 0x69, 0x65,
|
||||
0x6c, 0x64, 0x4d, 0x65, 0x12, 0x34, 0x0a, 0x09, 0x66, 0x69, 0x65, 0x6c, 0x64, 0x5f, 0x61, 0x75,
|
||||
0x78, 0x18, 0x93, 0x03, 0x20, 0x01, 0x28, 0x0b, 0x32, 0x14, 0x2e, 0x74, 0x65, 0x73, 0x74, 0x2e,
|
||||
0x50, 0x72, 0x69, 0x6d, 0x69, 0x74, 0x69, 0x76, 0x65, 0x73, 0x2e, 0x41, 0x75, 0x78, 0x48, 0x00,
|
||||
0x52, 0x08, 0x66, 0x69, 0x65, 0x6c, 0x64, 0x41, 0x75, 0x78, 0x1a, 0x26, 0x0a, 0x03, 0x41, 0x75,
|
||||
0x78, 0x12, 0x1f, 0x0a, 0x0b, 0x69, 0x6e, 0x6e, 0x65, 0x72, 0x5f, 0x66, 0x69, 0x65, 0x6c, 0x64,
|
||||
0x18, 0x01, 0x20, 0x01, 0x28, 0x0d, 0x52, 0x0a, 0x69, 0x6e, 0x6e, 0x65, 0x72, 0x46, 0x69, 0x65,
|
||||
0x6c, 0x64, 0x22, 0x3c, 0x0a, 0x08, 0x53, 0x6f, 0x6d, 0x65, 0x45, 0x6e, 0x75, 0x6d, 0x12, 0x0b,
|
||||
0x0a, 0x07, 0x55, 0x4e, 0x4b, 0x4e, 0x4f, 0x57, 0x4e, 0x10, 0x00, 0x12, 0x0c, 0x0a, 0x08, 0x50,
|
||||
0x4f, 0x53, 0x49, 0x54, 0x49, 0x56, 0x45, 0x10, 0x01, 0x12, 0x15, 0x0a, 0x08, 0x4e, 0x45, 0x47,
|
||||
0x41, 0x54, 0x49, 0x56, 0x45, 0x10, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0x01,
|
||||
0x42, 0x09, 0x0a, 0x07, 0x66, 0x69, 0x65, 0x6c, 0x64, 0x5f, 0x6d, 0x22, 0xc4, 0x01, 0x0a, 0x0d,
|
||||
0x52, 0x65, 0x70, 0x50, 0x72, 0x69, 0x6d, 0x69, 0x74, 0x69, 0x76, 0x65, 0x73, 0x12, 0x17, 0x0a,
|
||||
0x07, 0x66, 0x69, 0x65, 0x6c, 0x64, 0x5f, 0x61, 0x18, 0x01, 0x20, 0x03, 0x28, 0x0c, 0x52, 0x06,
|
||||
0x66, 0x69, 0x65, 0x6c, 0x64, 0x41, 0x12, 0x17, 0x0a, 0x07, 0x66, 0x69, 0x65, 0x6c, 0x64, 0x5f,
|
||||
0x62, 0x18, 0x02, 0x20, 0x03, 0x28, 0x09, 0x52, 0x06, 0x66, 0x69, 0x65, 0x6c, 0x64, 0x42, 0x12,
|
||||
0x17, 0x0a, 0x07, 0x66, 0x69, 0x65, 0x6c, 0x64, 0x5f, 0x63, 0x18, 0x03, 0x20, 0x03, 0x28, 0x05,
|
||||
0x52, 0x06, 0x66, 0x69, 0x65, 0x6c, 0x64, 0x43, 0x12, 0x17, 0x0a, 0x07, 0x66, 0x69, 0x65, 0x6c,
|
||||
0x64, 0x5f, 0x64, 0x18, 0x04, 0x20, 0x03, 0x28, 0x0d, 0x52, 0x06, 0x66, 0x69, 0x65, 0x6c, 0x64,
|
||||
0x44, 0x12, 0x17, 0x0a, 0x07, 0x66, 0x69, 0x65, 0x6c, 0x64, 0x5f, 0x65, 0x18, 0x05, 0x20, 0x03,
|
||||
0x28, 0x03, 0x52, 0x06, 0x66, 0x69, 0x65, 0x6c, 0x64, 0x45, 0x12, 0x17, 0x0a, 0x07, 0x66, 0x69,
|
||||
0x65, 0x6c, 0x64, 0x5f, 0x66, 0x18, 0x06, 0x20, 0x03, 0x28, 0x04, 0x52, 0x06, 0x66, 0x69, 0x65,
|
||||
0x6c, 0x64, 0x46, 0x12, 0x1d, 0x0a, 0x08, 0x66, 0x69, 0x65, 0x6c, 0x64, 0x5f, 0x66, 0x75, 0x18,
|
||||
0x07, 0x20, 0x03, 0x28, 0x04, 0x42, 0x02, 0x10, 0x00, 0x52, 0x07, 0x66, 0x69, 0x65, 0x6c, 0x64,
|
||||
0x46, 0x75, 0x42, 0x11, 0x5a, 0x0f, 0x75, 0x74, 0x69, 0x6c, 0x2f, 0x70, 0x72, 0x6f, 0x74, 0x6f,
|
||||
0x2f, 0x74, 0x65, 0x73, 0x74, 0x62, 0x06, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x33,
|
||||
}
|
||||
|
||||
var (
|
||||
|
@ -350,19 +463,21 @@ func file_util_proto_test_test_proto_rawDescGZIP() []byte {
|
|||
}
|
||||
|
||||
var file_util_proto_test_test_proto_enumTypes = make([]protoimpl.EnumInfo, 1)
|
||||
var file_util_proto_test_test_proto_msgTypes = make([]protoimpl.MessageInfo, 2)
|
||||
var file_util_proto_test_test_proto_msgTypes = make([]protoimpl.MessageInfo, 3)
|
||||
var file_util_proto_test_test_proto_goTypes = []interface{}{
|
||||
(Primitives_SomeEnum)(0), // 0: test.Primitives.SomeEnum
|
||||
(*Primitives)(nil), // 1: test.Primitives
|
||||
(*RepPrimitives)(nil), // 2: test.RepPrimitives
|
||||
(*Primitives_Aux)(nil), // 3: test.Primitives.Aux
|
||||
}
|
||||
var file_util_proto_test_test_proto_depIdxs = []int32{
|
||||
0, // 0: test.Primitives.field_h:type_name -> test.Primitives.SomeEnum
|
||||
1, // [1:1] is the sub-list for method output_type
|
||||
1, // [1:1] is the sub-list for method input_type
|
||||
1, // [1:1] is the sub-list for extension type_name
|
||||
1, // [1:1] is the sub-list for extension extendee
|
||||
0, // [0:1] is the sub-list for field type_name
|
||||
3, // 1: test.Primitives.field_aux:type_name -> test.Primitives.Aux
|
||||
2, // [2:2] is the sub-list for method output_type
|
||||
2, // [2:2] is the sub-list for method input_type
|
||||
2, // [2:2] is the sub-list for extension type_name
|
||||
2, // [2:2] is the sub-list for extension extendee
|
||||
0, // [0:2] is the sub-list for field type_name
|
||||
}
|
||||
|
||||
func init() { file_util_proto_test_test_proto_init() }
|
||||
|
@ -395,6 +510,23 @@ func file_util_proto_test_test_proto_init() {
|
|||
return nil
|
||||
}
|
||||
}
|
||||
file_util_proto_test_test_proto_msgTypes[2].Exporter = func(v interface{}, i int) interface{} {
|
||||
switch v := v.(*Primitives_Aux); i {
|
||||
case 0:
|
||||
return &v.state
|
||||
case 1:
|
||||
return &v.sizeCache
|
||||
case 2:
|
||||
return &v.unknownFields
|
||||
default:
|
||||
return nil
|
||||
}
|
||||
}
|
||||
}
|
||||
file_util_proto_test_test_proto_msgTypes[0].OneofWrappers = []interface{}{
|
||||
(*Primitives_FieldMa)(nil),
|
||||
(*Primitives_FieldMe)(nil),
|
||||
(*Primitives_FieldAux)(nil),
|
||||
}
|
||||
type x struct{}
|
||||
out := protoimpl.TypeBuilder{
|
||||
|
@ -402,7 +534,7 @@ func file_util_proto_test_test_proto_init() {
|
|||
GoPackagePath: reflect.TypeOf(x{}).PkgPath(),
|
||||
RawDescriptor: file_util_proto_test_test_proto_rawDesc,
|
||||
NumEnums: 1,
|
||||
NumMessages: 2,
|
||||
NumMessages: 3,
|
||||
NumExtensions: 0,
|
||||
NumServices: 0,
|
||||
},
|
||||
|
|
|
@ -22,6 +22,14 @@ message Primitives {
|
|||
NEGATIVE = -1;
|
||||
}
|
||||
SomeEnum field_h = 300;
|
||||
|
||||
message Aux { uint32 inner_field = 1; }
|
||||
|
||||
oneof field_m {
|
||||
bytes field_ma = 401;
|
||||
uint32 field_me = 402;
|
||||
Aux field_aux = 403;
|
||||
}
|
||||
}
|
||||
|
||||
message RepPrimitives {
|
||||
|
|
|
@ -126,29 +126,24 @@ func emitOneofGettersSetters(g *protogen.GeneratedFile, msg *protogen.Message, f
|
|||
// For some reason protoc generates different code for oneof message/non-message fields:
|
||||
// 1. For message we have 2 level struct wrapping and setters use inner type.
|
||||
// 2. For other types we also have 2 level wrapping, but setters use outer type.
|
||||
ft := fieldType(g, ff)
|
||||
|
||||
g.P("func (x *", msg.GoIdent.GoName, ") Get", ff.GoName, "() ", ft, " {")
|
||||
g.P("if xx, ok := x.Get", ff.Oneof.GoName, "().(*", ff.GoIdent, "); ok { return xx.", ff.GoName, " }")
|
||||
g.P("return ", fieldDefaultValue(ff))
|
||||
g.P("}")
|
||||
|
||||
if ff.Desc.Kind() == protoreflect.MessageKind {
|
||||
ft := fieldType(g, ff)
|
||||
|
||||
g.P("func (x *", msg.GoIdent.GoName, ") Get", ff.GoName, "() ", ft, " {")
|
||||
g.P("if xx, ok := x.Get", ff.Oneof.GoName, "().(*", ff.GoIdent, "); ok { return xx.", ff.GoName, " }")
|
||||
g.P("return nil")
|
||||
g.P("}")
|
||||
|
||||
g.P("func (x *", msg.GoIdent.GoName, ") Set", ff.GoName, "(v ", ft, ") {")
|
||||
g.P("x.", ff.Oneof.GoName, " = &", ff.GoIdent, "{", ff.GoName, ": v}")
|
||||
g.P("}")
|
||||
} else {
|
||||
g.P("func (x *", msg.GoIdent.GoName, ") Get", ff.GoName, "() *", ff.GoIdent, " {")
|
||||
g.P("if xx, ok := x.Get", ff.Oneof.GoName, "().(*", ff.GoIdent, "); ok { return xx }")
|
||||
g.P("return nil")
|
||||
g.P("}")
|
||||
|
||||
g.P("func (x *", msg.GoIdent.GoName, ") Set", ff.GoName, "(v *", ff.GoIdent, ") {")
|
||||
g.P("x.", ff.Oneof.GoName, " = v")
|
||||
g.P("}")
|
||||
|
||||
ft := fieldType(g, ff)
|
||||
emitGetterSetter(g, ff.GoIdent.GoName, ff.GoName, ft.String(), "nil")
|
||||
emitGetterSetter(g, ff.GoIdent.GoName, ff.GoName, ft.String(), fieldDefaultValue(ff))
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -159,8 +159,6 @@ func emitJSONMarshal(g *protogen.GeneratedFile, msg *protogen.Message) {
|
|||
g.P("case *", ff.GoIdent, ":")
|
||||
emitJSONFieldWrite(g, ff, "xx", i == 0)
|
||||
}
|
||||
g.P("default:")
|
||||
g.P(`out.RawString("null")`)
|
||||
g.P("}")
|
||||
continue
|
||||
}
|
||||
|
|
|
@ -2,8 +2,6 @@ package main
|
|||
|
||||
import (
|
||||
"flag"
|
||||
"fmt"
|
||||
"os"
|
||||
|
||||
"git.frostfs.info/TrueCloudLab/frostfs-api-go/v2/util/protogen/internalgengo"
|
||||
"google.golang.org/protobuf/compiler/protogen"
|
||||
|
@ -12,18 +10,10 @@ import (
|
|||
func main() {
|
||||
var flags flag.FlagSet
|
||||
genFuzz := flags.Bool("fuzz", false, "generate fuzz tests")
|
||||
yamlConfigPath := flags.String("config", "", "path to the configuration")
|
||||
|
||||
protogen.Options{
|
||||
ParamFunc: flags.Set,
|
||||
}.Run(func(gen *protogen.Plugin) error {
|
||||
if *yamlConfigPath != "" {
|
||||
s, e := os.Getwd()
|
||||
fmt.Fprintln(os.Stderr, s, e)
|
||||
data, err := os.ReadFile(*yamlConfigPath)
|
||||
fmt.Fprintln(os.Stderr, string(data), err)
|
||||
}
|
||||
|
||||
for _, f := range gen.Files {
|
||||
if f.Generate {
|
||||
internalgengo.GenerateFile(gen, f)
|
||||
|
|
Loading…
Add table
Reference in a new issue