Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

TEXT type read in as []byte #606

Open
srahul123 opened this issue Jul 11, 2018 · 1 comment
Open

TEXT type read in as []byte #606

srahul123 opened this issue Jul 11, 2018 · 1 comment

Comments

@srahul123
Copy link

srahul123 commented Jul 11, 2018

Following is my golang code:

package main

import "fmt"
import "database/sql"
import _ "github.com/mattn/go-sqlite3"

func main() {
        db, _ := sql.Open("sqlite3", "temp.db")

        db.Exec("CREATE TABLE X (col TEXT)")

        db.Exec("INSERT INTO X (col) VALUES ('abc')")

        rows, _ := db.Query("SELECT col FROM X")
        rows.Next()
        var col interface{}
        rows.Scan(&col)
        rows.Close()
        fmt.Printf("%T\n", col)
}

It prints []uint8. Shouldn't it print string ?

@rittneje
Copy link
Collaborator

rittneje commented Jan 6, 2019

dest[i] = []byte(s)

For some reason it casts the string into a byte slice before returning it. @mattn Any idea why it does this?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants