// GetSingleUser - function fetches information about a single user
function fetches information about a single user
// GetSingleUser - function fetches information about a single user
func (s *server) GetSingleUser(ctx context.Context, request *proto.RequestUser) (*proto.ResponseUser, error) {
	var id []int
	response := &proto.ResponseUser{}
	if request.UserId == 0 {
		return &proto.ResponseUser{}, errors.New("INVALID USER ID")
	}
	id = append(id, int(request.UserId))
	userData, err := mockdata.GetData(id)
	if err != nil {
		return &proto.ResponseUser{}, err
	}
	for _, v := range userData {
		response.Id = int64(v.ID)
		response.City = v.City
		response.Fname = v.Fname
		response.Height = float32(v.Height)
		response.Married = v.Married
		response.Phone = v.Phone
	}
	return response, nil
}
func ( s * server ) GetSingleUser ( ctx context . Context , request * proto . RequestUser ) ( * proto . ResponseUser , error ) { var id [ ] int response := & proto . ResponseUser { } if request . UserId == 0 { return & proto . ResponseUser { } , errors . New ( " " ) } id = append ( id , int ( request . UserId ) ) userData , err := mockdata . GetData ( id ) if err != nil { return & proto . ResponseUser { } , err } for _ , v := range userData { response . Id = int64 ( v . ID ) response . City = v . City response . Fname = v . Fname response . Height = float32 ( v . Height ) response . Married = v . Married response . Phone = v . Phone } return response , nil }
function fetches information about a single user
function fetches information about a single user
// variable decalarations // invalid input check // id is appended // GetData function is called with id // proto is populated // data is returned in proto format