Golang中国

异常:

E:/Go/src/github.com/xjj/studygo/sqlite3use/sqlite3use.exe  [E:/Go/src/github.com/xjj/studygo/sqlite3use]
fatal error: unexpected signal during runtime execution
[signal 0xc0000005 code=0x1 addr=0x4b4c73 pc=0x4b4c80]

runtime stack:
invalid spdelta 0x4b4c64 0x4b4c80 0x49348 4867
runtime.gothrow(0x58bc28, 0x2a)
    c:/go/src/runtime/panic.go:503 +0x67
runtime.sigpanic()
    c:/go/src/runtime/os_windows.go:36 +0x53
invalid spdelta 0x4b4c64 0x4b4c80 0x49348 4867
_cgo_497c08e8c976_Cfunc_sqlite3_threadsafe()
    ?:0 +0x1c

goroutine 1 [syscall, locked to thread]:
runtime.cgocall_errno(0x4b4c64, 0x10d8dc70, 0x0)
    c:/go/src/runtime/cgocall.go:130 +0xbc fp=0x10d8dc60 sp=0x10d8dc48
github.com/mattn/go-sqlite3._Cfunc_sqlite3_threadsafe(0x4b4c64)
    github.com/mattn/go-sqlite3/_obj/_cgo_gotypes.go:339 +0x47 fp=0x10d8dc70 sp=0x10d8dc60
github.com/mattn/go-sqlite3.(*SQLiteDriver).Open(0x10d7a1c0, 0x572bd8, 0xd, 0x0, 0x0, 0x0, 0x0)
    E:/Go/src/github.com/mattn/go-sqlite3/sqlite3.go:281 +0x57 fp=0x10d8de20 sp=0x10d8dc70
database/sql.(*DB).conn(0x10d7c230, 0x428cd7, 0x0, 0x0)
    c:/go/src/database/sql/sql.go:664 +0x414 fp=0x10d8ded0 sp=0x10d8de20
database/sql.(*DB).prepare(0x10d7c230, 0x589f28, 0x2b, 0x40e3d4, 0x0, 0x0)
    c:/go/src/database/sql/sql.go:848 +0x38 fp=0x10d8df2c sp=0x10d8ded0
database/sql.(*DB).Prepare(0x10d7c230, 0x589f28, 0x2b, 0xd, 0x0, 0x0)
    c:/go/src/database/sql/sql.go:833 +0x67 fp=0x10d8df58 sp=0x10d8df2c
main.main()
    E:/Go/src/github.com/xjj/studygo/sqlite3use/sqlite3use.go:19 +0x1e9 fp=0x10d8dfcc sp=0x10d8df58
runtime.main()
    c:/go/src/runtime/proc.go:63 +0xcc fp=0x10d8dff0 sp=0x10d8dfcc
runtime.goexit()
    c:/go/src/runtime/asm_386.s:2287 +0x1 fp=0x10d8dff4 sp=0x10d8dff0

goroutine 17 [syscall, locked to thread]:
runtime.goexit()
    c:/go/src/runtime/asm_386.s:2287 +0x1

goroutine 5 [chan receive]:
database/sql.(*DB).connectionOpener(0x10d7c230)
    c:/go/src/database/sql/sql.go:589 +0x43
created by database/sql.Open
    c:/go/src/database/sql/sql.go:452 +0x256
错误: 进程退出代码 2.

源码如下:

package main

import (
    "database/sql"
    "fmt"
    "log"

    _ "github.com/mattn/go-sqlite3"
)

func main() {
    db, err := sql.Open("sqlite3", "./sqlite_test")
    if err != nil {
        fmt.Println("non foo.db", err)
        log.Fatal(err)
    }
    defer db.Close() 

    stmt, err := db.Prepare("INSERT INTO test2 (username,age)values(?,?)")
    if err != nil {
        fmt.Println(err)
    }

    _, err = stmt.Exec("e", 11)
    _, err = stmt.Exec("f", 12)
    if err != nil {
        fmt.Println(err)
    }

    rows, err := db.Query("SELECT * FROM test2")
    if err != nil {
        fmt.Println(err)
    }
    fmt.Println(rows)

}

jimmykuu 于 2016-02-21 22:52 修改
2 回复
xjiaj8
#1 xjiaj8 • 2015-05-19 23:23

已经自行解决!
用4.9版本的CGO解决问题!
beego 和go-sqlite 的example都可以正常运行,就是编译非常慢。

qingo
#2 qingo • 2016-02-21 12:43

我升级go和beego到1.6后,请问2个问题:
1、为何升级前不提示需要cgo,升级后sqlite就提示需要?
2、beego热编译很慢,为何升级前热编译很快?
到底有啥玄机啊?

需要 登录 后方可回复, 如果你还没有账号你可以 注册 一个帐号。