-
Notifications
You must be signed in to change notification settings - Fork 0
/
main.go
43 lines (31 loc) · 766 Bytes
/
main.go
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
package main
import (
"database/sql"
"fmt"
"math/rand"
"runtime"
"time"
utl "books-list/util"
_ "github.com/go-sql-driver/mysql" // let work sql
)
func init() {
rand.Seed(time.Now().UnixNano())
maxCPU := runtime.NumCPU()
utl.CPUUsed = 4 // use 4 CPU
runtime.GOMAXPROCS(utl.CPUUsed)
fmt.Printf("\n=========================================\n")
fmt.Printf("= Number of CPUs (Total=%d - Used=%d)", maxCPU, utl.CPUUsed)
fmt.Printf("\n=========================================\n\n")
}
func main() {
fmt.Printf("Opening the %s ...\n\n", utl.DbName)
var err error
utl.DB, err = sql.Open(utl.DbDriver, utl.DataSourceName)
defer utl.DB.Close()
if err != nil {
panic(err.Error())
} else {
fmt.Println("Success !!\n")
}
utl.BookService()
}