How to use global var across files in a package?
Edit: The problem is that you used Short variable declaration := and you just stored the created *DB value in a local variable and not in the global one. This line: db, err := NewDB(dbinfo) Creates 2 local variables: db and err, and this local db has nothing to do with your global db variable. … Read more