Golang database/sql.RawBytes type examples

package database/sql

RawBytes is a byte slice that holds a reference to memory owned by the database itself. After a Scan into a RawBytes, the slice is only valid until the next call to Next, Scan, or Close.

Golang database/sql.RawBytes type usage examples

Example 1:

 var result sql.RawBytes
 rows.Scan(&result)
 if expected != string(result) {
 dbt.Error("result did not match expected value")
 }

Example 2:

 rows := dbt.mustQuery("SHOW STATUS LIKE 'Ssl_cipher'")
 var variable, value *sql.RawBytes
 for rows.Next() {

 if err := rows.Scan(&variable, &value); err != nil {
 dbt.Fatal(err.Error())
 }

 if value == nil {
 dbt.Fatal("No Cipher")
 }
 }

Reference :

http://golang.org/pkg/database/sql/#RawBytes

Advertisement