package models import ( "crypto/sha256" "encoding/json" "fmt" ) type Response struct { Meta QuestionID string AnswerID string } func (r *Response) String() string { return fmt.Sprintf("QID: %v, AID:%v", r.QuestionID, r.AnswerID) } func (r *Response) GetHash() string { return fmt.Sprintf("%x", sha256.Sum256([]byte(r.QuestionID+r.AnswerID))) } func (r *Response) Marshal() ([]byte, error) { return json.Marshal(r) } func (r *Response) Unmarshal(data []byte) error { return json.Unmarshal(data, r) }