Skip to content

Instantly share code, notes, and snippets.

@chris001177
Created June 21, 2019 11:09
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save chris001177/1fba963722485475dd4bf9b84ecf7c16 to your computer and use it in GitHub Desktop.
Save chris001177/1fba963722485475dd4bf9b84ecf7c16 to your computer and use it in GitHub Desktop.
package definition
// Note that in this approach both the singleton instance
// and its interface type are declared in the definition
// package. Make sure this package does not contain any
// logic, otherwise it might need to import other packages
// and its neutral nature is compromised.
var (
UserDBInstance UserDB
ConfigDBInstance ConfigDB
)
type UserDB interface {
UserRoleByID(id string) string
}
type ConfigDB interface {
AllPermissions() map[string][]string // maps from role to its permissions
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment