Moved GetUserBy to lib package, reordered import statements

The GetUserBy function will be useful in other parts of the application
so it makes sense to have it in the general lib package.

The import statements are ordered:

builtin Go packages

third-party packages

first-party packages