naise_pos/main.go
2023-03-14 17:39:40 +07:00

35 lines
680 B
Go

package main
import (
"database/sql"
"log"
"git.nochill.in/nochill/naice_pos/api"
db "git.nochill.in/nochill/naice_pos/db/sqlc"
"git.nochill.in/nochill/naice_pos/util"
_ "github.com/lib/pq"
)
func main() {
config, err := util.LoadConfig(".")
if err != nil {
log.Fatal("cannot load config: ", err)
}
dbConn, err := sql.Open(config.DBDriver, config.DBSource)
if err != nil {
log.Fatal("cannot connect to db: ", err)
}
store := db.NewStore(dbConn)
server, err := api.NewServer(config, store)
if err != nil {
log.Fatal("cannot make server: ", err)
}
err = server.Start(config.ServerAddress)
if err != nil {
log.Fatal("cannot start server: ", err)
}
}