-
Notifications
You must be signed in to change notification settings - Fork 0
/
main.go
50 lines (44 loc) · 892 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
44
45
46
47
48
49
50
package main
import (
"context"
"fmt"
"os"
"path/filepath"
"example.com/login/login"
"github.com/google/uuid"
)
var (
sessionKey = os.Getenv("SESSION_KEY")
sessionPassword = os.Getenv("SESSION_PASSWORD")
)
func main() {
var f *os.File
var err error
files, err := filepath.Glob("*.json")
if err != nil {
panic(err)
}
for _, f := range files {
if err := os.Remove(f); err != nil {
panic(err)
}
}
f, err = os.OpenFile(fmt.Sprintf("%s.json", uuid.NewString()), os.O_APPEND|os.O_CREATE|os.O_RDWR, 0666)
if err != nil {
panic(err)
}
// don't forget to close it
defer f.Close()
ctx := context.Background()
login, err := login.New(ctx, f, sessionKey, sessionPassword)
if err != nil {
fmt.Println("login.New() Failed")
os.Exit(1)
}
err = login.Login()
if err != nil {
fmt.Println("Login Failed")
os.Exit(1)
}
fmt.Println("Login Successful")
}