package main import ( "context" "encoding/gob" "log" ) type LastName struct { Name []byte } type FirstName struct { Name []byte } var fnl *KeyList = &KeyList{} var lnl *KeyList = &KeyList{} func init() { gob.Register(LastName{}) gob.Register(FirstName{}) LoadGob("./data/firstname.gob", fnl) LoadGob("./data/lastname.gob", lnl) } type nameserver struct { } func (s *nameserver) FirstName(cxt context.Context, request *Request) (*Reply, error) { reply := &Reply{} reply.Message = string(GetRandomKey(fnl).(FirstName).Name) return reply, nil } 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 } 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 }