Deferred log file close
Yes, on both counts (although putting it in the main package is not).

Typically I would return a logFile from createLogger (calling it newLogger is idiomatic), and defer closing the result.

If you're building a logger to work across your whole app, I'd look at how the standard library does it.

Essentially, create a new package my_app_logger with an initializer which sets up the logger. That way, every package that includes my_app_logger gets the same logger instance.