33 lines
496 B
Go
33 lines
496 B
Go
|
package main
|
||
|
|
||
|
import (
|
||
|
"encoding/json"
|
||
|
"log"
|
||
|
"os"
|
||
|
|
||
|
"sevenkeys/database"
|
||
|
|
||
|
"github.com/go-sql-driver/mysql"
|
||
|
)
|
||
|
|
||
|
func readConfigFromFile(filename string) mysql.Config {
|
||
|
bytes, err := os.ReadFile(filename)
|
||
|
if err != nil {
|
||
|
log.Fatal(err)
|
||
|
}
|
||
|
|
||
|
var config mysql.Config
|
||
|
err = json.Unmarshal(bytes, &config)
|
||
|
if err != nil {
|
||
|
log.Fatal(err)
|
||
|
}
|
||
|
|
||
|
return config
|
||
|
}
|
||
|
|
||
|
func main() {
|
||
|
config := readConfigFromFile("config.json")
|
||
|
db := database.GetDatabase(config)
|
||
|
database.CreateDatabaseSchema(db)
|
||
|
}
|