data_workshop/country.go

31 lines
577 B
Go
Raw Permalink Normal View History

2020-05-19 10:12:18 +00:00
package main
import (
context "context"
)
// Country struct
type Country struct {
Pic []byte
Name []byte
}
var countrylist *KeyList = &KeyList{}
type countryserver struct {
}
func (s *countryserver) Name(cxt context.Context, request *Request) (*Reply, error) {
reply := &Reply{}
reply.Message = string(GetRandomKey(countrylist).(Country).Name)
return reply, nil
}
func (s *countryserver) Picture(cxt context.Context, request *Request) (*CountryReply, error) {
reply := &CountryReply{}
reply.Image = GetRandomKey(countrylist).(Country).Pic
return reply, nil
}