Skip to content

Instantly share code, notes, and snippets.

@manakuro
Created December 10, 2021 04:47
Show Gist options
  • Save manakuro/38c4477a8c3b06bd436bbb6ba58fb0e0 to your computer and use it in GitHub Desktop.
Save manakuro/38c4477a8c3b06bd436bbb6ba58fb0e0 to your computer and use it in GitHub Desktop.
package main
import (
"golang-clean-architecture-ent-gqlgen/config"
"golang-clean-architecture-ent-gqlgen/ent"
"golang-clean-architecture-ent-gqlgen/pkg/adapter/controller"
"golang-clean-architecture-ent-gqlgen/pkg/infrastructure/datastore"
"golang-clean-architecture-ent-gqlgen/pkg/infrastructure/graphql"
"golang-clean-architecture-ent-gqlgen/pkg/infrastructure/router"
"golang-clean-architecture-ent-gqlgen/pkg/registry"
"log"
)
func main() {
config.ReadConfig(config.ReadConfigOption{})
client := newDBClient()
ctrl := newController(client)
srv := graphql.NewServer(client, ctrl)
e := router.New(srv)
e.Logger.Fatal(e.Start(":" + config.C.Server.Address))
}
func newDBClient() *ent.Client {
client, err := datastore.NewClient()
if err != nil {
log.Fatalf("failed opening mysql client: %v", err)
}
return client
}
func newController(client *ent.Client) controller.Controller {
r := registry.New(client)
return r.NewController()
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment