how do I use my import package's struct as a type in go -
i'm working in project , using "database/sql" package in go. , want use struct "db" declare in package "database/sql" argument func, can use return value sql.open() , func's argument. possible? codes below:
package main import ( "database/sql" "fmt" _ "github.com/go-sql-driver/mysql" ) func main() { var table string = "tablename" db, err := sql.open("mysql", "user:password@/dbname") // read data database read(db, table) } func read(db *db, table string) { // read }
this code throws "undefined: db" error.
you must use qualifier imported entities - package name 'name' comes from:
func read(db *sql.db, table string)
Comments
Post a Comment