diff options
Diffstat (limited to 'gosrc/main.go')
-rw-r--r-- | gosrc/main.go | 39 |
1 files changed, 33 insertions, 6 deletions
diff --git a/gosrc/main.go b/gosrc/main.go index 9923d09..435dac1 100644 --- a/gosrc/main.go +++ b/gosrc/main.go @@ -8,10 +8,13 @@ package main import ( "encoding/json" - "fmt" "io/ioutil" + "fmt" "log" "os" + + ui "github.com/gizak/termui/v3" + "github.com/gizak/termui/v3/widgets" ) // #include "../csrc/smith.h" @@ -28,28 +31,52 @@ func main() { fmt.Println("Welcome, traveller, my name is " + Styles.colorGreen + C.GoString(C.mr_smith()) + Styles.colorReset + "\nI will try to help you get the bag...") + // get user config from json file config_path := "./config.json" for i, a := range os.Args[1:] { if a == "-c" || a == "--config" { config_path = os.Args[i + 2] } } - config_content, err := ioutil.ReadFile(config_path) if err != nil { - log.Fatal("config file not found") + log.Fatal("error: config file not found", err) } - var config Config err = json.Unmarshal(config_content, &config) if err != nil { - log.Fatal("error during marshall() ", err) + log.Fatal("error: marshall() ", err) } + make_ui() + fmt.Println("\n" + Styles.colorBlue + "public_key: " + Styles.colorReset + config.Public_key + "\n" + Styles.colorBlue + "secret_key: " + Styles.colorReset + config.Secret_key + "\n" + Styles.colorBlue + "mirror: " + Styles.colorReset + config.Mirror) - make_body("qwe", "qwe", "qwe") + // make request body and sign it + body := make_body("qwe", "qwe", "qwe") + fmt.Println(body) + signature := sign_request(body, config.Secret_key) + fmt.Println("[" + signature + "]") +} + +func make_ui() error { + if err := ui.Init(); err != nil { + log.Fatal("error: failed to initialize termui", err) + } + + p:= widgets.NewParagraph() + p.Text = "hello" + p.SetRect(0, 0, 25, 5) + ui.Render(p) + + for e := range ui.PollEvents() { + if e.Type == ui.KeyboardEvent { + return nil + } + } + + return nil } |