Ibrahim Sharaf
Ibrahim Sharaf

Reputation: 127

go run/build hanging

I have this simple go file called main.go:

package main

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

func main() {
    db, err := sql.Open("sqlite3", "mydb.db")

    if err != nil {
        panic(err)
    }

    defer db.Close()

    fmt.Println("Opened Successfully")
}

I downloaded the required package but when I try to go run . or go build . I get nothing, the compiler just seems to be stuck in an infinite loop. If I remove the line _ "github.com/mattn/go-sqlite3" it works as expected with the error message panic: sql: unknown driver "sqlit3" (forgotten import?).

this happens many times with some imported packages.

this is my go.mod file:

module go-sqlite

go 1.18

require github.com/mattn/go-sqlite3 v1.14.15

go version: go version go1.18.1 linux/amd64

Upvotes: -1

Views: 1974

Answers (1)

user12420288
user12420288

Reputation:

If you use go with modules you could try to run go mod tidy

Upvotes: 0

Related Questions