package dbstore import ( db_sql "database/sql" "encoding/json" "github.com/pablotron/cvez/cpedict" ) // title search result type CpeSearchRow struct { // Database CPE ID CpeId int64 `json:"cpe_id"` // v2.3 formatting string Cpe23 string `json:"cpe23"` // titles Titles []cpedict.Title `json:"titles"` // references Refs []cpedict.Reference `json:"refs"` // search result rank Rank float32 `json:"rank"` } // Unmarshal CPE search row from row set. func unmarshalCpeSearchRow(rows *db_sql.Rows) (CpeSearchRow, error) { var r CpeSearchRow var titles string var refs string // get row values if err := rows.Scan(&r.CpeId, &r.Cpe23, &titles, &refs, &r.Rank); err != nil { return r, err } // unmarshal titles if err := json.Unmarshal([]byte(titles), &r.Titles); err != nil { return r, err } // unmarshal refs if err := json.Unmarshal([]byte(refs), &r.Refs); err != nil { return r, err } // return sccess return r, nil }