48 lines
1019 B
Go
48 lines
1019 B
Go
package main
|
|
|
|
import (
|
|
"context"
|
|
"log"
|
|
)
|
|
|
|
type LastName struct {
|
|
Name []byte
|
|
}
|
|
|
|
type FirstName struct {
|
|
Name []byte
|
|
}
|
|
|
|
var fnl *KeyList = &KeyList{}
|
|
var lnl *KeyList = &KeyList{}
|
|
|
|
type nameserver struct {
|
|
}
|
|
|
|
// FirstName first name 首名(姓)
|
|
func (s *nameserver) FirstName(cxt context.Context, request *Request) (*Reply, error) {
|
|
|
|
reply := &Reply{}
|
|
reply.Message = string(GetRandomKey(fnl).(FirstName).Name)
|
|
return reply, nil
|
|
|
|
}
|
|
|
|
// LastName last name 名字
|
|
func (s *nameserver) LastName(cxt context.Context, request *Request) (*Reply, error) {
|
|
reply := &Reply{}
|
|
log.Println(len(lnl.Keys))
|
|
reply.Message = string(GetRandomKey(lnl).(LastName).Name)
|
|
return reply, nil
|
|
}
|
|
|
|
// FullName 全名
|
|
func (s *nameserver) FullName(cxt context.Context, request *Request) (*Reply, error) {
|
|
reply := &Reply{}
|
|
var fullname []byte
|
|
fullname = append(fullname, GetRandomKey(fnl).(FirstName).Name...)
|
|
fullname = append(fullname, GetRandomKey(lnl).(LastName).Name...)
|
|
reply.Message = string(fullname)
|
|
return reply, nil
|
|
}
|