So i have this struct
type MessagesStored struct {
MessagetoStream string
StreamSub string
PubName string
CreatedAt time.Time
}
And i have a table in Postgres to match the struct
CREATE TABLE "StoredMessages"
(
"Message" character varying(200) COLLATE pg_catalog."default" NOT NULL,
"PubName" character varying(50) COLLATE pg_catalog."default" NOT NULL,
"Subject" character varying COLLATE pg_catalog."default" NOT NULL,
"CreatedAt" timestamp with time zone
)
So i am trying to select all the rows where a subject matches a string and store them in an array of the struct
var OldMessages []MessagesStored
db.Query("SELECT * FROM StoredMessages WHERE Subject = ", FilterSub)
for rows.Next() {
var oldmessages MessagesStored
errrws := rows.Scan(&oldmessages.MessagetoStream, oldmessages.StreamSub, &oldmessages.PubName, &oldmessages.CreatedAt)
CheckError(errrws)
OldMessages = append(OldMessages, oldmessages)
}
```