Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- package main
- import (
- "context"
- "database/sql"
- "log"
- "time"
- _ "github.com/jinzhu/gorm/dialects/sqlite"
- )
- func main() {
- db, err := sql.Open("sqlite3", "/tmp/gorm.db")
- if err != nil {
- log.Panic(err)
- }
- ctx := context.Background()
- ctx, cancel := context.WithTimeout(ctx, time.Microsecond*10)
- defer cancel()
- res := db.QueryRowContext(ctx, "select id from orders")
- id := -1
- if err := res.Scan(&id); err != nil {
- log.Panic(err)
- }
- log.Print(id)
- }
- 2018/06/18 19:19:03 interrupted
- panic: interrupted
- goroutine 1 [running]:
- log.Panic(0xc420053f48, 0x1, 0x1)
- /usr/local/Cellar/go/1.10.1/libexec/src/log/log.go:326 +0xc0
- main.main()
- /tmp/main.go:23 +0x226
- exit status 2
Add Comment
Please, Sign In to add comment