省区数据已经完整, 完成基本的接口
This commit is contained in:
parent
27c0277ba8
commit
c95dbc8f33
6
base.go
6
base.go
|
@ -146,3 +146,9 @@ func LoadGob(fname string, v IKeyList) {
|
|||
func GetRandomKey(v IKeyList) interface{} {
|
||||
return v.GetKeys()[rand.Intn(v.GetLength())]
|
||||
}
|
||||
|
||||
// GetRandomKeyByList get ikeylist key by random
|
||||
func GetRandomKeyByList(v interface{}) interface{} {
|
||||
sli := reflect.ValueOf(v)
|
||||
return sli.Index(rand.Intn(sli.Len())).Interface()
|
||||
}
|
||||
|
|
244
base.pb.go
244
base.pb.go
|
@ -1,200 +1,112 @@
|
|||
// Code generated by protoc-gen-go. DO NOT EDIT.
|
||||
// versions:
|
||||
// protoc-gen-go v1.22.0
|
||||
// protoc (unknown)
|
||||
// source: base.proto
|
||||
|
||||
package main
|
||||
|
||||
import (
|
||||
fmt "fmt"
|
||||
proto "github.com/golang/protobuf/proto"
|
||||
protoreflect "google.golang.org/protobuf/reflect/protoreflect"
|
||||
protoimpl "google.golang.org/protobuf/runtime/protoimpl"
|
||||
reflect "reflect"
|
||||
sync "sync"
|
||||
math "math"
|
||||
)
|
||||
|
||||
const (
|
||||
// Verify that this generated code is sufficiently up-to-date.
|
||||
_ = protoimpl.EnforceVersion(20 - protoimpl.MinVersion)
|
||||
// Verify that runtime/protoimpl is sufficiently up-to-date.
|
||||
_ = protoimpl.EnforceVersion(protoimpl.MaxVersion - 20)
|
||||
)
|
||||
// Reference imports to suppress errors if they are not otherwise used.
|
||||
var _ = proto.Marshal
|
||||
var _ = fmt.Errorf
|
||||
var _ = math.Inf
|
||||
|
||||
// This is a compile-time assertion that a sufficiently up-to-date version
|
||||
// of the legacy proto package is being used.
|
||||
const _ = proto.ProtoPackageIsVersion4
|
||||
// This is a compile-time assertion to ensure that this generated file
|
||||
// is compatible with the proto package it is being compiled against.
|
||||
// A compilation error at this line likely means your copy of the
|
||||
// proto package needs to be updated.
|
||||
const _ = proto.ProtoPackageIsVersion3 // please upgrade the proto package
|
||||
|
||||
// The request message containing the user's name.
|
||||
type Request struct {
|
||||
state protoimpl.MessageState
|
||||
sizeCache protoimpl.SizeCache
|
||||
unknownFields protoimpl.UnknownFields
|
||||
XXX_NoUnkeyedLiteral struct{} `json:"-"`
|
||||
XXX_unrecognized []byte `json:"-"`
|
||||
XXX_sizecache int32 `json:"-"`
|
||||
}
|
||||
|
||||
func (x *Request) Reset() {
|
||||
*x = Request{}
|
||||
if protoimpl.UnsafeEnabled {
|
||||
mi := &file_base_proto_msgTypes[0]
|
||||
ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x))
|
||||
ms.StoreMessageInfo(mi)
|
||||
}
|
||||
}
|
||||
|
||||
func (x *Request) String() string {
|
||||
return protoimpl.X.MessageStringOf(x)
|
||||
}
|
||||
|
||||
func (*Request) ProtoMessage() {}
|
||||
|
||||
func (x *Request) ProtoReflect() protoreflect.Message {
|
||||
mi := &file_base_proto_msgTypes[0]
|
||||
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 Request.ProtoReflect.Descriptor instead.
|
||||
func (m *Request) Reset() { *m = Request{} }
|
||||
func (m *Request) String() string { return proto.CompactTextString(m) }
|
||||
func (*Request) ProtoMessage() {}
|
||||
func (*Request) Descriptor() ([]byte, []int) {
|
||||
return file_base_proto_rawDescGZIP(), []int{0}
|
||||
return fileDescriptor_db1b6b0986796150, []int{0}
|
||||
}
|
||||
|
||||
func (m *Request) XXX_Unmarshal(b []byte) error {
|
||||
return xxx_messageInfo_Request.Unmarshal(m, b)
|
||||
}
|
||||
func (m *Request) XXX_Marshal(b []byte, deterministic bool) ([]byte, error) {
|
||||
return xxx_messageInfo_Request.Marshal(b, m, deterministic)
|
||||
}
|
||||
func (m *Request) XXX_Merge(src proto.Message) {
|
||||
xxx_messageInfo_Request.Merge(m, src)
|
||||
}
|
||||
func (m *Request) XXX_Size() int {
|
||||
return xxx_messageInfo_Request.Size(m)
|
||||
}
|
||||
func (m *Request) XXX_DiscardUnknown() {
|
||||
xxx_messageInfo_Request.DiscardUnknown(m)
|
||||
}
|
||||
|
||||
var xxx_messageInfo_Request proto.InternalMessageInfo
|
||||
|
||||
// The response message containing the greetings
|
||||
type Reply struct {
|
||||
state protoimpl.MessageState
|
||||
sizeCache protoimpl.SizeCache
|
||||
unknownFields protoimpl.UnknownFields
|
||||
|
||||
Message string `protobuf:"bytes,1,opt,name=message,proto3" json:"message,omitempty"`
|
||||
Message string `protobuf:"bytes,1,opt,name=message,proto3" json:"message,omitempty"`
|
||||
XXX_NoUnkeyedLiteral struct{} `json:"-"`
|
||||
XXX_unrecognized []byte `json:"-"`
|
||||
XXX_sizecache int32 `json:"-"`
|
||||
}
|
||||
|
||||
func (x *Reply) Reset() {
|
||||
*x = Reply{}
|
||||
if protoimpl.UnsafeEnabled {
|
||||
mi := &file_base_proto_msgTypes[1]
|
||||
ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x))
|
||||
ms.StoreMessageInfo(mi)
|
||||
}
|
||||
}
|
||||
|
||||
func (x *Reply) String() string {
|
||||
return protoimpl.X.MessageStringOf(x)
|
||||
}
|
||||
|
||||
func (*Reply) ProtoMessage() {}
|
||||
|
||||
func (x *Reply) ProtoReflect() protoreflect.Message {
|
||||
mi := &file_base_proto_msgTypes[1]
|
||||
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 Reply.ProtoReflect.Descriptor instead.
|
||||
func (m *Reply) Reset() { *m = Reply{} }
|
||||
func (m *Reply) String() string { return proto.CompactTextString(m) }
|
||||
func (*Reply) ProtoMessage() {}
|
||||
func (*Reply) Descriptor() ([]byte, []int) {
|
||||
return file_base_proto_rawDescGZIP(), []int{1}
|
||||
return fileDescriptor_db1b6b0986796150, []int{1}
|
||||
}
|
||||
|
||||
func (x *Reply) GetMessage() string {
|
||||
if x != nil {
|
||||
return x.Message
|
||||
func (m *Reply) XXX_Unmarshal(b []byte) error {
|
||||
return xxx_messageInfo_Reply.Unmarshal(m, b)
|
||||
}
|
||||
func (m *Reply) XXX_Marshal(b []byte, deterministic bool) ([]byte, error) {
|
||||
return xxx_messageInfo_Reply.Marshal(b, m, deterministic)
|
||||
}
|
||||
func (m *Reply) XXX_Merge(src proto.Message) {
|
||||
xxx_messageInfo_Reply.Merge(m, src)
|
||||
}
|
||||
func (m *Reply) XXX_Size() int {
|
||||
return xxx_messageInfo_Reply.Size(m)
|
||||
}
|
||||
func (m *Reply) XXX_DiscardUnknown() {
|
||||
xxx_messageInfo_Reply.DiscardUnknown(m)
|
||||
}
|
||||
|
||||
var xxx_messageInfo_Reply proto.InternalMessageInfo
|
||||
|
||||
func (m *Reply) GetMessage() string {
|
||||
if m != nil {
|
||||
return m.Message
|
||||
}
|
||||
return ""
|
||||
}
|
||||
|
||||
var File_base_proto protoreflect.FileDescriptor
|
||||
|
||||
var file_base_proto_rawDesc = []byte{
|
||||
0x0a, 0x0a, 0x62, 0x61, 0x73, 0x65, 0x2e, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x12, 0x04, 0x6d, 0x61,
|
||||
0x69, 0x6e, 0x22, 0x09, 0x0a, 0x07, 0x52, 0x65, 0x71, 0x75, 0x65, 0x73, 0x74, 0x22, 0x21, 0x0a,
|
||||
0x05, 0x52, 0x65, 0x70, 0x6c, 0x79, 0x12, 0x18, 0x0a, 0x07, 0x6d, 0x65, 0x73, 0x73, 0x61, 0x67,
|
||||
0x65, 0x18, 0x01, 0x20, 0x01, 0x28, 0x09, 0x52, 0x07, 0x6d, 0x65, 0x73, 0x73, 0x61, 0x67, 0x65,
|
||||
0x42, 0x08, 0x5a, 0x06, 0x2e, 0x3b, 0x6d, 0x61, 0x69, 0x6e, 0x62, 0x06, 0x70, 0x72, 0x6f, 0x74,
|
||||
0x6f, 0x33,
|
||||
func init() {
|
||||
proto.RegisterType((*Request)(nil), "main.Request")
|
||||
proto.RegisterType((*Reply)(nil), "main.Reply")
|
||||
}
|
||||
|
||||
var (
|
||||
file_base_proto_rawDescOnce sync.Once
|
||||
file_base_proto_rawDescData = file_base_proto_rawDesc
|
||||
)
|
||||
|
||||
func file_base_proto_rawDescGZIP() []byte {
|
||||
file_base_proto_rawDescOnce.Do(func() {
|
||||
file_base_proto_rawDescData = protoimpl.X.CompressGZIP(file_base_proto_rawDescData)
|
||||
})
|
||||
return file_base_proto_rawDescData
|
||||
func init() {
|
||||
proto.RegisterFile("base.proto", fileDescriptor_db1b6b0986796150)
|
||||
}
|
||||
|
||||
var file_base_proto_msgTypes = make([]protoimpl.MessageInfo, 2)
|
||||
var file_base_proto_goTypes = []interface{}{
|
||||
(*Request)(nil), // 0: main.Request
|
||||
(*Reply)(nil), // 1: main.Reply
|
||||
}
|
||||
var file_base_proto_depIdxs = []int32{
|
||||
0, // [0:0] is the sub-list for method output_type
|
||||
0, // [0:0] is the sub-list for method input_type
|
||||
0, // [0:0] is the sub-list for extension type_name
|
||||
0, // [0:0] is the sub-list for extension extendee
|
||||
0, // [0:0] is the sub-list for field type_name
|
||||
}
|
||||
|
||||
func init() { file_base_proto_init() }
|
||||
func file_base_proto_init() {
|
||||
if File_base_proto != nil {
|
||||
return
|
||||
}
|
||||
if !protoimpl.UnsafeEnabled {
|
||||
file_base_proto_msgTypes[0].Exporter = func(v interface{}, i int) interface{} {
|
||||
switch v := v.(*Request); i {
|
||||
case 0:
|
||||
return &v.state
|
||||
case 1:
|
||||
return &v.sizeCache
|
||||
case 2:
|
||||
return &v.unknownFields
|
||||
default:
|
||||
return nil
|
||||
}
|
||||
}
|
||||
file_base_proto_msgTypes[1].Exporter = func(v interface{}, i int) interface{} {
|
||||
switch v := v.(*Reply); i {
|
||||
case 0:
|
||||
return &v.state
|
||||
case 1:
|
||||
return &v.sizeCache
|
||||
case 2:
|
||||
return &v.unknownFields
|
||||
default:
|
||||
return nil
|
||||
}
|
||||
}
|
||||
}
|
||||
type x struct{}
|
||||
out := protoimpl.TypeBuilder{
|
||||
File: protoimpl.DescBuilder{
|
||||
GoPackagePath: reflect.TypeOf(x{}).PkgPath(),
|
||||
RawDescriptor: file_base_proto_rawDesc,
|
||||
NumEnums: 0,
|
||||
NumMessages: 2,
|
||||
NumExtensions: 0,
|
||||
NumServices: 0,
|
||||
},
|
||||
GoTypes: file_base_proto_goTypes,
|
||||
DependencyIndexes: file_base_proto_depIdxs,
|
||||
MessageInfos: file_base_proto_msgTypes,
|
||||
}.Build()
|
||||
File_base_proto = out.File
|
||||
file_base_proto_rawDesc = nil
|
||||
file_base_proto_goTypes = nil
|
||||
file_base_proto_depIdxs = nil
|
||||
var fileDescriptor_db1b6b0986796150 = []byte{
|
||||
// 95 bytes of a gzipped FileDescriptorProto
|
||||
0x1f, 0x8b, 0x08, 0x00, 0x00, 0x00, 0x00, 0x00, 0x02, 0xff, 0xe2, 0xe2, 0x4a, 0x4a, 0x2c, 0x4e,
|
||||
0xd5, 0x2b, 0x28, 0xca, 0x2f, 0xc9, 0x17, 0x62, 0xc9, 0x4d, 0xcc, 0xcc, 0x53, 0xe2, 0xe4, 0x62,
|
||||
0x0f, 0x4a, 0x2d, 0x2c, 0x4d, 0x2d, 0x2e, 0x51, 0x52, 0xe4, 0x62, 0x0d, 0x4a, 0x2d, 0xc8, 0xa9,
|
||||
0x14, 0x92, 0xe0, 0x62, 0xcf, 0x4d, 0x2d, 0x2e, 0x4e, 0x4c, 0x4f, 0x95, 0x60, 0x54, 0x60, 0xd4,
|
||||
0xe0, 0x0c, 0x82, 0x71, 0x9d, 0x38, 0xa2, 0xd8, 0xf4, 0xac, 0x41, 0xfa, 0x92, 0xd8, 0xc0, 0x86,
|
||||
0x18, 0x03, 0x02, 0x00, 0x00, 0xff, 0xff, 0xd8, 0xa8, 0xb2, 0x1e, 0x52, 0x00, 0x00, 0x00,
|
||||
}
|
||||
|
|
|
@ -9,7 +9,7 @@ import (
|
|||
// func TestCheckCountry2(t *testing.T) {
|
||||
// gob.Register(Country{})
|
||||
|
||||
// SaveGob("./data/country.gob", reflect.TypeOf(Country{}), NewKeyKind("country-name-", "Name"), NewKeyKind("country-pic-%s", "Pic"))
|
||||
// ("./data/country.gob", reflect.TypeOf(Country{}), NewKeyKind("country-name-", "Name"), NewKeyKind("country-pic-%s", "Pic"))
|
||||
// }
|
||||
|
||||
// func TestLastName(t *testing.T) {
|
||||
|
|
204
country.pb.go
204
country.pb.go
|
@ -1,174 +1,94 @@
|
|||
// Code generated by protoc-gen-go. DO NOT EDIT.
|
||||
// versions:
|
||||
// protoc-gen-go v1.22.0
|
||||
// protoc (unknown)
|
||||
// source: country.proto
|
||||
|
||||
package main
|
||||
|
||||
import (
|
||||
context "context"
|
||||
fmt "fmt"
|
||||
proto "github.com/golang/protobuf/proto"
|
||||
_ "google.golang.org/genproto/googleapis/api/annotations"
|
||||
grpc "google.golang.org/grpc"
|
||||
codes "google.golang.org/grpc/codes"
|
||||
status "google.golang.org/grpc/status"
|
||||
protoreflect "google.golang.org/protobuf/reflect/protoreflect"
|
||||
protoimpl "google.golang.org/protobuf/runtime/protoimpl"
|
||||
reflect "reflect"
|
||||
sync "sync"
|
||||
math "math"
|
||||
)
|
||||
|
||||
const (
|
||||
// Verify that this generated code is sufficiently up-to-date.
|
||||
_ = protoimpl.EnforceVersion(20 - protoimpl.MinVersion)
|
||||
// Verify that runtime/protoimpl is sufficiently up-to-date.
|
||||
_ = protoimpl.EnforceVersion(protoimpl.MaxVersion - 20)
|
||||
)
|
||||
// Reference imports to suppress errors if they are not otherwise used.
|
||||
var _ = proto.Marshal
|
||||
var _ = fmt.Errorf
|
||||
var _ = math.Inf
|
||||
|
||||
// This is a compile-time assertion that a sufficiently up-to-date version
|
||||
// of the legacy proto package is being used.
|
||||
const _ = proto.ProtoPackageIsVersion4
|
||||
// This is a compile-time assertion to ensure that this generated file
|
||||
// is compatible with the proto package it is being compiled against.
|
||||
// A compilation error at this line likely means your copy of the
|
||||
// proto package needs to be updated.
|
||||
const _ = proto.ProtoPackageIsVersion3 // please upgrade the proto package
|
||||
|
||||
// The response message containing the greetings
|
||||
type CountryReply struct {
|
||||
state protoimpl.MessageState
|
||||
sizeCache protoimpl.SizeCache
|
||||
unknownFields protoimpl.UnknownFields
|
||||
|
||||
Image []byte `protobuf:"bytes,1,opt,name=image,proto3" json:"image,omitempty"`
|
||||
Image []byte `protobuf:"bytes,1,opt,name=image,proto3" json:"image,omitempty"`
|
||||
XXX_NoUnkeyedLiteral struct{} `json:"-"`
|
||||
XXX_unrecognized []byte `json:"-"`
|
||||
XXX_sizecache int32 `json:"-"`
|
||||
}
|
||||
|
||||
func (x *CountryReply) Reset() {
|
||||
*x = CountryReply{}
|
||||
if protoimpl.UnsafeEnabled {
|
||||
mi := &file_country_proto_msgTypes[0]
|
||||
ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x))
|
||||
ms.StoreMessageInfo(mi)
|
||||
}
|
||||
}
|
||||
|
||||
func (x *CountryReply) String() string {
|
||||
return protoimpl.X.MessageStringOf(x)
|
||||
}
|
||||
|
||||
func (*CountryReply) ProtoMessage() {}
|
||||
|
||||
func (x *CountryReply) ProtoReflect() protoreflect.Message {
|
||||
mi := &file_country_proto_msgTypes[0]
|
||||
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 CountryReply.ProtoReflect.Descriptor instead.
|
||||
func (m *CountryReply) Reset() { *m = CountryReply{} }
|
||||
func (m *CountryReply) String() string { return proto.CompactTextString(m) }
|
||||
func (*CountryReply) ProtoMessage() {}
|
||||
func (*CountryReply) Descriptor() ([]byte, []int) {
|
||||
return file_country_proto_rawDescGZIP(), []int{0}
|
||||
return fileDescriptor_43a73f5bdb29770c, []int{0}
|
||||
}
|
||||
|
||||
func (x *CountryReply) GetImage() []byte {
|
||||
if x != nil {
|
||||
return x.Image
|
||||
func (m *CountryReply) XXX_Unmarshal(b []byte) error {
|
||||
return xxx_messageInfo_CountryReply.Unmarshal(m, b)
|
||||
}
|
||||
func (m *CountryReply) XXX_Marshal(b []byte, deterministic bool) ([]byte, error) {
|
||||
return xxx_messageInfo_CountryReply.Marshal(b, m, deterministic)
|
||||
}
|
||||
func (m *CountryReply) XXX_Merge(src proto.Message) {
|
||||
xxx_messageInfo_CountryReply.Merge(m, src)
|
||||
}
|
||||
func (m *CountryReply) XXX_Size() int {
|
||||
return xxx_messageInfo_CountryReply.Size(m)
|
||||
}
|
||||
func (m *CountryReply) XXX_DiscardUnknown() {
|
||||
xxx_messageInfo_CountryReply.DiscardUnknown(m)
|
||||
}
|
||||
|
||||
var xxx_messageInfo_CountryReply proto.InternalMessageInfo
|
||||
|
||||
func (m *CountryReply) GetImage() []byte {
|
||||
if m != nil {
|
||||
return m.Image
|
||||
}
|
||||
return nil
|
||||
}
|
||||
|
||||
var File_country_proto protoreflect.FileDescriptor
|
||||
|
||||
var file_country_proto_rawDesc = []byte{
|
||||
0x0a, 0x0d, 0x63, 0x6f, 0x75, 0x6e, 0x74, 0x72, 0x79, 0x2e, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x12,
|
||||
0x04, 0x6d, 0x61, 0x69, 0x6e, 0x1a, 0x0a, 0x62, 0x61, 0x73, 0x65, 0x2e, 0x70, 0x72, 0x6f, 0x74,
|
||||
0x6f, 0x1a, 0x1c, 0x67, 0x6f, 0x6f, 0x67, 0x6c, 0x65, 0x2f, 0x61, 0x70, 0x69, 0x2f, 0x61, 0x6e,
|
||||
0x6e, 0x6f, 0x74, 0x61, 0x74, 0x69, 0x6f, 0x6e, 0x73, 0x2e, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x22,
|
||||
0x24, 0x0a, 0x0c, 0x43, 0x6f, 0x75, 0x6e, 0x74, 0x72, 0x79, 0x52, 0x65, 0x70, 0x6c, 0x79, 0x12,
|
||||
0x14, 0x0a, 0x05, 0x69, 0x6d, 0x61, 0x67, 0x65, 0x18, 0x01, 0x20, 0x01, 0x28, 0x0c, 0x52, 0x05,
|
||||
0x69, 0x6d, 0x61, 0x67, 0x65, 0x32, 0x9d, 0x01, 0x0a, 0x07, 0x43, 0x6f, 0x75, 0x6e, 0x74, 0x72,
|
||||
0x79, 0x12, 0x3f, 0x0a, 0x04, 0x4e, 0x61, 0x6d, 0x65, 0x12, 0x0d, 0x2e, 0x6d, 0x61, 0x69, 0x6e,
|
||||
0x2e, 0x52, 0x65, 0x71, 0x75, 0x65, 0x73, 0x74, 0x1a, 0x0b, 0x2e, 0x6d, 0x61, 0x69, 0x6e, 0x2e,
|
||||
0x52, 0x65, 0x70, 0x6c, 0x79, 0x22, 0x1b, 0x82, 0xd3, 0xe4, 0x93, 0x02, 0x15, 0x22, 0x10, 0x2f,
|
||||
0x76, 0x31, 0x2f, 0x63, 0x6f, 0x75, 0x6e, 0x74, 0x72, 0x79, 0x2f, 0x6e, 0x61, 0x6d, 0x65, 0x3a,
|
||||
0x01, 0x2a, 0x12, 0x51, 0x0a, 0x07, 0x50, 0x69, 0x63, 0x74, 0x75, 0x72, 0x65, 0x12, 0x0d, 0x2e,
|
||||
0x6d, 0x61, 0x69, 0x6e, 0x2e, 0x52, 0x65, 0x71, 0x75, 0x65, 0x73, 0x74, 0x1a, 0x12, 0x2e, 0x6d,
|
||||
0x61, 0x69, 0x6e, 0x2e, 0x43, 0x6f, 0x75, 0x6e, 0x74, 0x72, 0x79, 0x52, 0x65, 0x70, 0x6c, 0x79,
|
||||
0x22, 0x23, 0x82, 0xd3, 0xe4, 0x93, 0x02, 0x1d, 0x22, 0x18, 0x2f, 0x76, 0x31, 0x2f, 0x63, 0x6f,
|
||||
0x75, 0x6e, 0x74, 0x72, 0x79, 0x2f, 0x6e, 0x61, 0x6d, 0x65, 0x2f, 0x70, 0x69, 0x63, 0x74, 0x75,
|
||||
0x72, 0x65, 0x3a, 0x01, 0x2a, 0x42, 0x08, 0x5a, 0x06, 0x2e, 0x3b, 0x6d, 0x61, 0x69, 0x6e, 0x62,
|
||||
0x06, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x33,
|
||||
func init() {
|
||||
proto.RegisterType((*CountryReply)(nil), "main.CountryReply")
|
||||
}
|
||||
|
||||
var (
|
||||
file_country_proto_rawDescOnce sync.Once
|
||||
file_country_proto_rawDescData = file_country_proto_rawDesc
|
||||
)
|
||||
|
||||
func file_country_proto_rawDescGZIP() []byte {
|
||||
file_country_proto_rawDescOnce.Do(func() {
|
||||
file_country_proto_rawDescData = protoimpl.X.CompressGZIP(file_country_proto_rawDescData)
|
||||
})
|
||||
return file_country_proto_rawDescData
|
||||
func init() {
|
||||
proto.RegisterFile("country.proto", fileDescriptor_43a73f5bdb29770c)
|
||||
}
|
||||
|
||||
var file_country_proto_msgTypes = make([]protoimpl.MessageInfo, 1)
|
||||
var file_country_proto_goTypes = []interface{}{
|
||||
(*CountryReply)(nil), // 0: main.CountryReply
|
||||
(*Request)(nil), // 1: main.Request
|
||||
(*Reply)(nil), // 2: main.Reply
|
||||
}
|
||||
var file_country_proto_depIdxs = []int32{
|
||||
1, // 0: main.Country.Name:input_type -> main.Request
|
||||
1, // 1: main.Country.Picture:input_type -> main.Request
|
||||
2, // 2: main.Country.Name:output_type -> main.Reply
|
||||
0, // 3: main.Country.Picture:output_type -> main.CountryReply
|
||||
2, // [2:4] is the sub-list for method output_type
|
||||
0, // [0:2] is the sub-list for method input_type
|
||||
0, // [0:0] is the sub-list for extension type_name
|
||||
0, // [0:0] is the sub-list for extension extendee
|
||||
0, // [0:0] is the sub-list for field type_name
|
||||
}
|
||||
|
||||
func init() { file_country_proto_init() }
|
||||
func file_country_proto_init() {
|
||||
if File_country_proto != nil {
|
||||
return
|
||||
}
|
||||
file_base_proto_init()
|
||||
if !protoimpl.UnsafeEnabled {
|
||||
file_country_proto_msgTypes[0].Exporter = func(v interface{}, i int) interface{} {
|
||||
switch v := v.(*CountryReply); i {
|
||||
case 0:
|
||||
return &v.state
|
||||
case 1:
|
||||
return &v.sizeCache
|
||||
case 2:
|
||||
return &v.unknownFields
|
||||
default:
|
||||
return nil
|
||||
}
|
||||
}
|
||||
}
|
||||
type x struct{}
|
||||
out := protoimpl.TypeBuilder{
|
||||
File: protoimpl.DescBuilder{
|
||||
GoPackagePath: reflect.TypeOf(x{}).PkgPath(),
|
||||
RawDescriptor: file_country_proto_rawDesc,
|
||||
NumEnums: 0,
|
||||
NumMessages: 1,
|
||||
NumExtensions: 0,
|
||||
NumServices: 1,
|
||||
},
|
||||
GoTypes: file_country_proto_goTypes,
|
||||
DependencyIndexes: file_country_proto_depIdxs,
|
||||
MessageInfos: file_country_proto_msgTypes,
|
||||
}.Build()
|
||||
File_country_proto = out.File
|
||||
file_country_proto_rawDesc = nil
|
||||
file_country_proto_goTypes = nil
|
||||
file_country_proto_depIdxs = nil
|
||||
var fileDescriptor_43a73f5bdb29770c = []byte{
|
||||
// 215 bytes of a gzipped FileDescriptorProto
|
||||
0x1f, 0x8b, 0x08, 0x00, 0x00, 0x00, 0x00, 0x00, 0x02, 0xff, 0xe2, 0xe2, 0x4d, 0xce, 0x2f, 0xcd,
|
||||
0x2b, 0x29, 0xaa, 0xd4, 0x2b, 0x28, 0xca, 0x2f, 0xc9, 0x17, 0x62, 0xc9, 0x4d, 0xcc, 0xcc, 0x93,
|
||||
0xe2, 0x4a, 0x4a, 0x2c, 0x4e, 0x85, 0x88, 0x48, 0xc9, 0xa4, 0xe7, 0xe7, 0xa7, 0xe7, 0xa4, 0xea,
|
||||
0x27, 0x16, 0x64, 0xea, 0x27, 0xe6, 0xe5, 0xe5, 0x97, 0x24, 0x96, 0x64, 0xe6, 0xe7, 0x15, 0x43,
|
||||
0x64, 0x95, 0x54, 0xb8, 0x78, 0x9c, 0x21, 0x06, 0x04, 0xa5, 0x16, 0xe4, 0x54, 0x0a, 0x89, 0x70,
|
||||
0xb1, 0x66, 0xe6, 0x26, 0xa6, 0xa7, 0x4a, 0x30, 0x2a, 0x30, 0x6a, 0xf0, 0x04, 0x41, 0x38, 0x46,
|
||||
0x73, 0x19, 0xb9, 0xd8, 0xa1, 0xca, 0x84, 0xec, 0xb9, 0x58, 0xfc, 0x12, 0x73, 0x53, 0x85, 0x78,
|
||||
0xf5, 0x40, 0x56, 0xe9, 0x05, 0xa5, 0x16, 0x96, 0xa6, 0x16, 0x97, 0x48, 0x71, 0xc3, 0xb8, 0x05,
|
||||
0x39, 0x95, 0x4a, 0xd2, 0x4d, 0x97, 0x9f, 0x4c, 0x66, 0x12, 0x55, 0x12, 0xd0, 0x2f, 0x33, 0xd4,
|
||||
0x87, 0x3a, 0x50, 0x3f, 0x2f, 0x31, 0x37, 0xd5, 0x8a, 0x51, 0x4b, 0x28, 0x90, 0x8b, 0x3d, 0x20,
|
||||
0x33, 0xb9, 0xa4, 0xb4, 0x08, 0xc3, 0x0c, 0x21, 0x08, 0x17, 0xd9, 0x41, 0x4a, 0xca, 0x60, 0xa3,
|
||||
0x64, 0x95, 0x24, 0xd0, 0x8d, 0xd2, 0x2f, 0x80, 0x18, 0x62, 0xc5, 0xa8, 0xe5, 0xc4, 0x11, 0xc5,
|
||||
0xa6, 0x67, 0x0d, 0xd2, 0x9b, 0xc4, 0x06, 0xf6, 0x96, 0x31, 0x20, 0x00, 0x00, 0xff, 0xff, 0x58,
|
||||
0x65, 0x9d, 0xf6, 0x17, 0x01, 0x00, 0x00,
|
||||
}
|
||||
|
||||
// Reference imports to suppress errors if they are not otherwise used.
|
||||
|
@ -225,10 +145,10 @@ type CountryServer interface {
|
|||
type UnimplementedCountryServer struct {
|
||||
}
|
||||
|
||||
func (*UnimplementedCountryServer) Name(context.Context, *Request) (*Reply, error) {
|
||||
func (*UnimplementedCountryServer) Name(ctx context.Context, req *Request) (*Reply, error) {
|
||||
return nil, status.Errorf(codes.Unimplemented, "method Name not implemented")
|
||||
}
|
||||
func (*UnimplementedCountryServer) Picture(context.Context, *Request) (*CountryReply, error) {
|
||||
func (*UnimplementedCountryServer) Picture(ctx context.Context, req *Request) (*CountryReply, error) {
|
||||
return nil, status.Errorf(codes.Unimplemented, "method Picture not implemented")
|
||||
}
|
||||
|
||||
|
|
|
@ -1,7 +0,0 @@
|
|||
package main
|
||||
|
||||
import "testing"
|
||||
|
||||
func TestReGob(t *testing.T) {
|
||||
|
||||
}
|
10
data_remake_test.go
Normal file
10
data_remake_test.go
Normal file
|
@ -0,0 +1,10 @@
|
|||
package main
|
||||
|
||||
import (
|
||||
"testing"
|
||||
)
|
||||
|
||||
func TestRemakeGob(t *testing.T) {
|
||||
province := &KeyList{}
|
||||
LoadGob("./data/province.gob", province)
|
||||
}
|
2
go.mod
2
go.mod
|
@ -3,10 +3,10 @@ module workshop
|
|||
go 1.14
|
||||
|
||||
require (
|
||||
github.com/474420502/hunter v0.1.1
|
||||
github.com/facebookgo/ensure v0.0.0-20200202191622-63f1cf65ac4c // indirect
|
||||
github.com/facebookgo/stack v0.0.0-20160209184415-751773369052 // indirect
|
||||
github.com/facebookgo/subset v0.0.0-20200203212716-c811ad88dec4 // indirect
|
||||
github.com/golang/glog v0.0.0-20160126235308-23def4e6c14b
|
||||
github.com/golang/protobuf v1.4.1
|
||||
github.com/grpc-ecosystem/grpc-gateway v1.14.5
|
||||
github.com/stretchr/testify v1.5.1 // indirect
|
||||
|
|
103
go.sum
103
go.sum
|
@ -1,11 +1,34 @@
|
|||
cloud.google.com/go v0.26.0/go.mod h1:aQUYkXzVsufM+DwF1aE+0xfcU+56JwCaLick0ClmMTw=
|
||||
cloud.google.com/go v0.34.0/go.mod h1:aQUYkXzVsufM+DwF1aE+0xfcU+56JwCaLick0ClmMTw=
|
||||
cloud.google.com/go v0.38.0/go.mod h1:990N+gfupTy94rShfmMCWGDn0LpTmnzTp2qbd1dvSRU=
|
||||
cloud.google.com/go v0.41.0/go.mod h1:OauMR7DV8fzvZIl2qg6rkaIhD/vmgk4iwEw/h6ercmg=
|
||||
github.com/474420502/focus v0.9.0 h1:Y/TjSdSdIgegO78OJixphiPl1wVqhK9AbcXjiDDugo4=
|
||||
github.com/474420502/focus v0.9.0/go.mod h1:jrDXvK1CnUJ3PCR3ZJVYinbS2Yz5kM8OoAbCLe6AF7Y=
|
||||
github.com/474420502/gcurl v0.0.4 h1:eR1BNXvQ4T245dotWpjDzAMWch+FTTfScqzsdq93JK0=
|
||||
github.com/474420502/gcurl v0.0.4/go.mod h1:qtCzAZZbVRIsBt0lNUh2I0qDniU9T3E21aSsVUYo7Hc=
|
||||
github.com/474420502/hunter v0.1.1 h1:gZ/WMZpCSO5ECE0vdJSLCoy54rU4hdlGkivX5H+X9g8=
|
||||
github.com/474420502/hunter v0.1.1/go.mod h1:41DpZWSsGBWsFwb/liapbT1uH58Yvl+BpW4SJwLC2Fw=
|
||||
github.com/474420502/requests v1.5.0/go.mod h1:SLXrQ5dL9c7dkIeKNUCBAjOIt3J9KFCS2RQjWJecNwo=
|
||||
github.com/474420502/requests v1.5.1 h1:miv6O4RMbZ8I0ZdUTLf/EU5Dmewc/4IL/DmUMwtuv8M=
|
||||
github.com/474420502/requests v1.5.1/go.mod h1:SLXrQ5dL9c7dkIeKNUCBAjOIt3J9KFCS2RQjWJecNwo=
|
||||
github.com/BurntSushi/toml v0.3.1/go.mod h1:xHWCNGjB5oqiDr8zfno3MHue2Ht5sIBksp03qcyfWMU=
|
||||
github.com/BurntSushi/xgb v0.0.0-20160522181843-27f122750802/go.mod h1:IVnqGOEym/WlBOVXweHU+Q+/VP0lqqI8lqeDx9IjBqo=
|
||||
github.com/BurntSushi/xgbutil v0.0.0-20160919175755-f7c97cef3b4e/go.mod h1:uw9h2sd4WWHOPdJ13MQpwK5qYWKYDumDqxWWIknEQ+k=
|
||||
github.com/Pallinder/go-randomdata v1.1.0 h1:gUubB1IEUliFmzjqjhf+bgkg1o6uoFIkRsP3VrhEcx8=
|
||||
github.com/Pallinder/go-randomdata v1.1.0/go.mod h1:yHmJgulpD2Nfrm0cR9tI/+oAgRqCQQixsA8HyRZfV9Y=
|
||||
github.com/antihax/optional v0.0.0-20180407024304-ca021399b1a6/go.mod h1:V8iCPQYkqmusNa815XgQio277wI47sdRh1dUOLdyC6Q=
|
||||
github.com/armon/go-socks5 v0.0.0-20160902184237-e75332964ef5/go.mod h1:wHh0iHkYZB8zMSxRWpUBQtwG5a7fFgvEO+odwuTv2gs=
|
||||
github.com/blang/semver v3.5.1+incompatible h1:cQNTCjp13qL8KC3Nbxr/y2Bqb63oX6wdnnjpJbkM4JQ=
|
||||
github.com/blang/semver v3.5.1+incompatible/go.mod h1:kRBLl5iJ+tD4TcOOxsy/0fnwebNt5EWlYSAyrTnjyyk=
|
||||
github.com/census-instrumentation/opencensus-proto v0.2.1/go.mod h1:f6KPmirojxKA12rnyqOA5BBL4O983OfeGPqjHWSTneU=
|
||||
github.com/client9/misspell v0.3.4/go.mod h1:qj6jICC3Q7zFZvVWo7KLAzC3yx5G7kyvSDkc90ppPyw=
|
||||
github.com/cncf/udpa/go v0.0.0-20191209042840-269d4d468f6f/go.mod h1:M8M6+tZqaGXZJjfX53e64911xZQV5JYwmTeXPW+k8Sc=
|
||||
github.com/davecgh/go-spew v1.1.0 h1:ZDRjVQ15GmhC3fiQ8ni8+OwkZQO4DARzQgrnXU1Liz8=
|
||||
github.com/davecgh/go-spew v1.1.0/go.mod h1:J7Y8YcW2NihsgmVo/mv3lAwl/skON4iLHjSsI+c5H38=
|
||||
github.com/davecgh/go-spew v1.1.1 h1:vj9j/u1bqnvCEfJOwUhtlOARqs3+rkHYY13jYWTU97c=
|
||||
github.com/davecgh/go-spew v1.1.1/go.mod h1:J7Y8YcW2NihsgmVo/mv3lAwl/skON4iLHjSsI+c5H38=
|
||||
github.com/elazarl/goproxy v0.0.0-20190711103511-473e67f1d7d2/go.mod h1:/Zj4wYkgs4iZTTu3o/KG3Itv/qCCa8VVMlb3i9OVuzc=
|
||||
github.com/elazarl/goproxy/ext v0.0.0-20190711103511-473e67f1d7d2/go.mod h1:gNh8nYJoAm43RfaxurUnxr+N1PwuFV3ZMl/efxlIlY8=
|
||||
github.com/envoyproxy/go-control-plane v0.9.0/go.mod h1:YTl/9mNaCwkRvm6d1a2C3ymFceY/DCBVvsKhRF0iEA4=
|
||||
github.com/envoyproxy/go-control-plane v0.9.1-0.20191026205805-5f8ba28d4473/go.mod h1:YTl/9mNaCwkRvm6d1a2C3ymFceY/DCBVvsKhRF0iEA4=
|
||||
github.com/envoyproxy/go-control-plane v0.9.4/go.mod h1:6rpuAdCZL397s3pYoYcLgu1mIlRU8Am5FuJP05cCM98=
|
||||
|
@ -20,7 +43,10 @@ github.com/ghodss/yaml v1.0.0/go.mod h1:4dBDuWmgqj2HViK6kFavaiC9ZROes6MMH2rRYeME
|
|||
github.com/golang/glog v0.0.0-20160126235308-23def4e6c14b h1:VKtxabqXZkF25pY9ekfRL6a582T4P37/31XEstQ5p58=
|
||||
github.com/golang/glog v0.0.0-20160126235308-23def4e6c14b/go.mod h1:SBH7ygxi8pfUlaOkMMuAQtPIUF8ecWP5IEl/CR7VP2Q=
|
||||
github.com/golang/mock v1.1.1/go.mod h1:oTYuIxOrZwtPieC+H1uAHpcLFnEyAGVDL/k47Jfbm0A=
|
||||
github.com/golang/mock v1.2.0/go.mod h1:oTYuIxOrZwtPieC+H1uAHpcLFnEyAGVDL/k47Jfbm0A=
|
||||
github.com/golang/mock v1.3.1/go.mod h1:sBzyDLLjw3U8JLTeZvSv8jJB+tU5PVekmnlKIyFUx0Y=
|
||||
github.com/golang/protobuf v1.2.0/go.mod h1:6lQm79b+lXiMfvg/cZm0SGofjICqVBUtrP5yJMmIC1U=
|
||||
github.com/golang/protobuf v1.3.1/go.mod h1:6lQm79b+lXiMfvg/cZm0SGofjICqVBUtrP5yJMmIC1U=
|
||||
github.com/golang/protobuf v1.3.2/go.mod h1:6lQm79b+lXiMfvg/cZm0SGofjICqVBUtrP5yJMmIC1U=
|
||||
github.com/golang/protobuf v1.3.3/go.mod h1:vzj43D7+SQXF/4pzW/hwtAqwc6iTitCiVSaWz5lYuqw=
|
||||
github.com/golang/protobuf v1.4.0-rc.1/go.mod h1:ceaxUfeHdC40wWswd/P6IGgMaK3YpKi5j83Wpe3EHw8=
|
||||
|
@ -30,56 +56,130 @@ github.com/golang/protobuf v1.4.0-rc.4.0.20200313231945-b860323f09d0/go.mod h1:W
|
|||
github.com/golang/protobuf v1.4.0/go.mod h1:jodUvKwWbYaEsadDk5Fwe5c77LiNKVO9IDvqG2KuDX0=
|
||||
github.com/golang/protobuf v1.4.1 h1:ZFgWrT+bLgsYPirOnRfKLYJLvssAegOj/hgyMFdJZe0=
|
||||
github.com/golang/protobuf v1.4.1/go.mod h1:U8fpvMrcmy5pZrNK1lt4xCsGvpyWQ/VVv6QDs8UjoX8=
|
||||
github.com/google/btree v0.0.0-20180813153112-4030bb1f1f0c/go.mod h1:lNA+9X1NB3Zf8V7Ke586lFgjr2dZNuvo3lPJSGZ5JPQ=
|
||||
github.com/google/btree v1.0.0/go.mod h1:lNA+9X1NB3Zf8V7Ke586lFgjr2dZNuvo3lPJSGZ5JPQ=
|
||||
github.com/google/go-cmp v0.2.0/go.mod h1:oXzfMopK8JAjlY9xF4vHSVASa0yLyX7SntLO5aqRK0M=
|
||||
github.com/google/go-cmp v0.3.0/go.mod h1:8QqcDgzrUqlUb/G2PQTWiueGozuR1884gddMywk6iLU=
|
||||
github.com/google/go-cmp v0.3.1/go.mod h1:8QqcDgzrUqlUb/G2PQTWiueGozuR1884gddMywk6iLU=
|
||||
github.com/google/go-cmp v0.4.0 h1:xsAVV57WRhGj6kEIi8ReJzQlHHqcBYCElAvkovg3B/4=
|
||||
github.com/google/go-cmp v0.4.0/go.mod h1:v8dTdLbMG2kIc/vJvl+f65V22dbkXbowE6jgT/gNBxE=
|
||||
github.com/google/go-github/v27 v27.0.4/go.mod h1:/0Gr8pJ55COkmv+S/yPKCczSkUPIM/LnFyubufRNIS0=
|
||||
github.com/google/go-querystring v1.0.0/go.mod h1:odCYkC5MyYFN7vkCjXpyrEuKhc/BUO6wN/zVPAxq5ck=
|
||||
github.com/google/martian v2.1.0+incompatible/go.mod h1:9I4somxYTbIHy5NJKHRl3wXiIaQGbYVAs8BPL6v8lEs=
|
||||
github.com/google/pprof v0.0.0-20181206194817-3ea8567a2e57/go.mod h1:zfwlbNMJ+OItoe0UupaVj+oy1omPYYDuagoSzA8v9mc=
|
||||
github.com/google/pprof v0.0.0-20190515194954-54271f7e092f/go.mod h1:zfwlbNMJ+OItoe0UupaVj+oy1omPYYDuagoSzA8v9mc=
|
||||
github.com/googleapis/gax-go/v2 v2.0.4/go.mod h1:0Wqv26UfaUD9n4G6kQubkQ+KchISgw+vpHVxEJEs9eg=
|
||||
github.com/googleapis/gax-go/v2 v2.0.5/go.mod h1:DWXyrwAJ9X0FpwwEdw+IPEYBICEFu5mhpdKc/us6bOk=
|
||||
github.com/grpc-ecosystem/grpc-gateway v1.14.5 h1:aiLxiiVzAXb7wb3lAmubA69IokWOoUNe+E7TdGKh8yw=
|
||||
github.com/grpc-ecosystem/grpc-gateway v1.14.5/go.mod h1:UJ0EZAp832vCd54Wev9N1BMKEyvcZ5+IM0AwDrnlkEc=
|
||||
github.com/hashicorp/golang-lru v0.5.0/go.mod h1:/m3WP610KZHVQ1SGc6re/UDhFvYD7pJ4Ao+sR/qLZy8=
|
||||
github.com/hashicorp/golang-lru v0.5.1/go.mod h1:/m3WP610KZHVQ1SGc6re/UDhFvYD7pJ4Ao+sR/qLZy8=
|
||||
github.com/jstemmer/go-junit-report v0.0.0-20190106144839-af01ea7f8024/go.mod h1:6v2b51hI/fHJwM22ozAgKL4VKDeJcHhJFhtBdhmNjmU=
|
||||
github.com/lestrrat-go/libxml2 v0.0.0-20200215080510-6483566f52cb h1:qqNmX9V9n4byPp7LUvUf7CPhMPYO9ol4ElpbD3DgzuY=
|
||||
github.com/lestrrat-go/libxml2 v0.0.0-20200215080510-6483566f52cb/go.mod h1:fy/ZVbgyB83mtricxwSW3zqIRXWOVpKG2PvdUDFeC58=
|
||||
github.com/pkg/errors v0.9.1 h1:FEBLx1zS214owpjy7qsBeixbURkuhQAwrK5UwLGTwt4=
|
||||
github.com/pkg/errors v0.9.1/go.mod h1:bwawxfHBFNV+L2hUp1rHADufV3IMtnDRdf1r5NINEl0=
|
||||
github.com/pmezard/go-difflib v1.0.0 h1:4DBwDE0NGyQoBHbLQYPwSUPoCMWR5BEzIk/f1lZbAQM=
|
||||
github.com/pmezard/go-difflib v1.0.0/go.mod h1:iKH77koFhYxTK1pcRnkKkqfTogsbg7gZNVY4sRDYZ/4=
|
||||
github.com/prometheus/client_model v0.0.0-20190812154241-14fe0d1b01d4/go.mod h1:xMI15A0UPsDsEKsMN9yxemIoYk6Tm2C1GtYGdfGttqA=
|
||||
github.com/rogpeppe/fastuuid v1.2.0/go.mod h1:jVj6XXZzXRy/MSR5jhDC/2q6DgLz+nrA6LYCDYWNEvQ=
|
||||
github.com/rogpeppe/go-charset v0.0.0-20180617210344-2471d30d28b4/go.mod h1:qgYeAmZ5ZIpBWTGllZSQnw97Dj+woV0toclVaRGI8pc=
|
||||
github.com/stretchr/objx v0.1.0/go.mod h1:HFkY916IF+rwdDfMAkV7OtwuqBVzrE8GR6GFx+wExME=
|
||||
github.com/stretchr/testify v1.4.0/go.mod h1:j7eGeouHqKxXV5pUuKE4zz7dFj8WfuZ+81PSLYec5m4=
|
||||
github.com/stretchr/testify v1.5.1 h1:nOGnQDM7FYENwehXlg/kFVnos3rEvtKTjRvOWSzb6H4=
|
||||
github.com/stretchr/testify v1.5.1/go.mod h1:5W2xD1RspED5o8YsWQXVCued0rvSQ+mT+I5cxcmMvtA=
|
||||
github.com/tebeka/selenium v0.9.9 h1:cNziB+etNgyH/7KlNI7RMC1ua5aH1+5wUlFQyzeMh+w=
|
||||
github.com/tebeka/selenium v0.9.9/go.mod h1:5Fr8+pUvU6B1OiPfkdCKdXZyr5znvVkxuPd0NOdZCQc=
|
||||
github.com/tecbot/gorocksdb v0.0.0-20191217155057-f0fad39f321c h1:g+WoO5jjkqGAzHWCjJB1zZfXPIAaDpzXIEJ0eS6B5Ok=
|
||||
github.com/tecbot/gorocksdb v0.0.0-20191217155057-f0fad39f321c/go.mod h1:ahpPrc7HpcfEWDQRZEmnXMzHY03mLDYMCxeDzy46i+8=
|
||||
github.com/tidwall/gjson v1.3.2/go.mod h1:P256ACg0Mn+j1RXIDXoss50DeIABTYK1PULOJHhxOls=
|
||||
github.com/tidwall/match v1.0.1/go.mod h1:LujAq0jyVjBy028G1WhWfIzbpQfMO8bBZ6Tyb0+pL9E=
|
||||
github.com/tidwall/pretty v1.0.0/go.mod h1:XNkn88O1ChpSDQmQeStsy+sBenx6DDtFZJxhVysOjyk=
|
||||
go.opencensus.io v0.21.0/go.mod h1:mSImk1erAIZhrmZN+AvHh14ztQfjbGwt4TtuofqLduU=
|
||||
go.opencensus.io v0.22.0/go.mod h1:+kGneAE2xo2IficOXnaByMWTGM9T73dGwxeWcUqIpI8=
|
||||
golang.org/x/crypto v0.0.0-20190308221718-c2843e01d9a2/go.mod h1:djNgcEr1/C05ACkg1iLfiJU5Ep61QUkGW8qpdssI0+w=
|
||||
golang.org/x/crypto v0.0.0-20190605123033-f99c8df09eb5/go.mod h1:yigFU9vqHzYiE8UmvKecakEJjdnWj3jj499lnFckfCI=
|
||||
golang.org/x/exp v0.0.0-20190121172915-509febef88a4/go.mod h1:CJ0aWSM057203Lf6IL+f9T1iT9GByDxfZKAQTCR3kQA=
|
||||
golang.org/x/exp v0.0.0-20190510132918-efd6b22b2522/go.mod h1:ZjyILWgesfNpC6sMxTJOJm9Kp84zZh5NQWvqDGG3Qr8=
|
||||
golang.org/x/image v0.0.0-20190227222117-0694c2d4d067/go.mod h1:kZ7UVZpmo3dzQBMxlp+ypCbDeSB+sBbTgSJuh5dn5js=
|
||||
golang.org/x/lint v0.0.0-20181026193005-c67002cb31c3/go.mod h1:UVdnD1Gm6xHRNCYTkRU2/jEulfH38KcIWyp/GAMgvoE=
|
||||
golang.org/x/lint v0.0.0-20190227174305-5b3e6a55c961/go.mod h1:wehouNa3lNwaWXcvxsM5YxQ5yQlVC4a0KAMCusXpPoU=
|
||||
golang.org/x/lint v0.0.0-20190301231843-5614ed5bae6f/go.mod h1:UVdnD1Gm6xHRNCYTkRU2/jEulfH38KcIWyp/GAMgvoE=
|
||||
golang.org/x/lint v0.0.0-20190313153728-d0100b6bd8b3/go.mod h1:6SW0HCj/g11FgYtHlgUYUwCkIfeOF89ocIRzGO/8vkc=
|
||||
golang.org/x/lint v0.0.0-20190409202823-959b441ac422/go.mod h1:6SW0HCj/g11FgYtHlgUYUwCkIfeOF89ocIRzGO/8vkc=
|
||||
golang.org/x/mobile v0.0.0-20190312151609-d3739f865fa6/go.mod h1:z+o9i4GpDbdi3rU15maQ/Ox0txvL9dWGYEHz965HBQE=
|
||||
golang.org/x/net v0.0.0-20180724234803-3673e40ba225/go.mod h1:mL1N/T3taQHkDXs73rZJwtUhF3w3ftmwwsq0BUmARs4=
|
||||
golang.org/x/net v0.0.0-20180826012351-8a410e7b638d/go.mod h1:mL1N/T3taQHkDXs73rZJwtUhF3w3ftmwwsq0BUmARs4=
|
||||
golang.org/x/net v0.0.0-20190108225652-1e06a53dbb7e/go.mod h1:mL1N/T3taQHkDXs73rZJwtUhF3w3ftmwwsq0BUmARs4=
|
||||
golang.org/x/net v0.0.0-20190213061140-3a22650c66bd/go.mod h1:mL1N/T3taQHkDXs73rZJwtUhF3w3ftmwwsq0BUmARs4=
|
||||
golang.org/x/net v0.0.0-20190311183353-d8887717615a/go.mod h1:t9HGtf8HONx5eT2rtn7q6eTqICYqUVnKs3thJo3Qplg=
|
||||
golang.org/x/net v0.0.0-20190404232315-eb5bcb51f2a3/go.mod h1:t9HGtf8HONx5eT2rtn7q6eTqICYqUVnKs3thJo3Qplg=
|
||||
golang.org/x/net v0.0.0-20190501004415-9ce7a6920f09/go.mod h1:t9HGtf8HONx5eT2rtn7q6eTqICYqUVnKs3thJo3Qplg=
|
||||
golang.org/x/net v0.0.0-20190503192946-f4e77d36d62c/go.mod h1:t9HGtf8HONx5eT2rtn7q6eTqICYqUVnKs3thJo3Qplg=
|
||||
golang.org/x/net v0.0.0-20190603091049-60506f45cf65/go.mod h1:HSz+uSET+XFnRR8LxR5pz3Of3rY3CfYBVs4xY44aLks=
|
||||
golang.org/x/net v0.0.0-20190620200207-3b0461eec859/go.mod h1:z5CRVTTTmAJ677TzLLGU+0bjPO0LkuOLi4/5GtJWs/s=
|
||||
golang.org/x/net v0.0.0-20191002035440-2ec189313ef0 h1:2mqDk8w/o6UmeUCu5Qiq2y7iMf6anbx+YA8d1JFoFrs=
|
||||
golang.org/x/net v0.0.0-20191002035440-2ec189313ef0/go.mod h1:z5CRVTTTmAJ677TzLLGU+0bjPO0LkuOLi4/5GtJWs/s=
|
||||
golang.org/x/net v0.0.0-20200324143707-d3edc9973b7e h1:3G+cUijn7XD+S4eJFddp53Pv7+slrESplyjG25HgL+k=
|
||||
golang.org/x/net v0.0.0-20200324143707-d3edc9973b7e/go.mod h1:qpuaurCH72eLCgpAm/N6yyVIVM9cpaDIP3A8BGJEC5A=
|
||||
golang.org/x/oauth2 v0.0.0-20180821212333-d2e6202438be/go.mod h1:N/0e6XlmueqKjAGxoOufVs8QHGRruUQn6yWY3a++T0U=
|
||||
golang.org/x/oauth2 v0.0.0-20190226205417-e64efc72b421/go.mod h1:gOpvHmFTYa4IltrdGE7lF6nIHvwfUNPOp7c8zoXwtLw=
|
||||
golang.org/x/oauth2 v0.0.0-20190604053449-0f29369cfe45/go.mod h1:gOpvHmFTYa4IltrdGE7lF6nIHvwfUNPOp7c8zoXwtLw=
|
||||
golang.org/x/sync v0.0.0-20180314180146-1d60e4601c6f/go.mod h1:RxMgew5VJxzue5/jJTE5uejpjVlOe/izrB70Jof72aM=
|
||||
golang.org/x/sync v0.0.0-20181108010431-42b317875d0f/go.mod h1:RxMgew5VJxzue5/jJTE5uejpjVlOe/izrB70Jof72aM=
|
||||
golang.org/x/sync v0.0.0-20181221193216-37e7f081c4d4/go.mod h1:RxMgew5VJxzue5/jJTE5uejpjVlOe/izrB70Jof72aM=
|
||||
golang.org/x/sync v0.0.0-20190227155943-e225da77a7e6/go.mod h1:RxMgew5VJxzue5/jJTE5uejpjVlOe/izrB70Jof72aM=
|
||||
golang.org/x/sync v0.0.0-20190423024810-112230192c58/go.mod h1:RxMgew5VJxzue5/jJTE5uejpjVlOe/izrB70Jof72aM=
|
||||
golang.org/x/sys v0.0.0-20180830151530-49385e6e1522/go.mod h1:STP8DvDyc/dI5b8T5hshtkjS+E42TnysNCUPdjciGhY=
|
||||
golang.org/x/sys v0.0.0-20190215142949-d0b11bdaac8a h1:1BGLXjeY4akVXGgbC9HugT3Jv3hCI0z56oJR5vAMgBU=
|
||||
golang.org/x/sys v0.0.0-20190215142949-d0b11bdaac8a/go.mod h1:STP8DvDyc/dI5b8T5hshtkjS+E42TnysNCUPdjciGhY=
|
||||
golang.org/x/sys v0.0.0-20190312061237-fead79001313/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs=
|
||||
golang.org/x/sys v0.0.0-20190412213103-97732733099d/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs=
|
||||
golang.org/x/sys v0.0.0-20190502145724-3ef323f4f1fd/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs=
|
||||
golang.org/x/sys v0.0.0-20190507160741-ecd444e8653b/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs=
|
||||
golang.org/x/sys v0.0.0-20190606165138-5da285871e9c/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs=
|
||||
golang.org/x/sys v0.0.0-20190624142023-c5567b49c5d0/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs=
|
||||
golang.org/x/sys v0.0.0-20200323222414-85ca7c5b95cd h1:xhmwyvizuTgC2qz7ZlMluP20uW+C3Rm0FD/WLDX8884=
|
||||
golang.org/x/sys v0.0.0-20200323222414-85ca7c5b95cd/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs=
|
||||
golang.org/x/text v0.3.0 h1:g61tztE5qeGQ89tm6NTjjM9VPIm088od1l6aSorWRWg=
|
||||
golang.org/x/text v0.3.0/go.mod h1:NqM8EUOU14njkJ3fqMW+pc6Ldnwhi/IjpwHt7yyuwOQ=
|
||||
golang.org/x/text v0.3.1-0.20180807135948-17ff2d5776d2/go.mod h1:NqM8EUOU14njkJ3fqMW+pc6Ldnwhi/IjpwHt7yyuwOQ=
|
||||
golang.org/x/text v0.3.2 h1:tW2bmiBqwgJj/UpqtC8EpXEZVYOwU0yG4iWbprSVAcs=
|
||||
golang.org/x/text v0.3.2/go.mod h1:bEr9sfX3Q8Zfm5fL9x+3itogRgK3+ptLWKqgva+5dAk=
|
||||
golang.org/x/time v0.0.0-20181108054448-85acf8d2951c/go.mod h1:tRJNPiyCQ0inRvYxbN9jk5I+vvW/OXSQhTDSoE431IQ=
|
||||
golang.org/x/time v0.0.0-20190308202827-9d24e82272b4/go.mod h1:tRJNPiyCQ0inRvYxbN9jk5I+vvW/OXSQhTDSoE431IQ=
|
||||
golang.org/x/tools v0.0.0-20180917221912-90fa682c2a6e/go.mod h1:n7NCudcB/nEzxVGmLbDWY5pfWTLqBcC2KZ6jyYvM4mQ=
|
||||
golang.org/x/tools v0.0.0-20190114222345-bf090417da8b/go.mod h1:n7NCudcB/nEzxVGmLbDWY5pfWTLqBcC2KZ6jyYvM4mQ=
|
||||
golang.org/x/tools v0.0.0-20190226205152-f727befe758c/go.mod h1:9Yl7xja0Znq3iFh3HoIrodX9oNMXvdceNzlUR8zjMvY=
|
||||
golang.org/x/tools v0.0.0-20190311212946-11955173bddd/go.mod h1:LCzVGOaR6xXOjkQ3onu1FJEFr0SW1gC7cKk1uF8kGRs=
|
||||
golang.org/x/tools v0.0.0-20190312151545-0bb0c0a6e846/go.mod h1:LCzVGOaR6xXOjkQ3onu1FJEFr0SW1gC7cKk1uF8kGRs=
|
||||
golang.org/x/tools v0.0.0-20190312170243-e65039ee4138/go.mod h1:LCzVGOaR6xXOjkQ3onu1FJEFr0SW1gC7cKk1uF8kGRs=
|
||||
golang.org/x/tools v0.0.0-20190425150028-36563e24a262/go.mod h1:RgjU9mgBXZiqYHBnxXauZ1Gv1EHHAz9KjViQ78xBX0Q=
|
||||
golang.org/x/tools v0.0.0-20190506145303-2d16b83fe98c/go.mod h1:RgjU9mgBXZiqYHBnxXauZ1Gv1EHHAz9KjViQ78xBX0Q=
|
||||
golang.org/x/tools v0.0.0-20190524140312-2c0ae7006135/go.mod h1:RgjU9mgBXZiqYHBnxXauZ1Gv1EHHAz9KjViQ78xBX0Q=
|
||||
golang.org/x/tools v0.0.0-20190606124116-d0a3d012864b/go.mod h1:/rFqwRUd4F7ZHNgwSSTFct+R/Kf4OFW1sUzUTQQTgfc=
|
||||
golang.org/x/tools v0.0.0-20190624190245-7f2218787638/go.mod h1:/rFqwRUd4F7ZHNgwSSTFct+R/Kf4OFW1sUzUTQQTgfc=
|
||||
golang.org/x/xerrors v0.0.0-20191204190536-9bdfabe68543 h1:E7g+9GITq07hpfrRu66IVDexMakfv52eLZ2CXBWiKr4=
|
||||
golang.org/x/xerrors v0.0.0-20191204190536-9bdfabe68543/go.mod h1:I/5z698sn9Ka8TeJc9MKroUUfqBBauWjQqLJ2OPfmY0=
|
||||
google.golang.org/api v0.4.0/go.mod h1:8k5glujaEP+g9n7WNsDg8QP6cUVNI86fCNMcbazEtwE=
|
||||
google.golang.org/api v0.7.0/go.mod h1:WtwebWUNSVBH/HAw79HIFXZNqEvBhG+Ra+ax0hx3E3M=
|
||||
google.golang.org/appengine v1.1.0/go.mod h1:EbEs0AVv82hx2wNQdGPgUI5lhzA/G0D9YwlJXL52JkM=
|
||||
google.golang.org/appengine v1.4.0/go.mod h1:xpcJRLb0r/rnEns0DIKYYv+WjYCduHsrkT7/EB5XEv4=
|
||||
google.golang.org/appengine v1.5.0/go.mod h1:xpcJRLb0r/rnEns0DIKYYv+WjYCduHsrkT7/EB5XEv4=
|
||||
google.golang.org/appengine v1.6.1/go.mod h1:i06prIuMbXzDqacNJfV5OdTW448YApPu5ww/cMBSeb0=
|
||||
google.golang.org/genproto v0.0.0-20180817151627-c66870c02cf8/go.mod h1:JiN7NxoALGmiZfu7CAH4rXhgtRTLTxftemlI0sWmxmc=
|
||||
google.golang.org/genproto v0.0.0-20190307195333-5fe7a883aa19/go.mod h1:VzzqZJRnGkLBvHegQrXjBqPurQTc5/KpmUdxsrq26oE=
|
||||
google.golang.org/genproto v0.0.0-20190418145605-e7d98fc518a7/go.mod h1:VzzqZJRnGkLBvHegQrXjBqPurQTc5/KpmUdxsrq26oE=
|
||||
google.golang.org/genproto v0.0.0-20190425155659-357c62f0e4bb/go.mod h1:VzzqZJRnGkLBvHegQrXjBqPurQTc5/KpmUdxsrq26oE=
|
||||
google.golang.org/genproto v0.0.0-20190502173448-54afdca5d873/go.mod h1:VzzqZJRnGkLBvHegQrXjBqPurQTc5/KpmUdxsrq26oE=
|
||||
google.golang.org/genproto v0.0.0-20190626174449-989357319d63/go.mod h1:z3L6/3dTEVtUr6QSP8miRzeRqwQOioJ9I66odjN4I7s=
|
||||
google.golang.org/genproto v0.0.0-20190819201941-24fa4b261c55/go.mod h1:DMBHOl98Agz4BDEuKkezgsaosCRResVns1a3J2ZsMNc=
|
||||
google.golang.org/genproto v0.0.0-20190927181202-20e1ac93f88c/go.mod h1:IbNlFCBrqXvoKpeg0TB2l7cyZUmoaFKYIwrEpbDKLA8=
|
||||
google.golang.org/genproto v0.0.0-20200511104702-f5ebc3bea380 h1:xriR1EgvKfkKxIoU2uUvrMVl+H26359loFFUleSMXFo=
|
||||
google.golang.org/genproto v0.0.0-20200511104702-f5ebc3bea380/go.mod h1:55QSHmfGQM9UVYDPBsyGGes0y52j32PQ3BqQfXhyH3c=
|
||||
google.golang.org/grpc v1.19.0/go.mod h1:mqu4LbDTu4XGKhr4mRzUsmM4RtVoemTSY81AxZiDr8c=
|
||||
google.golang.org/grpc v1.20.1/go.mod h1:10oTOabMzJvdu6/UiuZezV6QK5dSlG84ov/aaiqXj38=
|
||||
google.golang.org/grpc v1.21.1/go.mod h1:oYelfM1adQP15Ek0mdvEgi9Df8B9CZIaU1084ijfRaM=
|
||||
google.golang.org/grpc v1.23.0/go.mod h1:Y5yQAOtifL1yxbo5wqy6BxZv8vAUGQwXBOALyacEbxg=
|
||||
google.golang.org/grpc v1.24.0/go.mod h1:XDChyiUovWa60DnaeDeZmSW86xtLtjtZbwvSiRnRtcA=
|
||||
google.golang.org/grpc v1.25.1/go.mod h1:c3i+UQWmh7LiEpx4sFZnkU36qjEYZ0imhYfXVyQciAY=
|
||||
|
@ -99,4 +199,7 @@ gopkg.in/yaml.v2 v2.2.2/go.mod h1:hI93XBmqTisBFMUTm0b8Fm+jr3Dg1NNxqwp+5A1VGuI=
|
|||
gopkg.in/yaml.v2 v2.2.3 h1:fvjTMHxHEw/mxHbtzPi3JCcKXQRAnQTBRo6YCJSVHKI=
|
||||
gopkg.in/yaml.v2 v2.2.3/go.mod h1:hI93XBmqTisBFMUTm0b8Fm+jr3Dg1NNxqwp+5A1VGuI=
|
||||
honnef.co/go/tools v0.0.0-20190102054323-c2f93a96b099/go.mod h1:rf3lG4BRIbNafJWhAfAdb/ePZxsR/4RtNHQocxwk9r4=
|
||||
honnef.co/go/tools v0.0.0-20190106161140-3f1c8253044a/go.mod h1:rf3lG4BRIbNafJWhAfAdb/ePZxsR/4RtNHQocxwk9r4=
|
||||
honnef.co/go/tools v0.0.0-20190418001031-e561f6794a2a/go.mod h1:rf3lG4BRIbNafJWhAfAdb/ePZxsR/4RtNHQocxwk9r4=
|
||||
honnef.co/go/tools v0.0.0-20190523083050-ea95bdfd59fc/go.mod h1:rf3lG4BRIbNafJWhAfAdb/ePZxsR/4RtNHQocxwk9r4=
|
||||
rsc.io/binaryregexp v0.2.0/go.mod h1:qTv7/COck+e2FymRvadv62gMdZztPaShugOCi3I+8D8=
|
||||
|
|
2
main.go
2
main.go
|
@ -39,9 +39,11 @@ func main() {
|
|||
|
||||
ns := &nameserver{}
|
||||
cs := &countryserver{}
|
||||
ps := &provinceserver{}
|
||||
|
||||
RegisterNameHandlerServer(ctx, mux, ns)
|
||||
RegisterCountryHandlerServer(ctx, mux, cs)
|
||||
RegisterProvinceAreaCityHandlerServer(ctx, mux, ps)
|
||||
|
||||
log.Fatal(http.ListenAndServe(":4433", mux))
|
||||
|
||||
|
|
111
people.pb.go
111
people.pb.go
|
@ -1,99 +1,48 @@
|
|||
// Code generated by protoc-gen-go. DO NOT EDIT.
|
||||
// versions:
|
||||
// protoc-gen-go v1.22.0
|
||||
// protoc (unknown)
|
||||
// source: people.proto
|
||||
|
||||
package main
|
||||
|
||||
import (
|
||||
context "context"
|
||||
fmt "fmt"
|
||||
proto "github.com/golang/protobuf/proto"
|
||||
_ "google.golang.org/genproto/googleapis/api/annotations"
|
||||
grpc "google.golang.org/grpc"
|
||||
codes "google.golang.org/grpc/codes"
|
||||
status "google.golang.org/grpc/status"
|
||||
protoreflect "google.golang.org/protobuf/reflect/protoreflect"
|
||||
protoimpl "google.golang.org/protobuf/runtime/protoimpl"
|
||||
reflect "reflect"
|
||||
math "math"
|
||||
)
|
||||
|
||||
const (
|
||||
// Verify that this generated code is sufficiently up-to-date.
|
||||
_ = protoimpl.EnforceVersion(20 - protoimpl.MinVersion)
|
||||
// Verify that runtime/protoimpl is sufficiently up-to-date.
|
||||
_ = protoimpl.EnforceVersion(protoimpl.MaxVersion - 20)
|
||||
)
|
||||
// Reference imports to suppress errors if they are not otherwise used.
|
||||
var _ = proto.Marshal
|
||||
var _ = fmt.Errorf
|
||||
var _ = math.Inf
|
||||
|
||||
// This is a compile-time assertion that a sufficiently up-to-date version
|
||||
// of the legacy proto package is being used.
|
||||
const _ = proto.ProtoPackageIsVersion4
|
||||
// This is a compile-time assertion to ensure that this generated file
|
||||
// is compatible with the proto package it is being compiled against.
|
||||
// A compilation error at this line likely means your copy of the
|
||||
// proto package needs to be updated.
|
||||
const _ = proto.ProtoPackageIsVersion3 // please upgrade the proto package
|
||||
|
||||
var File_people_proto protoreflect.FileDescriptor
|
||||
|
||||
var file_people_proto_rawDesc = []byte{
|
||||
0x0a, 0x0c, 0x70, 0x65, 0x6f, 0x70, 0x6c, 0x65, 0x2e, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x12, 0x04,
|
||||
0x6d, 0x61, 0x69, 0x6e, 0x1a, 0x1c, 0x67, 0x6f, 0x6f, 0x67, 0x6c, 0x65, 0x2f, 0x61, 0x70, 0x69,
|
||||
0x2f, 0x61, 0x6e, 0x6e, 0x6f, 0x74, 0x61, 0x74, 0x69, 0x6f, 0x6e, 0x73, 0x2e, 0x70, 0x72, 0x6f,
|
||||
0x74, 0x6f, 0x1a, 0x0a, 0x62, 0x61, 0x73, 0x65, 0x2e, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x32, 0xda,
|
||||
0x01, 0x0a, 0x04, 0x4e, 0x61, 0x6d, 0x65, 0x12, 0x46, 0x0a, 0x09, 0x46, 0x69, 0x72, 0x73, 0x74,
|
||||
0x4e, 0x61, 0x6d, 0x65, 0x12, 0x0d, 0x2e, 0x6d, 0x61, 0x69, 0x6e, 0x2e, 0x52, 0x65, 0x71, 0x75,
|
||||
0x65, 0x73, 0x74, 0x1a, 0x0b, 0x2e, 0x6d, 0x61, 0x69, 0x6e, 0x2e, 0x52, 0x65, 0x70, 0x6c, 0x79,
|
||||
0x22, 0x1d, 0x82, 0xd3, 0xe4, 0x93, 0x02, 0x17, 0x22, 0x12, 0x2f, 0x76, 0x31, 0x2f, 0x6e, 0x61,
|
||||
0x6d, 0x65, 0x2f, 0x66, 0x69, 0x72, 0x73, 0x74, 0x6e, 0x61, 0x6d, 0x65, 0x3a, 0x01, 0x2a, 0x12,
|
||||
0x44, 0x0a, 0x08, 0x4c, 0x61, 0x73, 0x74, 0x4e, 0x61, 0x6d, 0x65, 0x12, 0x0d, 0x2e, 0x6d, 0x61,
|
||||
0x69, 0x6e, 0x2e, 0x52, 0x65, 0x71, 0x75, 0x65, 0x73, 0x74, 0x1a, 0x0b, 0x2e, 0x6d, 0x61, 0x69,
|
||||
0x6e, 0x2e, 0x52, 0x65, 0x70, 0x6c, 0x79, 0x22, 0x1c, 0x82, 0xd3, 0xe4, 0x93, 0x02, 0x16, 0x22,
|
||||
0x11, 0x2f, 0x76, 0x31, 0x2f, 0x6e, 0x61, 0x6d, 0x65, 0x2f, 0x6c, 0x61, 0x73, 0x74, 0x6e, 0x61,
|
||||
0x6d, 0x65, 0x3a, 0x01, 0x2a, 0x12, 0x44, 0x0a, 0x08, 0x46, 0x75, 0x6c, 0x6c, 0x4e, 0x61, 0x6d,
|
||||
0x65, 0x12, 0x0d, 0x2e, 0x6d, 0x61, 0x69, 0x6e, 0x2e, 0x52, 0x65, 0x71, 0x75, 0x65, 0x73, 0x74,
|
||||
0x1a, 0x0b, 0x2e, 0x6d, 0x61, 0x69, 0x6e, 0x2e, 0x52, 0x65, 0x70, 0x6c, 0x79, 0x22, 0x1c, 0x82,
|
||||
0xd3, 0xe4, 0x93, 0x02, 0x16, 0x22, 0x11, 0x2f, 0x76, 0x31, 0x2f, 0x6e, 0x61, 0x6d, 0x65, 0x2f,
|
||||
0x66, 0x75, 0x6c, 0x6c, 0x6e, 0x61, 0x6d, 0x65, 0x3a, 0x01, 0x2a, 0x42, 0x08, 0x5a, 0x06, 0x2e,
|
||||
0x3b, 0x6d, 0x61, 0x69, 0x6e, 0x62, 0x06, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x33,
|
||||
func init() {
|
||||
proto.RegisterFile("people.proto", fileDescriptor_09461903b56db210)
|
||||
}
|
||||
|
||||
var file_people_proto_goTypes = []interface{}{
|
||||
(*Request)(nil), // 0: main.Request
|
||||
(*Reply)(nil), // 1: main.Reply
|
||||
}
|
||||
var file_people_proto_depIdxs = []int32{
|
||||
0, // 0: main.Name.FirstName:input_type -> main.Request
|
||||
0, // 1: main.Name.LastName:input_type -> main.Request
|
||||
0, // 2: main.Name.FullName:input_type -> main.Request
|
||||
1, // 3: main.Name.FirstName:output_type -> main.Reply
|
||||
1, // 4: main.Name.LastName:output_type -> main.Reply
|
||||
1, // 5: main.Name.FullName:output_type -> main.Reply
|
||||
3, // [3:6] is the sub-list for method output_type
|
||||
0, // [0:3] is the sub-list for method input_type
|
||||
0, // [0:0] is the sub-list for extension type_name
|
||||
0, // [0:0] is the sub-list for extension extendee
|
||||
0, // [0:0] is the sub-list for field type_name
|
||||
}
|
||||
|
||||
func init() { file_people_proto_init() }
|
||||
func file_people_proto_init() {
|
||||
if File_people_proto != nil {
|
||||
return
|
||||
}
|
||||
file_base_proto_init()
|
||||
type x struct{}
|
||||
out := protoimpl.TypeBuilder{
|
||||
File: protoimpl.DescBuilder{
|
||||
GoPackagePath: reflect.TypeOf(x{}).PkgPath(),
|
||||
RawDescriptor: file_people_proto_rawDesc,
|
||||
NumEnums: 0,
|
||||
NumMessages: 0,
|
||||
NumExtensions: 0,
|
||||
NumServices: 1,
|
||||
},
|
||||
GoTypes: file_people_proto_goTypes,
|
||||
DependencyIndexes: file_people_proto_depIdxs,
|
||||
}.Build()
|
||||
File_people_proto = out.File
|
||||
file_people_proto_rawDesc = nil
|
||||
file_people_proto_goTypes = nil
|
||||
file_people_proto_depIdxs = nil
|
||||
var fileDescriptor_09461903b56db210 = []byte{
|
||||
// 190 bytes of a gzipped FileDescriptorProto
|
||||
0x1f, 0x8b, 0x08, 0x00, 0x00, 0x00, 0x00, 0x00, 0x02, 0xff, 0xe2, 0xe2, 0x29, 0x48, 0xcd, 0x2f,
|
||||
0xc8, 0x49, 0xd5, 0x2b, 0x28, 0xca, 0x2f, 0xc9, 0x17, 0x62, 0xc9, 0x4d, 0xcc, 0xcc, 0x93, 0x92,
|
||||
0x49, 0xcf, 0xcf, 0x4f, 0xcf, 0x49, 0xd5, 0x4f, 0x2c, 0xc8, 0xd4, 0x4f, 0xcc, 0xcb, 0xcb, 0x2f,
|
||||
0x49, 0x2c, 0xc9, 0xcc, 0xcf, 0x2b, 0x86, 0xa8, 0x91, 0xe2, 0x4a, 0x4a, 0x2c, 0x86, 0xaa, 0x37,
|
||||
0xba, 0xc5, 0xc8, 0xc5, 0xe2, 0x97, 0x98, 0x9b, 0x2a, 0xe4, 0xc6, 0xc5, 0xe9, 0x96, 0x59, 0x54,
|
||||
0x5c, 0x02, 0xe6, 0xf0, 0xea, 0x81, 0x8c, 0xd1, 0x0b, 0x4a, 0x2d, 0x2c, 0x4d, 0x2d, 0x2e, 0x91,
|
||||
0xe2, 0x86, 0x71, 0x0b, 0x72, 0x2a, 0x95, 0x64, 0x9b, 0x2e, 0x3f, 0x99, 0xcc, 0x24, 0xae, 0x24,
|
||||
0xa4, 0x5f, 0x66, 0xa8, 0x9f, 0x97, 0x98, 0x9b, 0xaa, 0x9f, 0x06, 0xd2, 0x07, 0x62, 0x59, 0x31,
|
||||
0x6a, 0x09, 0xb9, 0x70, 0x71, 0xf8, 0x24, 0x12, 0x61, 0x8c, 0x0c, 0xd8, 0x18, 0x31, 0x25, 0x41,
|
||||
0xb8, 0x31, 0x39, 0x89, 0x28, 0xa6, 0xb8, 0x95, 0xe6, 0xe4, 0x90, 0x61, 0x4a, 0x5a, 0x69, 0x4e,
|
||||
0x0e, 0xd4, 0x14, 0x27, 0x8e, 0x28, 0x36, 0x3d, 0x6b, 0x90, 0xea, 0x24, 0x36, 0xb0, 0x6f, 0x8d,
|
||||
0x01, 0x01, 0x00, 0x00, 0xff, 0xff, 0x9f, 0x0c, 0x50, 0xa2, 0x2d, 0x01, 0x00, 0x00,
|
||||
}
|
||||
|
||||
// Reference imports to suppress errors if they are not otherwise used.
|
||||
|
@ -161,13 +110,13 @@ type NameServer interface {
|
|||
type UnimplementedNameServer struct {
|
||||
}
|
||||
|
||||
func (*UnimplementedNameServer) FirstName(context.Context, *Request) (*Reply, error) {
|
||||
func (*UnimplementedNameServer) FirstName(ctx context.Context, req *Request) (*Reply, error) {
|
||||
return nil, status.Errorf(codes.Unimplemented, "method FirstName not implemented")
|
||||
}
|
||||
func (*UnimplementedNameServer) LastName(context.Context, *Request) (*Reply, error) {
|
||||
func (*UnimplementedNameServer) LastName(ctx context.Context, req *Request) (*Reply, error) {
|
||||
return nil, status.Errorf(codes.Unimplemented, "method LastName not implemented")
|
||||
}
|
||||
func (*UnimplementedNameServer) FullName(context.Context, *Request) (*Reply, error) {
|
||||
func (*UnimplementedNameServer) FullName(ctx context.Context, req *Request) (*Reply, error) {
|
||||
return nil, status.Errorf(codes.Unimplemented, "method FullName not implemented")
|
||||
}
|
||||
|
||||
|
|
57
proto/province.proto
Normal file
57
proto/province.proto
Normal file
|
@ -0,0 +1,57 @@
|
|||
syntax = "proto3";
|
||||
|
||||
package main;
|
||||
|
||||
option go_package = ".;main";
|
||||
|
||||
|
||||
import "base.proto";
|
||||
import "google/api/annotations.proto";
|
||||
|
||||
|
||||
// The greeting service definition.
|
||||
service ProvinceAreaCity {
|
||||
// Sends a greeting
|
||||
rpc Province (Request) returns (NameCodeReply){
|
||||
option (google.api.http) = {
|
||||
post: "/v1/province/namecode"
|
||||
body: "*"
|
||||
};
|
||||
}
|
||||
|
||||
rpc Area (Request) returns (NameCodeReply){
|
||||
option (google.api.http) = {
|
||||
post: "/v1/area/namecode"
|
||||
body: "*"
|
||||
};
|
||||
}
|
||||
|
||||
rpc City (Request) returns (NameCodeReply){
|
||||
option (google.api.http) = {
|
||||
post: "/v1/city/namecode"
|
||||
body: "*"
|
||||
};
|
||||
}
|
||||
|
||||
// rpc CityParent (Request) returns (NameCodeReply){
|
||||
// option (google.api.http) = {
|
||||
// post: "/v1/city/namecode/parent"
|
||||
// body: "*"
|
||||
// };
|
||||
// }
|
||||
}
|
||||
|
||||
|
||||
// The response message containing the greetings
|
||||
message NameCodeReply {
|
||||
string name = 1;
|
||||
string code = 2;
|
||||
}
|
||||
|
||||
|
||||
|
||||
// enum NameType {
|
||||
// FullName = 0;
|
||||
// FirstName = 1;
|
||||
// LastName = 2 ;
|
||||
// }
|
58
province.go
Normal file
58
province.go
Normal file
|
@ -0,0 +1,58 @@
|
|||
package main
|
||||
|
||||
import (
|
||||
context "context"
|
||||
"encoding/gob"
|
||||
)
|
||||
|
||||
// NameCode 省份地区的结构
|
||||
type NameCode struct {
|
||||
Name string
|
||||
Code string
|
||||
Child []*NameCode
|
||||
}
|
||||
|
||||
var province = &KeyList{}
|
||||
|
||||
func init() {
|
||||
gob.Register(NameCode{})
|
||||
LoadGob("./data/province.gob", province)
|
||||
}
|
||||
|
||||
type provinceserver struct {
|
||||
}
|
||||
|
||||
func (ps *provinceserver) Province(ctx context.Context, req *Request) (*NameCodeReply, error) {
|
||||
reply := &NameCodeReply{}
|
||||
|
||||
nc := GetRandomKeyByList(province.GetKeys()).(NameCode)
|
||||
reply.Name = nc.Name
|
||||
reply.Code = nc.Code
|
||||
|
||||
return reply, nil
|
||||
}
|
||||
|
||||
func (ps *provinceserver) Area(ctx context.Context, req *Request) (*NameCodeReply, error) {
|
||||
reply := &NameCodeReply{}
|
||||
|
||||
nc := GetRandomKeyByList(province.GetKeys()).(NameCode)
|
||||
areanc := GetRandomKeyByList(nc.Child).(*NameCode)
|
||||
|
||||
reply.Name = areanc.Name
|
||||
reply.Code = areanc.Code
|
||||
|
||||
return reply, nil
|
||||
}
|
||||
|
||||
func (ps *provinceserver) City(ctx context.Context, req *Request) (*NameCodeReply, error) {
|
||||
reply := &NameCodeReply{}
|
||||
|
||||
nc := GetRandomKeyByList(province.GetKeys()).(NameCode)
|
||||
areanc := GetRandomKeyByList(nc.Child).(*NameCode)
|
||||
citync := GetRandomKeyByList(areanc.Child).(*NameCode)
|
||||
|
||||
reply.Name = citync.Name
|
||||
reply.Code = citync.Code
|
||||
|
||||
return reply, nil
|
||||
}
|
255
province.pb.go
Normal file
255
province.pb.go
Normal file
|
@ -0,0 +1,255 @@
|
|||
// Code generated by protoc-gen-go. DO NOT EDIT.
|
||||
// source: province.proto
|
||||
|
||||
package main
|
||||
|
||||
import (
|
||||
context "context"
|
||||
fmt "fmt"
|
||||
proto "github.com/golang/protobuf/proto"
|
||||
_ "google.golang.org/genproto/googleapis/api/annotations"
|
||||
grpc "google.golang.org/grpc"
|
||||
codes "google.golang.org/grpc/codes"
|
||||
status "google.golang.org/grpc/status"
|
||||
math "math"
|
||||
)
|
||||
|
||||
// Reference imports to suppress errors if they are not otherwise used.
|
||||
var _ = proto.Marshal
|
||||
var _ = fmt.Errorf
|
||||
var _ = math.Inf
|
||||
|
||||
// This is a compile-time assertion to ensure that this generated file
|
||||
// is compatible with the proto package it is being compiled against.
|
||||
// A compilation error at this line likely means your copy of the
|
||||
// proto package needs to be updated.
|
||||
const _ = proto.ProtoPackageIsVersion3 // please upgrade the proto package
|
||||
|
||||
// The response message containing the greetings
|
||||
type NameCodeReply struct {
|
||||
Name string `protobuf:"bytes,1,opt,name=name,proto3" json:"name,omitempty"`
|
||||
Code string `protobuf:"bytes,2,opt,name=code,proto3" json:"code,omitempty"`
|
||||
XXX_NoUnkeyedLiteral struct{} `json:"-"`
|
||||
XXX_unrecognized []byte `json:"-"`
|
||||
XXX_sizecache int32 `json:"-"`
|
||||
}
|
||||
|
||||
func (m *NameCodeReply) Reset() { *m = NameCodeReply{} }
|
||||
func (m *NameCodeReply) String() string { return proto.CompactTextString(m) }
|
||||
func (*NameCodeReply) ProtoMessage() {}
|
||||
func (*NameCodeReply) Descriptor() ([]byte, []int) {
|
||||
return fileDescriptor_e183bc545e5b5a19, []int{0}
|
||||
}
|
||||
|
||||
func (m *NameCodeReply) XXX_Unmarshal(b []byte) error {
|
||||
return xxx_messageInfo_NameCodeReply.Unmarshal(m, b)
|
||||
}
|
||||
func (m *NameCodeReply) XXX_Marshal(b []byte, deterministic bool) ([]byte, error) {
|
||||
return xxx_messageInfo_NameCodeReply.Marshal(b, m, deterministic)
|
||||
}
|
||||
func (m *NameCodeReply) XXX_Merge(src proto.Message) {
|
||||
xxx_messageInfo_NameCodeReply.Merge(m, src)
|
||||
}
|
||||
func (m *NameCodeReply) XXX_Size() int {
|
||||
return xxx_messageInfo_NameCodeReply.Size(m)
|
||||
}
|
||||
func (m *NameCodeReply) XXX_DiscardUnknown() {
|
||||
xxx_messageInfo_NameCodeReply.DiscardUnknown(m)
|
||||
}
|
||||
|
||||
var xxx_messageInfo_NameCodeReply proto.InternalMessageInfo
|
||||
|
||||
func (m *NameCodeReply) GetName() string {
|
||||
if m != nil {
|
||||
return m.Name
|
||||
}
|
||||
return ""
|
||||
}
|
||||
|
||||
func (m *NameCodeReply) GetCode() string {
|
||||
if m != nil {
|
||||
return m.Code
|
||||
}
|
||||
return ""
|
||||
}
|
||||
|
||||
func init() {
|
||||
proto.RegisterType((*NameCodeReply)(nil), "main.NameCodeReply")
|
||||
}
|
||||
|
||||
func init() {
|
||||
proto.RegisterFile("province.proto", fileDescriptor_e183bc545e5b5a19)
|
||||
}
|
||||
|
||||
var fileDescriptor_e183bc545e5b5a19 = []byte{
|
||||
// 238 bytes of a gzipped FileDescriptorProto
|
||||
0x1f, 0x8b, 0x08, 0x00, 0x00, 0x00, 0x00, 0x00, 0x02, 0xff, 0xe2, 0xe2, 0x2b, 0x28, 0xca, 0x2f,
|
||||
0xcb, 0xcc, 0x4b, 0x4e, 0xd5, 0x2b, 0x28, 0xca, 0x2f, 0xc9, 0x17, 0x62, 0xc9, 0x4d, 0xcc, 0xcc,
|
||||
0x93, 0xe2, 0x4a, 0x4a, 0x2c, 0x86, 0x8a, 0x48, 0xc9, 0xa4, 0xe7, 0xe7, 0xa7, 0xe7, 0xa4, 0xea,
|
||||
0x27, 0x16, 0x64, 0xea, 0x27, 0xe6, 0xe5, 0xe5, 0x97, 0x24, 0x96, 0x64, 0xe6, 0xe7, 0x15, 0x43,
|
||||
0x64, 0x95, 0xcc, 0xb9, 0x78, 0xfd, 0x12, 0x73, 0x53, 0x9d, 0xf3, 0x53, 0x52, 0x83, 0x52, 0x0b,
|
||||
0x72, 0x2a, 0x85, 0x84, 0xb8, 0x58, 0xf2, 0x12, 0x73, 0x53, 0x25, 0x18, 0x15, 0x18, 0x35, 0x38,
|
||||
0x83, 0xc0, 0x6c, 0x90, 0x58, 0x72, 0x7e, 0x4a, 0xaa, 0x04, 0x13, 0x44, 0x0c, 0xc4, 0x36, 0xfa,
|
||||
0xc1, 0xc8, 0x25, 0x10, 0x00, 0xb5, 0xdb, 0xb1, 0x28, 0x35, 0xd1, 0x39, 0xb3, 0xa4, 0x52, 0x28,
|
||||
0x80, 0x8b, 0x03, 0x26, 0x26, 0xc4, 0xab, 0x07, 0x72, 0x8a, 0x5e, 0x50, 0x6a, 0x61, 0x69, 0x6a,
|
||||
0x71, 0x89, 0x94, 0x30, 0x84, 0x8b, 0x62, 0x99, 0x92, 0x42, 0xd3, 0xe5, 0x27, 0x93, 0x99, 0xa4,
|
||||
0x94, 0x44, 0xf5, 0xcb, 0x0c, 0xf5, 0x61, 0x3e, 0xd1, 0x07, 0xd9, 0x09, 0xb2, 0xc3, 0x8a, 0x51,
|
||||
0x4b, 0xc8, 0x83, 0x8b, 0x05, 0x64, 0x3a, 0x51, 0xa6, 0xc9, 0x80, 0x4d, 0x13, 0x53, 0x12, 0x04,
|
||||
0x99, 0x96, 0x58, 0x94, 0x9a, 0x88, 0x6e, 0x12, 0xd8, 0x8d, 0x24, 0x9b, 0x94, 0x9c, 0x59, 0x52,
|
||||
0x89, 0x6c, 0x92, 0x13, 0x47, 0x14, 0x9b, 0x9e, 0x35, 0x48, 0x57, 0x12, 0x1b, 0x38, 0x10, 0x8d,
|
||||
0x01, 0x01, 0x00, 0x00, 0xff, 0xff, 0xb0, 0xf8, 0xff, 0xa1, 0x86, 0x01, 0x00, 0x00,
|
||||
}
|
||||
|
||||
// Reference imports to suppress errors if they are not otherwise used.
|
||||
var _ context.Context
|
||||
var _ grpc.ClientConnInterface
|
||||
|
||||
// This is a compile-time assertion to ensure that this generated file
|
||||
// is compatible with the grpc package it is being compiled against.
|
||||
const _ = grpc.SupportPackageIsVersion6
|
||||
|
||||
// ProvinceAreaCityClient is the client API for ProvinceAreaCity service.
|
||||
//
|
||||
// For semantics around ctx use and closing/ending streaming RPCs, please refer to https://godoc.org/google.golang.org/grpc#ClientConn.NewStream.
|
||||
type ProvinceAreaCityClient interface {
|
||||
// Sends a greeting
|
||||
Province(ctx context.Context, in *Request, opts ...grpc.CallOption) (*NameCodeReply, error)
|
||||
Area(ctx context.Context, in *Request, opts ...grpc.CallOption) (*NameCodeReply, error)
|
||||
City(ctx context.Context, in *Request, opts ...grpc.CallOption) (*NameCodeReply, error)
|
||||
}
|
||||
|
||||
type provinceAreaCityClient struct {
|
||||
cc grpc.ClientConnInterface
|
||||
}
|
||||
|
||||
func NewProvinceAreaCityClient(cc grpc.ClientConnInterface) ProvinceAreaCityClient {
|
||||
return &provinceAreaCityClient{cc}
|
||||
}
|
||||
|
||||
func (c *provinceAreaCityClient) Province(ctx context.Context, in *Request, opts ...grpc.CallOption) (*NameCodeReply, error) {
|
||||
out := new(NameCodeReply)
|
||||
err := c.cc.Invoke(ctx, "/main.ProvinceAreaCity/Province", in, out, opts...)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
return out, nil
|
||||
}
|
||||
|
||||
func (c *provinceAreaCityClient) Area(ctx context.Context, in *Request, opts ...grpc.CallOption) (*NameCodeReply, error) {
|
||||
out := new(NameCodeReply)
|
||||
err := c.cc.Invoke(ctx, "/main.ProvinceAreaCity/Area", in, out, opts...)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
return out, nil
|
||||
}
|
||||
|
||||
func (c *provinceAreaCityClient) City(ctx context.Context, in *Request, opts ...grpc.CallOption) (*NameCodeReply, error) {
|
||||
out := new(NameCodeReply)
|
||||
err := c.cc.Invoke(ctx, "/main.ProvinceAreaCity/City", in, out, opts...)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
return out, nil
|
||||
}
|
||||
|
||||
// ProvinceAreaCityServer is the server API for ProvinceAreaCity service.
|
||||
type ProvinceAreaCityServer interface {
|
||||
// Sends a greeting
|
||||
Province(context.Context, *Request) (*NameCodeReply, error)
|
||||
Area(context.Context, *Request) (*NameCodeReply, error)
|
||||
City(context.Context, *Request) (*NameCodeReply, error)
|
||||
}
|
||||
|
||||
// UnimplementedProvinceAreaCityServer can be embedded to have forward compatible implementations.
|
||||
type UnimplementedProvinceAreaCityServer struct {
|
||||
}
|
||||
|
||||
func (*UnimplementedProvinceAreaCityServer) Province(ctx context.Context, req *Request) (*NameCodeReply, error) {
|
||||
return nil, status.Errorf(codes.Unimplemented, "method Province not implemented")
|
||||
}
|
||||
func (*UnimplementedProvinceAreaCityServer) Area(ctx context.Context, req *Request) (*NameCodeReply, error) {
|
||||
return nil, status.Errorf(codes.Unimplemented, "method Area not implemented")
|
||||
}
|
||||
func (*UnimplementedProvinceAreaCityServer) City(ctx context.Context, req *Request) (*NameCodeReply, error) {
|
||||
return nil, status.Errorf(codes.Unimplemented, "method City not implemented")
|
||||
}
|
||||
|
||||
func RegisterProvinceAreaCityServer(s *grpc.Server, srv ProvinceAreaCityServer) {
|
||||
s.RegisterService(&_ProvinceAreaCity_serviceDesc, srv)
|
||||
}
|
||||
|
||||
func _ProvinceAreaCity_Province_Handler(srv interface{}, ctx context.Context, dec func(interface{}) error, interceptor grpc.UnaryServerInterceptor) (interface{}, error) {
|
||||
in := new(Request)
|
||||
if err := dec(in); err != nil {
|
||||
return nil, err
|
||||
}
|
||||
if interceptor == nil {
|
||||
return srv.(ProvinceAreaCityServer).Province(ctx, in)
|
||||
}
|
||||
info := &grpc.UnaryServerInfo{
|
||||
Server: srv,
|
||||
FullMethod: "/main.ProvinceAreaCity/Province",
|
||||
}
|
||||
handler := func(ctx context.Context, req interface{}) (interface{}, error) {
|
||||
return srv.(ProvinceAreaCityServer).Province(ctx, req.(*Request))
|
||||
}
|
||||
return interceptor(ctx, in, info, handler)
|
||||
}
|
||||
|
||||
func _ProvinceAreaCity_Area_Handler(srv interface{}, ctx context.Context, dec func(interface{}) error, interceptor grpc.UnaryServerInterceptor) (interface{}, error) {
|
||||
in := new(Request)
|
||||
if err := dec(in); err != nil {
|
||||
return nil, err
|
||||
}
|
||||
if interceptor == nil {
|
||||
return srv.(ProvinceAreaCityServer).Area(ctx, in)
|
||||
}
|
||||
info := &grpc.UnaryServerInfo{
|
||||
Server: srv,
|
||||
FullMethod: "/main.ProvinceAreaCity/Area",
|
||||
}
|
||||
handler := func(ctx context.Context, req interface{}) (interface{}, error) {
|
||||
return srv.(ProvinceAreaCityServer).Area(ctx, req.(*Request))
|
||||
}
|
||||
return interceptor(ctx, in, info, handler)
|
||||
}
|
||||
|
||||
func _ProvinceAreaCity_City_Handler(srv interface{}, ctx context.Context, dec func(interface{}) error, interceptor grpc.UnaryServerInterceptor) (interface{}, error) {
|
||||
in := new(Request)
|
||||
if err := dec(in); err != nil {
|
||||
return nil, err
|
||||
}
|
||||
if interceptor == nil {
|
||||
return srv.(ProvinceAreaCityServer).City(ctx, in)
|
||||
}
|
||||
info := &grpc.UnaryServerInfo{
|
||||
Server: srv,
|
||||
FullMethod: "/main.ProvinceAreaCity/City",
|
||||
}
|
||||
handler := func(ctx context.Context, req interface{}) (interface{}, error) {
|
||||
return srv.(ProvinceAreaCityServer).City(ctx, req.(*Request))
|
||||
}
|
||||
return interceptor(ctx, in, info, handler)
|
||||
}
|
||||
|
||||
var _ProvinceAreaCity_serviceDesc = grpc.ServiceDesc{
|
||||
ServiceName: "main.ProvinceAreaCity",
|
||||
HandlerType: (*ProvinceAreaCityServer)(nil),
|
||||
Methods: []grpc.MethodDesc{
|
||||
{
|
||||
MethodName: "Province",
|
||||
Handler: _ProvinceAreaCity_Province_Handler,
|
||||
},
|
||||
{
|
||||
MethodName: "Area",
|
||||
Handler: _ProvinceAreaCity_Area_Handler,
|
||||
},
|
||||
{
|
||||
MethodName: "City",
|
||||
Handler: _ProvinceAreaCity_City_Handler,
|
||||
},
|
||||
},
|
||||
Streams: []grpc.StreamDesc{},
|
||||
Metadata: "province.proto",
|
||||
}
|
319
province.pb.gw.go
Normal file
319
province.pb.gw.go
Normal file
|
@ -0,0 +1,319 @@
|
|||
// Code generated by protoc-gen-grpc-gateway. DO NOT EDIT.
|
||||
// source: province.proto
|
||||
|
||||
/*
|
||||
Package main is a reverse proxy.
|
||||
|
||||
It translates gRPC into RESTful JSON APIs.
|
||||
*/
|
||||
package main
|
||||
|
||||
import (
|
||||
"context"
|
||||
"io"
|
||||
"net/http"
|
||||
|
||||
"github.com/golang/protobuf/descriptor"
|
||||
"github.com/golang/protobuf/proto"
|
||||
"github.com/grpc-ecosystem/grpc-gateway/runtime"
|
||||
"github.com/grpc-ecosystem/grpc-gateway/utilities"
|
||||
"google.golang.org/grpc"
|
||||
"google.golang.org/grpc/codes"
|
||||
"google.golang.org/grpc/grpclog"
|
||||
"google.golang.org/grpc/status"
|
||||
)
|
||||
|
||||
// Suppress "imported and not used" errors
|
||||
var _ codes.Code
|
||||
var _ io.Reader
|
||||
var _ status.Status
|
||||
var _ = runtime.String
|
||||
var _ = utilities.NewDoubleArray
|
||||
var _ = descriptor.ForMessage
|
||||
|
||||
func request_ProvinceAreaCity_Province_0(ctx context.Context, marshaler runtime.Marshaler, client ProvinceAreaCityClient, req *http.Request, pathParams map[string]string) (proto.Message, runtime.ServerMetadata, error) {
|
||||
var protoReq Request
|
||||
var metadata runtime.ServerMetadata
|
||||
|
||||
newReader, berr := utilities.IOReaderFactory(req.Body)
|
||||
if berr != nil {
|
||||
return nil, metadata, status.Errorf(codes.InvalidArgument, "%v", berr)
|
||||
}
|
||||
if err := marshaler.NewDecoder(newReader()).Decode(&protoReq); err != nil && err != io.EOF {
|
||||
return nil, metadata, status.Errorf(codes.InvalidArgument, "%v", err)
|
||||
}
|
||||
|
||||
msg, err := client.Province(ctx, &protoReq, grpc.Header(&metadata.HeaderMD), grpc.Trailer(&metadata.TrailerMD))
|
||||
return msg, metadata, err
|
||||
|
||||
}
|
||||
|
||||
func local_request_ProvinceAreaCity_Province_0(ctx context.Context, marshaler runtime.Marshaler, server ProvinceAreaCityServer, req *http.Request, pathParams map[string]string) (proto.Message, runtime.ServerMetadata, error) {
|
||||
var protoReq Request
|
||||
var metadata runtime.ServerMetadata
|
||||
|
||||
newReader, berr := utilities.IOReaderFactory(req.Body)
|
||||
if berr != nil {
|
||||
return nil, metadata, status.Errorf(codes.InvalidArgument, "%v", berr)
|
||||
}
|
||||
if err := marshaler.NewDecoder(newReader()).Decode(&protoReq); err != nil && err != io.EOF {
|
||||
return nil, metadata, status.Errorf(codes.InvalidArgument, "%v", err)
|
||||
}
|
||||
|
||||
msg, err := server.Province(ctx, &protoReq)
|
||||
return msg, metadata, err
|
||||
|
||||
}
|
||||
|
||||
func request_ProvinceAreaCity_Area_0(ctx context.Context, marshaler runtime.Marshaler, client ProvinceAreaCityClient, req *http.Request, pathParams map[string]string) (proto.Message, runtime.ServerMetadata, error) {
|
||||
var protoReq Request
|
||||
var metadata runtime.ServerMetadata
|
||||
|
||||
newReader, berr := utilities.IOReaderFactory(req.Body)
|
||||
if berr != nil {
|
||||
return nil, metadata, status.Errorf(codes.InvalidArgument, "%v", berr)
|
||||
}
|
||||
if err := marshaler.NewDecoder(newReader()).Decode(&protoReq); err != nil && err != io.EOF {
|
||||
return nil, metadata, status.Errorf(codes.InvalidArgument, "%v", err)
|
||||
}
|
||||
|
||||
msg, err := client.Area(ctx, &protoReq, grpc.Header(&metadata.HeaderMD), grpc.Trailer(&metadata.TrailerMD))
|
||||
return msg, metadata, err
|
||||
|
||||
}
|
||||
|
||||
func local_request_ProvinceAreaCity_Area_0(ctx context.Context, marshaler runtime.Marshaler, server ProvinceAreaCityServer, req *http.Request, pathParams map[string]string) (proto.Message, runtime.ServerMetadata, error) {
|
||||
var protoReq Request
|
||||
var metadata runtime.ServerMetadata
|
||||
|
||||
newReader, berr := utilities.IOReaderFactory(req.Body)
|
||||
if berr != nil {
|
||||
return nil, metadata, status.Errorf(codes.InvalidArgument, "%v", berr)
|
||||
}
|
||||
if err := marshaler.NewDecoder(newReader()).Decode(&protoReq); err != nil && err != io.EOF {
|
||||
return nil, metadata, status.Errorf(codes.InvalidArgument, "%v", err)
|
||||
}
|
||||
|
||||
msg, err := server.Area(ctx, &protoReq)
|
||||
return msg, metadata, err
|
||||
|
||||
}
|
||||
|
||||
func request_ProvinceAreaCity_City_0(ctx context.Context, marshaler runtime.Marshaler, client ProvinceAreaCityClient, req *http.Request, pathParams map[string]string) (proto.Message, runtime.ServerMetadata, error) {
|
||||
var protoReq Request
|
||||
var metadata runtime.ServerMetadata
|
||||
|
||||
newReader, berr := utilities.IOReaderFactory(req.Body)
|
||||
if berr != nil {
|
||||
return nil, metadata, status.Errorf(codes.InvalidArgument, "%v", berr)
|
||||
}
|
||||
if err := marshaler.NewDecoder(newReader()).Decode(&protoReq); err != nil && err != io.EOF {
|
||||
return nil, metadata, status.Errorf(codes.InvalidArgument, "%v", err)
|
||||
}
|
||||
|
||||
msg, err := client.City(ctx, &protoReq, grpc.Header(&metadata.HeaderMD), grpc.Trailer(&metadata.TrailerMD))
|
||||
return msg, metadata, err
|
||||
|
||||
}
|
||||
|
||||
func local_request_ProvinceAreaCity_City_0(ctx context.Context, marshaler runtime.Marshaler, server ProvinceAreaCityServer, req *http.Request, pathParams map[string]string) (proto.Message, runtime.ServerMetadata, error) {
|
||||
var protoReq Request
|
||||
var metadata runtime.ServerMetadata
|
||||
|
||||
newReader, berr := utilities.IOReaderFactory(req.Body)
|
||||
if berr != nil {
|
||||
return nil, metadata, status.Errorf(codes.InvalidArgument, "%v", berr)
|
||||
}
|
||||
if err := marshaler.NewDecoder(newReader()).Decode(&protoReq); err != nil && err != io.EOF {
|
||||
return nil, metadata, status.Errorf(codes.InvalidArgument, "%v", err)
|
||||
}
|
||||
|
||||
msg, err := server.City(ctx, &protoReq)
|
||||
return msg, metadata, err
|
||||
|
||||
}
|
||||
|
||||
// RegisterProvinceAreaCityHandlerServer registers the http handlers for service ProvinceAreaCity to "mux".
|
||||
// UnaryRPC :call ProvinceAreaCityServer directly.
|
||||
// StreamingRPC :currently unsupported pending https://github.com/grpc/grpc-go/issues/906.
|
||||
func RegisterProvinceAreaCityHandlerServer(ctx context.Context, mux *runtime.ServeMux, server ProvinceAreaCityServer) error {
|
||||
|
||||
mux.Handle("POST", pattern_ProvinceAreaCity_Province_0, func(w http.ResponseWriter, req *http.Request, pathParams map[string]string) {
|
||||
ctx, cancel := context.WithCancel(req.Context())
|
||||
defer cancel()
|
||||
inboundMarshaler, outboundMarshaler := runtime.MarshalerForRequest(mux, req)
|
||||
rctx, err := runtime.AnnotateIncomingContext(ctx, mux, req)
|
||||
if err != nil {
|
||||
runtime.HTTPError(ctx, mux, outboundMarshaler, w, req, err)
|
||||
return
|
||||
}
|
||||
resp, md, err := local_request_ProvinceAreaCity_Province_0(rctx, inboundMarshaler, server, req, pathParams)
|
||||
ctx = runtime.NewServerMetadataContext(ctx, md)
|
||||
if err != nil {
|
||||
runtime.HTTPError(ctx, mux, outboundMarshaler, w, req, err)
|
||||
return
|
||||
}
|
||||
|
||||
forward_ProvinceAreaCity_Province_0(ctx, mux, outboundMarshaler, w, req, resp, mux.GetForwardResponseOptions()...)
|
||||
|
||||
})
|
||||
|
||||
mux.Handle("POST", pattern_ProvinceAreaCity_Area_0, func(w http.ResponseWriter, req *http.Request, pathParams map[string]string) {
|
||||
ctx, cancel := context.WithCancel(req.Context())
|
||||
defer cancel()
|
||||
inboundMarshaler, outboundMarshaler := runtime.MarshalerForRequest(mux, req)
|
||||
rctx, err := runtime.AnnotateIncomingContext(ctx, mux, req)
|
||||
if err != nil {
|
||||
runtime.HTTPError(ctx, mux, outboundMarshaler, w, req, err)
|
||||
return
|
||||
}
|
||||
resp, md, err := local_request_ProvinceAreaCity_Area_0(rctx, inboundMarshaler, server, req, pathParams)
|
||||
ctx = runtime.NewServerMetadataContext(ctx, md)
|
||||
if err != nil {
|
||||
runtime.HTTPError(ctx, mux, outboundMarshaler, w, req, err)
|
||||
return
|
||||
}
|
||||
|
||||
forward_ProvinceAreaCity_Area_0(ctx, mux, outboundMarshaler, w, req, resp, mux.GetForwardResponseOptions()...)
|
||||
|
||||
})
|
||||
|
||||
mux.Handle("POST", pattern_ProvinceAreaCity_City_0, func(w http.ResponseWriter, req *http.Request, pathParams map[string]string) {
|
||||
ctx, cancel := context.WithCancel(req.Context())
|
||||
defer cancel()
|
||||
inboundMarshaler, outboundMarshaler := runtime.MarshalerForRequest(mux, req)
|
||||
rctx, err := runtime.AnnotateIncomingContext(ctx, mux, req)
|
||||
if err != nil {
|
||||
runtime.HTTPError(ctx, mux, outboundMarshaler, w, req, err)
|
||||
return
|
||||
}
|
||||
resp, md, err := local_request_ProvinceAreaCity_City_0(rctx, inboundMarshaler, server, req, pathParams)
|
||||
ctx = runtime.NewServerMetadataContext(ctx, md)
|
||||
if err != nil {
|
||||
runtime.HTTPError(ctx, mux, outboundMarshaler, w, req, err)
|
||||
return
|
||||
}
|
||||
|
||||
forward_ProvinceAreaCity_City_0(ctx, mux, outboundMarshaler, w, req, resp, mux.GetForwardResponseOptions()...)
|
||||
|
||||
})
|
||||
|
||||
return nil
|
||||
}
|
||||
|
||||
// RegisterProvinceAreaCityHandlerFromEndpoint is same as RegisterProvinceAreaCityHandler but
|
||||
// automatically dials to "endpoint" and closes the connection when "ctx" gets done.
|
||||
func RegisterProvinceAreaCityHandlerFromEndpoint(ctx context.Context, mux *runtime.ServeMux, endpoint string, opts []grpc.DialOption) (err error) {
|
||||
conn, err := grpc.Dial(endpoint, opts...)
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
defer func() {
|
||||
if err != nil {
|
||||
if cerr := conn.Close(); cerr != nil {
|
||||
grpclog.Infof("Failed to close conn to %s: %v", endpoint, cerr)
|
||||
}
|
||||
return
|
||||
}
|
||||
go func() {
|
||||
<-ctx.Done()
|
||||
if cerr := conn.Close(); cerr != nil {
|
||||
grpclog.Infof("Failed to close conn to %s: %v", endpoint, cerr)
|
||||
}
|
||||
}()
|
||||
}()
|
||||
|
||||
return RegisterProvinceAreaCityHandler(ctx, mux, conn)
|
||||
}
|
||||
|
||||
// RegisterProvinceAreaCityHandler registers the http handlers for service ProvinceAreaCity to "mux".
|
||||
// The handlers forward requests to the grpc endpoint over "conn".
|
||||
func RegisterProvinceAreaCityHandler(ctx context.Context, mux *runtime.ServeMux, conn *grpc.ClientConn) error {
|
||||
return RegisterProvinceAreaCityHandlerClient(ctx, mux, NewProvinceAreaCityClient(conn))
|
||||
}
|
||||
|
||||
// RegisterProvinceAreaCityHandlerClient registers the http handlers for service ProvinceAreaCity
|
||||
// to "mux". The handlers forward requests to the grpc endpoint over the given implementation of "ProvinceAreaCityClient".
|
||||
// Note: the gRPC framework executes interceptors within the gRPC handler. If the passed in "ProvinceAreaCityClient"
|
||||
// doesn't go through the normal gRPC flow (creating a gRPC client etc.) then it will be up to the passed in
|
||||
// "ProvinceAreaCityClient" to call the correct interceptors.
|
||||
func RegisterProvinceAreaCityHandlerClient(ctx context.Context, mux *runtime.ServeMux, client ProvinceAreaCityClient) error {
|
||||
|
||||
mux.Handle("POST", pattern_ProvinceAreaCity_Province_0, func(w http.ResponseWriter, req *http.Request, pathParams map[string]string) {
|
||||
ctx, cancel := context.WithCancel(req.Context())
|
||||
defer cancel()
|
||||
inboundMarshaler, outboundMarshaler := runtime.MarshalerForRequest(mux, req)
|
||||
rctx, err := runtime.AnnotateContext(ctx, mux, req)
|
||||
if err != nil {
|
||||
runtime.HTTPError(ctx, mux, outboundMarshaler, w, req, err)
|
||||
return
|
||||
}
|
||||
resp, md, err := request_ProvinceAreaCity_Province_0(rctx, inboundMarshaler, client, req, pathParams)
|
||||
ctx = runtime.NewServerMetadataContext(ctx, md)
|
||||
if err != nil {
|
||||
runtime.HTTPError(ctx, mux, outboundMarshaler, w, req, err)
|
||||
return
|
||||
}
|
||||
|
||||
forward_ProvinceAreaCity_Province_0(ctx, mux, outboundMarshaler, w, req, resp, mux.GetForwardResponseOptions()...)
|
||||
|
||||
})
|
||||
|
||||
mux.Handle("POST", pattern_ProvinceAreaCity_Area_0, func(w http.ResponseWriter, req *http.Request, pathParams map[string]string) {
|
||||
ctx, cancel := context.WithCancel(req.Context())
|
||||
defer cancel()
|
||||
inboundMarshaler, outboundMarshaler := runtime.MarshalerForRequest(mux, req)
|
||||
rctx, err := runtime.AnnotateContext(ctx, mux, req)
|
||||
if err != nil {
|
||||
runtime.HTTPError(ctx, mux, outboundMarshaler, w, req, err)
|
||||
return
|
||||
}
|
||||
resp, md, err := request_ProvinceAreaCity_Area_0(rctx, inboundMarshaler, client, req, pathParams)
|
||||
ctx = runtime.NewServerMetadataContext(ctx, md)
|
||||
if err != nil {
|
||||
runtime.HTTPError(ctx, mux, outboundMarshaler, w, req, err)
|
||||
return
|
||||
}
|
||||
|
||||
forward_ProvinceAreaCity_Area_0(ctx, mux, outboundMarshaler, w, req, resp, mux.GetForwardResponseOptions()...)
|
||||
|
||||
})
|
||||
|
||||
mux.Handle("POST", pattern_ProvinceAreaCity_City_0, func(w http.ResponseWriter, req *http.Request, pathParams map[string]string) {
|
||||
ctx, cancel := context.WithCancel(req.Context())
|
||||
defer cancel()
|
||||
inboundMarshaler, outboundMarshaler := runtime.MarshalerForRequest(mux, req)
|
||||
rctx, err := runtime.AnnotateContext(ctx, mux, req)
|
||||
if err != nil {
|
||||
runtime.HTTPError(ctx, mux, outboundMarshaler, w, req, err)
|
||||
return
|
||||
}
|
||||
resp, md, err := request_ProvinceAreaCity_City_0(rctx, inboundMarshaler, client, req, pathParams)
|
||||
ctx = runtime.NewServerMetadataContext(ctx, md)
|
||||
if err != nil {
|
||||
runtime.HTTPError(ctx, mux, outboundMarshaler, w, req, err)
|
||||
return
|
||||
}
|
||||
|
||||
forward_ProvinceAreaCity_City_0(ctx, mux, outboundMarshaler, w, req, resp, mux.GetForwardResponseOptions()...)
|
||||
|
||||
})
|
||||
|
||||
return nil
|
||||
}
|
||||
|
||||
var (
|
||||
pattern_ProvinceAreaCity_Province_0 = runtime.MustPattern(runtime.NewPattern(1, []int{2, 0, 2, 1, 2, 2}, []string{"v1", "province", "namecode"}, "", runtime.AssumeColonVerbOpt(true)))
|
||||
|
||||
pattern_ProvinceAreaCity_Area_0 = runtime.MustPattern(runtime.NewPattern(1, []int{2, 0, 2, 1, 2, 2}, []string{"v1", "area", "namecode"}, "", runtime.AssumeColonVerbOpt(true)))
|
||||
|
||||
pattern_ProvinceAreaCity_City_0 = runtime.MustPattern(runtime.NewPattern(1, []int{2, 0, 2, 1, 2, 2}, []string{"v1", "city", "namecode"}, "", runtime.AssumeColonVerbOpt(true)))
|
||||
)
|
||||
|
||||
var (
|
||||
forward_ProvinceAreaCity_Province_0 = runtime.ForwardResponseMessage
|
||||
|
||||
forward_ProvinceAreaCity_Area_0 = runtime.ForwardResponseMessage
|
||||
|
||||
forward_ProvinceAreaCity_City_0 = runtime.ForwardResponseMessage
|
||||
)
|
140
province_test.go
Normal file
140
province_test.go
Normal file
|
@ -0,0 +1,140 @@
|
|||
package main
|
||||
|
||||
import (
|
||||
"log"
|
||||
"strings"
|
||||
"testing"
|
||||
|
||||
"github.com/474420502/hunter"
|
||||
)
|
||||
|
||||
type AreaCode struct {
|
||||
hunter.PreCurlUrl
|
||||
}
|
||||
|
||||
func (acode *AreaCode) Execute(cxt *hunter.TaskContext) {
|
||||
content, err := cxt.Hunt()
|
||||
if err != nil {
|
||||
panic(err)
|
||||
}
|
||||
|
||||
extractor := hunter.NewExtractor(content.Content())
|
||||
xp, err := extractor.XPath("//div[@class='ip']")
|
||||
if err != nil {
|
||||
panic(err)
|
||||
}
|
||||
|
||||
texts, errlist := xp.ForEachText("./h4")
|
||||
if len(errlist) != 0 {
|
||||
panic(err)
|
||||
}
|
||||
|
||||
var provinces []*NameCode
|
||||
provincesdict := make(map[string]*NameCode)
|
||||
provincemap := make(map[string]string)
|
||||
for _, t := range texts {
|
||||
pcode := strings.Split(t, " ")
|
||||
provincemap[pcode[1]] = pcode[0]
|
||||
|
||||
nc := &NameCode{Name: pcode[0], Code: pcode[1]}
|
||||
provincesdict[pcode[1]] = nc
|
||||
provinces = append(provinces, nc)
|
||||
}
|
||||
// log.Println(texts)
|
||||
|
||||
nxp, errlist := xp.ForEach("./ul//li")
|
||||
if len(errlist) != 0 {
|
||||
panic(err)
|
||||
}
|
||||
texts, errlist = nxp.ForEachText("./h5")
|
||||
if len(errlist) != 0 {
|
||||
panic(err)
|
||||
}
|
||||
|
||||
var temp []string
|
||||
// var areas []*NameCode
|
||||
areasdict := make(map[string]*NameCode)
|
||||
for _, t := range texts {
|
||||
pcode := strings.Split(t, " ")
|
||||
var name, code string
|
||||
var nval string
|
||||
switch pcode[0] {
|
||||
case "市辖区":
|
||||
name = provincemap[pcode[1][0:2]] + pcode[0]
|
||||
code = pcode[1]
|
||||
case "县":
|
||||
name = provincemap[pcode[1][0:2]] + pcode[0] + "区"
|
||||
code = pcode[1]
|
||||
case "省直辖县级行政区划":
|
||||
name = provincemap[pcode[1][0:2]] + pcode[0]
|
||||
code = pcode[1]
|
||||
default:
|
||||
name = pcode[0]
|
||||
code = pcode[1]
|
||||
}
|
||||
|
||||
nval = name + " " + code
|
||||
temp = append(temp, nval)
|
||||
|
||||
nc := &NameCode{Name: name, Code: code}
|
||||
areasdict[code] = nc
|
||||
pnc := provincesdict[code[0:2]]
|
||||
pnc.Child = append(pnc.Child, nc)
|
||||
|
||||
// areas = append(areas, nc)
|
||||
}
|
||||
|
||||
log.Println(temp)
|
||||
|
||||
texts, errlist = nxp.ForEachText("./ul//li")
|
||||
if len(errlist) != 0 {
|
||||
panic(err)
|
||||
}
|
||||
log.Println(texts)
|
||||
|
||||
for _, t := range texts {
|
||||
pcode := strings.Split(t, " ")
|
||||
|
||||
var name, code string
|
||||
switch pcode[0] {
|
||||
case "市辖区":
|
||||
name = areasdict[pcode[1][0:4]].Name + pcode[0]
|
||||
code = pcode[1]
|
||||
default:
|
||||
name = pcode[0]
|
||||
code = pcode[1]
|
||||
}
|
||||
|
||||
nc := &NameCode{Name: name, Code: code}
|
||||
|
||||
anc := areasdict[nc.Code[0:4]]
|
||||
anc.Child = append(anc.Child, nc)
|
||||
}
|
||||
|
||||
kl := &KeyList{}
|
||||
for _, p := range provinces {
|
||||
kl.AppendKey(p)
|
||||
}
|
||||
SaveData("./data/province.gob", kl)
|
||||
}
|
||||
|
||||
func TestHunterCountry(t *testing.T) {
|
||||
|
||||
// gob.Register(&NameCode{})
|
||||
|
||||
defer db.Close()
|
||||
|
||||
curlBash := `curl 'http://www.ip33.com/area_code.html'`
|
||||
|
||||
ht := hunter.NewHunter() // first params PreCurlUrl
|
||||
curl := hunter.PreCurlUrl(curlBash)
|
||||
ht.AddTask(&AreaCode{PreCurlUrl: curl})
|
||||
|
||||
ht.Execute()
|
||||
}
|
||||
|
||||
func estLoadProvince(t *testing.T) {
|
||||
kl := &KeyList{}
|
||||
LoadGob("./data/province.gob", kl)
|
||||
t.Error(GetRandomKeyByList(kl.GetKeys()).(NameCode))
|
||||
}
|
Loading…
Reference in New Issue
Block a user