go_zero

package
v2.1.36 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Feb 2, 2026 License: Apache-2.0 Imports: 9 Imported by: 0

Documentation

Index

Constants

View Source
const (
	UserService_GetById_FullMethodName  = "/UserService/GetById"
	UserService_GetById1_FullMethodName = "/UserService/GetById1"
)

Variables

View Source
var (
	Gender_name = map[int32]string{
		0: "GENDER_UNKNOWN",
		1: "GENDER_MALE",
		2: "GENDER_FEMALE",
	}
	Gender_value = map[string]int32{
		"GENDER_UNKNOWN": 0,
		"GENDER_MALE":    1,
		"GENDER_FEMALE":  2,
	}
)

Enum value maps for Gender.

View Source
var File_user_proto protoreflect.FileDescriptor
View Source
var UserService_ServiceDesc = grpc.ServiceDesc{
	ServiceName: "UserService",
	HandlerType: (*UserServiceServer)(nil),
	Methods: []grpc.MethodDesc{
		{
			MethodName: "GetById",
			Handler:    _UserService_GetById_Handler,
		},
		{
			MethodName: "GetById1",
			Handler:    _UserService_GetById1_Handler,
		},
	},
	Streams:  []grpc.StreamDesc{},
	Metadata: "user.proto",
}

UserService_ServiceDesc is the grpc.ServiceDesc for UserService service. It's only intended for direct use with grpc.RegisterService, and not to be introspected or modified (even as a copy)

Functions

func RegisterUserServiceServer

func RegisterUserServiceServer(s grpc.ServiceRegistrar, srv UserServiceServer)

Types

type Address

type Address struct {
	Province string `protobuf:"bytes,1,opt,name=province,proto3" json:"province,omitempty"`
	City     string `protobuf:"bytes,2,opt,name=city,proto3" json:"city,omitempty"`
	// contains filtered or unexported fields
}

匿名嵌套结构

func (*Address) Descriptor deprecated

func (*Address) Descriptor() ([]byte, []int)

Deprecated: Use Address.ProtoReflect.Descriptor instead.

func (*Address) GetCity

func (x *Address) GetCity() string

func (*Address) GetProvince

func (x *Address) GetProvince() string

func (*Address) ProtoMessage

func (*Address) ProtoMessage()

func (*Address) ProtoReflect

func (x *Address) ProtoReflect() protoreflect.Message

func (*Address) Reset

func (x *Address) Reset()

func (*Address) String

func (x *Address) String() string

type Gender

type Gender int32

枚举类型

const (
	Gender_GENDER_UNKNOWN Gender = 0 // 默认值,从0开始
	Gender_GENDER_MALE    Gender = 1
	Gender_GENDER_FEMALE  Gender = 2
)

func (Gender) Descriptor

func (Gender) Descriptor() protoreflect.EnumDescriptor

func (Gender) Enum

func (x Gender) Enum() *Gender

func (Gender) EnumDescriptor deprecated

func (Gender) EnumDescriptor() ([]byte, []int)

Deprecated: Use Gender.Descriptor instead.

func (Gender) Number

func (x Gender) Number() protoreflect.EnumNumber

func (Gender) String

func (x Gender) String() string

func (Gender) Type

func (Gender) Type() protoreflect.EnumType

type GetByIdRequest

type GetByIdRequest struct {
	Id int64 `protobuf:"varint,1,opt,name=id,proto3" json:"id,omitempty"`
	// contains filtered or unexported fields
}

定义输入

func (*GetByIdRequest) Descriptor deprecated

func (*GetByIdRequest) Descriptor() ([]byte, []int)

Deprecated: Use GetByIdRequest.ProtoReflect.Descriptor instead.

func (*GetByIdRequest) GetId

func (x *GetByIdRequest) GetId() int64

func (*GetByIdRequest) ProtoMessage

func (*GetByIdRequest) ProtoMessage()

func (*GetByIdRequest) ProtoReflect

func (x *GetByIdRequest) ProtoReflect() protoreflect.Message

func (*GetByIdRequest) Reset

func (x *GetByIdRequest) Reset()

func (*GetByIdRequest) String

func (x *GetByIdRequest) String() string

type GetByIdResponse

type GetByIdResponse struct {
	User *User `protobuf:"bytes,1,opt,name=user,proto3" json:"user,omitempty"`
	// contains filtered or unexported fields
}

定义输出

func (*GetByIdResponse) Descriptor deprecated

func (*GetByIdResponse) Descriptor() ([]byte, []int)

Deprecated: Use GetByIdResponse.ProtoReflect.Descriptor instead.

func (*GetByIdResponse) GetUser

func (x *GetByIdResponse) GetUser() *User

func (*GetByIdResponse) ProtoMessage

func (*GetByIdResponse) ProtoMessage()

func (*GetByIdResponse) ProtoReflect

func (x *GetByIdResponse) ProtoReflect() protoreflect.Message

func (*GetByIdResponse) Reset

func (x *GetByIdResponse) Reset()

func (*GetByIdResponse) String

func (x *GetByIdResponse) String() string

type Service

