Hello,

I am sorry I am not sure I understood what you wanted to achieve, however, 
if you need to extract a json object from your sql rows, here is some code 
that should do it:
https://play.golang.org/p/92oFkprZfs

HTH

Pierre

Le mercredi 9 novembre 2016 22:36:42 UTC+1, Sergio Hunter a écrit :
>
> Please tell me how to properly finish the JSON parser, so when the line 
> did not fall unzip the code? That is, when you compile the code meets the 
> text rather than the archive, immediately falls. It is necessary to write 
> to skip the line with the text. When I start the first line unpacks it, and 
> then when it sees the text drops, so it is necessary to write to pass and 
> go on to unpack the archive. Sorry for my English. I hope you are 
> understood me)
>
> package main   import ( "database/sql" "log" _"
> github.com/go-sql-driver/mysql" "compress/zlib" "bytes" "os" "fmt" 
> "encoding/json" )   func main() { db, err := sql.Open("mysql", 
> "name:password@tcp(127.0.0.1:port)/database") if err != nil { panic(err.
> Error()) } defer db.Close()   rows, err := db.Query(`SELECT data FROM 
> user_stats ORDER BY created_at LIMIT 10`) if err != nil { log.Fatal(err) } 
> defer rows.Close()   var data []byte   for rows.Next() { err := rows.Scan(
> &data) if err != nil { log.Fatal(err) }   r, err := zlib.NewReader(bytes.
> NewReader(data)) if err != nil { log.Panicf("Cannot read archive %v", err)
> ; } io.Copy(os.Stdout, r) r.Close() } }
>

-- 
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.

Reply via email to