-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathmain.go
41 lines (35 loc) · 1.18 KB
/
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
package main
import (
"TechnicalAssignment/cmd/db"
"TechnicalAssignment/cmd/server"
"TechnicalAssignment/pkg/constants"
"TechnicalAssignment/pkg/service"
"fmt"
)
func main() {
// Init Tables
db.GlobalUsernameTable = constants.UsernameFile
var initerr error
db.GlobalBalanceTable, db.GlobalPasswordTable, initerr = db.InitTables(constants.BalanceFile, constants.PasswordFile)
if initerr != nil {
panic("DB init error")
}
// Close DB
defer db.CloseDB(db.GlobalBalanceTable)
defer db.CloseDB(db.GlobalPasswordTable)
// Init Wallet
sessionUser := service.Wallet{}
// Register Admin
db.CreateUser("admin", "password123")
fmt.Println(
"Please Enter a command: " +
"\n 1) register <username> <password> - adds an account with username and password" +
"\n 2) login <username> <password>- login with username and password" +
"\n 3) deposit <x> - deposit $x to your account" +
"\n 4) withdraw <x> - withdraw $x from your account" +
"\n 5) send <username> <x> - sends $x to <username>" +
"\n 6) balance - shows your acccount balance" +
"\n 7) logout - logout" +
"\n 8) accounts - view all account information (admin only)")
server.ListenAndServe(&sessionUser)
}