type Service struct {
	UnimplementedUserServiceServer // 继承,实现service的时候【必须强制组合mented】,也是为了向后兼容
	Name                           string
}

Service 实现 service

func (*Service) GetById

func (s *Service) GetById(ctx context.Context, request *GetByIdRequest) (*GetByIdResponse, error)

func (*Service) GetById1

func (s *Service) GetById1(ctx context.Context, request *GetByIdRequest) (*GetByIdResponse, error)

type UnimplementedUserServiceServer

type UnimplementedUserServiceServer struct{}

UnimplementedUserServiceServer must be embedded to have forward compatible implementations.

NOTE: this should be embedded by value instead of pointer to avoid a nil pointer dereference when methods are called.

func (UnimplementedUserServiceServer) GetById

func (UnimplementedUserServiceServer) GetById1

type UnsafeUserServiceServer

type UnsafeUserServiceServer interface {
	// contains filtered or unexported methods
}

UnsafeUserServiceServer may be embedded to opt out of forward compatibility for this service. Use of this interface is not recommended, as added methods to UserServiceServer will result in compilation errors.

type User

type User struct {
	Id   int64  `protobuf:"varint,1,opt,name=id,proto3" json:"id,omitempty"`
	Name string `protobuf:"bytes,2,opt,name=name,proto3" json:"name,omitempty"`
	// 编号可以不连续【即便删除字段,也不要复用被删除的编号】
	Avatar string `protobuf:"bytes,4,opt,name=avatar,proto3" json:"avatar,omitempty"`
	// protobuf 也是支持map结构和的
	Attributes map[string]string `` // map<key,value>
	/* 147-byte string literal not displayed */
	Nicknames []string `protobuf:"bytes,6,rep,name=nicknames,proto3" json:"nicknames,omitempty"` // repeated表示数组
	Age       *int32   `protobuf:"varint,7,opt,name=age,proto3,oneof" json:"age,omitempty"`      // optional表示可选字段
	Address   *Address `protobuf:"bytes,8,opt,name=address,proto3" json:"address,omitempty"`     // 匿名嵌套结构
	// Types that are valid to be assigned to Contacts:
	//
	//	*User_Email
	//	*User_Phone
	Contacts isUser_Contacts `protobuf_oneof:"contacts"`
	Gender   Gender          `protobuf:"varint,11,opt,name=gender,proto3,enum=Gender" json:"gender,omitempty"` // 枚举类型
	// contains filtered or unexported fields
}

定义一个消息体【1、2、3、是编号,编号只能从1开始】

func (*User) Descriptor deprecated

func (*User) Descriptor() ([]byte, []int)

Deprecated: Use User.ProtoReflect.Descriptor instead.

func (*User) GetAddress

func (x *User) GetAddress() *Address

func (*User) GetAge

func (x *User) GetAge() int32

func (*User) GetAttributes

func (x *User) GetAttributes() map[string]string

func (*User) GetAvatar

func (x *User) GetAvatar() string

func (*User) GetContacts

func (x *User) GetContacts() isUser_Contacts

func (*User) GetEmail

func (x *User) GetEmail() string

func (*User) GetGender

func (x *User) GetGender() Gender

func (*User) GetId

func (x *User) GetId() int64

func (*User) GetName

func (x *User) GetName() string

func (*User) GetNicknames

func (x *User) GetNicknames() []string

func (*User) GetPhone

func (x *User) GetPhone() string

func (*User) ProtoMessage

func (*User) ProtoMessage()

func (*User) ProtoReflect

func (x *User) ProtoReflect() protoreflect.Message

func (*User) Reset

func (x *User) Reset()

func (*User) String

func (x *User) String() string

type UserServiceClient

type UserServiceClient interface {
	GetById(ctx context.Context, in *GetByIdRequest, opts ...grpc.CallOption) (*GetByIdResponse, error)
	GetById1(ctx context.Context, in *GetByIdRequest, opts ...grpc.CallOption) (*GetByIdResponse, error)
}

UserServiceClient is the client API for UserService service.

For semantics around ctx use and closing/ending streaming RPCs, please refer to https://pkg.go.dev/google.golang.org/grpc/?tab=doc#ClientConn.NewStream.

定义一个服务接口、service

func NewUserServiceClient

func NewUserServiceClient(cc grpc.ClientConnInterface) UserServiceClient

type UserServiceServer

type UserServiceServer interface {
	GetById(context.Context, *GetByIdRequest) (*GetByIdResponse, error)
	GetById1(context.Context, *GetByIdRequest) (*GetByIdResponse, error)
	// contains filtered or unexported methods
}

UserServiceServer is the server API for UserService service. All implementations must embed UnimplementedUserServiceServer for forward compatibility.

定义一个服务接口、service

type User_Email

type User_Email struct {
	Email string `protobuf:"bytes,9,opt,name=email,proto3,oneof"`
}

type User_Phone

type User_Phone struct {
	Phone string `protobuf:"bytes,10,opt,name=phone,proto3,oneof"`
}

Source Files

  • service.go
  • user.pb.go
  • user_grpc.pb.go

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL