> > Thank you very much for the reply but my problem is that there are no > slice of time.Time. This is the main reason I chose to get the data this > way by creating a slice of struct. >
Can you tell me what is the best way to get this sort of data in a struct of 2 slices. my code is package main import ( "database/sql" _ "github.com/lib/pq" "log" "fmt" "time" _ "github.com/jmoiron/sqlx" "github.com/jinzhu/gorm" "github.com/jmoiron/sqlx" ) type State struct{ DLastmodified time.Time DState string } func main(){ db, err := sql.Open("postgres", "user=postgres password=Gurgaon@65 dbname=HRMS sslmode=disable") if err!=nil { panic(err) } defer db.Close() rows, err := db.Query("SELECT * FROM dropdown.states") if err!=nil { panic(err) } defer rows.Close() got :=[]State{} for rows.Next() { var r State err = rows.Scan(&r.DLastmodified,&r.DState) if err!=nil{ log.Fatal(err) } got= append(got,r) } fmt.Println(got[1:3].DState) fmt.Println(got[2:3]) fmt.Println(got[1].DState) fmt.Println(got[3:3]) } > is this how I should query it. Now I believe there is something wrong > with my approach towards this code. > -- You received this message because you are subscribed to the Google Groups "golang-nuts" group. To unsubscribe from this group and stop receiving emails from it, send an email to golang-nuts+unsubscr...@googlegroups.com. For more options, visit https://groups.google.com/d/optout.