This question already has an answer here:
So lets say i have the following package structure
----models
----------user
----------message
the models
package would have the file index.go
that looks something like this
package models
import "database/sql"
var DB *sql.DB
and user
package would have a file user.go that looks like this
package user
type User struct {
ID uint64
Username string
}
func One(username string) *User {
// get user from database and return
}
how do i access the DB
variable declared in index.go
from the user
package?
</div>