From 6bf037c5ec8ab6ace3ef687a144152146126ccca Mon Sep 17 00:00:00 2001 From: jiangyong27 Date: Sun, 9 Apr 2023 11:38:30 +0800 Subject: [PATCH] bidprice2 --- conf/dadi.json | 4 ++++ config/daid.go | 30 ++++++++++++++++++++++++++++++ 2 files changed, 34 insertions(+) create mode 100644 conf/dadi.json create mode 100644 config/daid.go diff --git a/conf/dadi.json b/conf/dadi.json new file mode 100644 index 0000000..ac2fa8d --- /dev/null +++ b/conf/dadi.json @@ -0,0 +1,4 @@ +{ + "bidProfit": 50, + "couponCost": 3000 +} \ No newline at end of file diff --git a/config/daid.go b/config/daid.go new file mode 100644 index 0000000..55685a2 --- /dev/null +++ b/config/daid.go @@ -0,0 +1,30 @@ +package config + +import ( + "encoding/json" + "io/ioutil" +) + +type Dadi struct { + BidProfit int64 `json:"bidProfit"` + CouponCost int64 `json:"couponCost"` +} + +var ( + dadiConfig *Dadi = nil +) + +func LoadDadiConfig() { + body, err := ioutil.ReadFile("conf/dadi.json") + if err != nil { + panic(err) + } + dadiConfig = new(Dadi) + if err := json.Unmarshal([]byte(body), dadiConfig); err != nil { + panic(err) + } +} + +func GetDadiConfig() *Dadi { + return dadiConfig +}