Created
June 21, 2019 11:08
-
-
Save chris001177/8b446834fb853cbad979e3f6a19ba39d to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
package main | |
// Note how the main package is the only one importing | |
// packages other than the definition package. | |
import ( | |
"github.com/myproject/config" | |
"github.com/myproject/database" | |
"github.com/myproject/definition" | |
"github.com/myproject/handler" | |
"net/http" | |
) | |
func main() { | |
// This approach also uses singleton instances, and | |
// again it's the initiator's responsibility to make | |
// sure they're initialized. | |
definition.UserDBInstance = &database.SomeUserDB{} | |
definition.ConfigDBInstance = &database.SomeConfigDB{} | |
config.InitPermissions() | |
http.HandleFunc("/", handler.UserPermissionsByID) | |
http.ListenAndServe(":8080", nil) | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment