本文整理匯總了Golang中github.com/c-darwin/dcoin-go/packages/utils.ErrInfo函數的典型用法代碼示例。如果您正苦於以下問題:Golang ErrInfo函數的具體用法?Golang ErrInfo怎麽用?Golang ErrInfo使用的例子?那麽, 這裏精選的函數代碼示例或許可以為您提供幫助。
在下文中一共展示了ErrInfo函數的15個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Golang代碼示例。
示例1: Information
func (c *Controller) Information() (string, error) {
var err error
alertMessages_, err := c.GetAll(`SELECT * FROM alert_messages ORDER BY id DESC`, -1)
var alertMessages []map[string]string
for _, v := range alertMessages_ {
show := false
if v["currency_list"] != "ALL" {
// проверим, есть ли у нас обещнные суммы с такой валютой
amounts, err := c.Single("SELECT id FROM promised_amount WHERE currency_id IN (" + v["currency_list"] + ")").Int64()
if err != nil {
return "", utils.ErrInfo(err)
}
if amounts > 0 {
show = true
}
} else {
show = true
}
if show {
alertMessages = append(alertMessages, map[string]string{"id": v["id"], "message": v["message"]})
}
}
TemplateStr, err := makeTemplate("information", "information", &InformationPage{
Lang: c.Lang,
AlertMessages: alertMessages})
if err != nil {
return "", utils.ErrInfo(err)
}
return TemplateStr, nil
}
示例2: Upgrade5
func (c *Controller) Upgrade5() (string, error) {
log.Debug("Upgrade5")
geolocationLat := ""
geolocationLon := ""
geolocation, err := c.Single("SELECT geolocation FROM " + c.MyPrefix + "my_table").String()
if err != nil {
return "", utils.ErrInfo(err)
}
if len(geolocation) > 0 {
x := strings.Split(geolocation, ", ")
if len(x) == 2 {
geolocationLat = x[0]
geolocationLon = x[1]
}
}
saveAndGotoStep := strings.Replace(c.Lang["save_and_goto_step"], "[num]", "7", -1)
upgradeMenu := utils.MakeUpgradeMenu(5)
TemplateStr, err := makeTemplate("upgrade_5", "upgrade5", &upgrade5Page{
Alert: c.Alert,
Lang: c.Lang,
SaveAndGotoStep: saveAndGotoStep,
UpgradeMenu: upgradeMenu,
GeolocationLat: geolocationLat,
GeolocationLon: geolocationLon,
UserId: c.SessUserId,
Mobile: utils.Mobile()})
if err != nil {
return "", utils.ErrInfo(err)
}
return TemplateStr, nil
}
示例3: SaveNotifications
func (c *Controller) SaveNotifications() (string, error) {
if c.SessRestricted != 0 {
return "", utils.ErrInfo(errors.New("Permission denied"))
}
c.r.ParseForm()
var data []map[string]interface{}
err := json.Unmarshal([]byte(c.r.PostFormValue("data")), &data)
if err != nil {
return "", utils.ErrInfo(err)
}
log.Debug("data:", data)
for k, _ := range data {
err := c.ExecSql(`
UPDATE `+c.MyPrefix+`my_notifications
SET email = ?,
sms = ?,
mobile = ?
WHERE name = ?
`, data[k]["email"].(float64), data[k]["sms"].(float64), data[k]["mobile"].(float64), data[k]["name"].(string))
if err != nil {
return "", utils.ErrInfo(err)
}
}
return `{"error":0}`, nil
}
示例4: checkAvailableKey
func (a *AvailablekeyStruct) checkAvailableKey(key string) (int64, string, error) {
publicKeyAsn, err := utils.GetPublicFromPrivate(key)
if err != nil {
log.Debug("%v", err)
return 0, "", utils.ErrInfo(err)
}
log.Debug("publicKeyAsn: %s", publicKeyAsn)
userId, err := a.Single("SELECT user_id FROM users WHERE hex(public_key_0) = ?", publicKeyAsn).Int64()
if err != nil {
return 0, "", utils.ErrInfo(err)
}
log.Debug("userId: %s", userId)
if userId == 0 {
return 0, "", errors.New("null userId")
}
allTables, err := a.GetAllTables()
if err != nil {
return 0, "", utils.ErrInfo(err)
}
// может другой юзер уже начал смену ключа. актуально для пула
if utils.InSliceString(utils.Int64ToStr(userId)+"_my_table", allTables) {
return 0, "", errors.New("exists _my_table")
}
return userId, string(publicKeyAsn), nil
}
示例5: Signals
func Signals() {
SigChan = make(chan os.Signal, 1)
waitSig()
var Term os.Signal = syscall.SIGTERM
go func() {
signal.Notify(SigChan, os.Interrupt, os.Kill, Term)
<-SigChan
fmt.Println("KILL SIGNAL")
for _, ch := range utils.DaemonsChans {
fmt.Println("ch.ChBreaker<-true")
ch.ChBreaker <- true
}
for _, ch := range utils.DaemonsChans {
fmt.Println(<-ch.ChAnswer)
}
log.Debug("Daemons killed")
fmt.Println("Daemons killed")
if utils.DB != nil && utils.DB.DB != nil {
err := utils.DB.Close()
fmt.Println("DB Closed")
if err != nil {
log.Error("%v", utils.ErrInfo(err))
//panic(err)
}
}
err := os.Remove(*utils.Dir + "/dcoin.pid")
if err != nil {
log.Error("%v", utils.ErrInfo(err))
panic(err)
}
fmt.Println("removed " + *utils.Dir + "/dcoin.pid")
os.Exit(1)
}()
}
示例6: SaveUserCoords
func (c *Controller) SaveUserCoords() (string, error) {
if c.SessRestricted != 0 {
return "", utils.ErrInfo(errors.New("Permission denied"))
}
c.r.ParseForm()
coordsJson := c.r.FormValue("coords_json")
var coords [][2]int
err := json.Unmarshal([]byte(coordsJson), &coords)
if err != nil {
return "", err
}
coordsType := c.r.FormValue("type")
if coordsType != "face" && coordsType != "profile" {
return "", errors.New("Incorrect type")
}
coordsJson_, err := json.Marshal(coords)
if err != nil {
return "", err
}
err = c.ExecSql("UPDATE "+c.MyPrefix+"my_table SET "+coordsType+"_coords = ?", string(coordsJson_))
if err != nil {
return "", utils.ErrInfo(err)
}
return `{"success":"ok"}`, nil
}
示例7: SaveHost
func (c *Controller) SaveHost() (string, error) {
if c.SessRestricted != 0 {
return "", utils.ErrInfo(errors.New("Permission denied"))
}
c.r.ParseForm()
http_host := c.r.FormValue("http_host")
if len(http_host) > 0 && http_host[len(http_host)-1:] != "/" {
http_host += "/"
}
tcp_host := c.r.FormValue("tcp_host")
if !utils.CheckInputData(http_host, "http_host") {
return `{"error":"1"}`, nil
}
if !utils.CheckInputData(tcp_host, "tcp_host") {
return `{"error":"1"}`, nil
}
err := c.ExecSql("UPDATE "+c.MyPrefix+"my_table SET http_host = ?, tcp_host = ?", http_host, tcp_host)
if err != nil {
return "", utils.ErrInfo(err)
}
return `{"error":"0"}`, nil
}
示例8: EData
func (c *Controller) EData() (string, error) {
c.w.Header().Set("Access-Control-Allow-Origin", "*")
// сколько всего продается DC
eOrders, err := c.GetAll(`SELECT sell_currency_id, sum(amount) as amount FROM e_orders WHERE sell_currency_id < 1000 AND empty_time = 0 GROUP BY sell_currency_id`, 100)
if err != nil {
return "", utils.ErrInfo(err)
}
values := ""
for _, data := range eOrders {
values += utils.ClearNull(data["amount"], 0) + ` d` + c.CurrencyList[utils.StrToInt64(data["sell_currency_id"])] + `, `
}
if len(values) > 0 {
values = values[:len(values)-2]
}
ps, err := c.Single(`SELECT value FROM e_config WHERE name = 'ps'`).String()
if err != nil {
return "", utils.ErrInfo(err)
}
jsonData, err := json.Marshal(map[string]string{"values": values, "ps": ps})
if err != nil {
return "", utils.ErrInfo(err)
}
return string(jsonData), nil
}
示例9: CheckCfCurrency
func (c *Controller) CheckCfCurrency() (string, error) {
if c.SessRestricted != 0 {
return "", utils.ErrInfo(errors.New("Permission denied"))
}
c.r.ParseForm()
projectCurrencyName := c.r.FormValue("project_currency_name")
if !utils.CheckInputData(projectCurrencyName, "cf_currency_name") {
return "", errors.New("incorrect project_currency_name")
}
// проверим, не занято ли имя валюты
currency, err := c.Single("SELECT id FROM cf_projects WHERE project_currency_name = ? AND close_block_id = 0 AND del_block_id = 0", projectCurrencyName).Int64()
if err != nil {
return "", utils.ErrInfo(err)
}
if currency > 0 {
return `{"error":"` + c.Lang["currency_name_busy"] + `"}`, nil
}
// проверим, не занято ли имя валюты
currency, err = c.Single("SELECT id FROM cf_currency WHERE name = ?", projectCurrencyName).Int64()
if err != nil {
return "", utils.ErrInfo(err)
}
if currency > 0 {
return `{"error":"` + c.Lang["currency_name_busy"] + `"}`, nil
}
return `{"success":"` + c.Lang["name_is_not_occupied"] + `"}`, nil
}
示例10: NewPhoto
func (c *Controller) NewPhoto() (string, error) {
c.r.ParseForm()
userId := int64(utils.StrToFloat64(c.r.FormValue("user_id")))
data, err := c.OneRow("SELECT photo_block_id, photo_max_miner_id, miners_keepers FROM miners_data WHERE user_id = ?", userId).String()
if err != nil {
return "", utils.ErrInfo(err)
}
// получим ID майнеров, у которых лежат фото нужного нам юзера
minersIds := utils.GetMinersKeepers(data["photo_block_id"], data["photo_max_miner_id"], data["miners_keepers"], true)
// берем 1 случайный из 10-и ID майнеров
k := utils.RandInt(0, len(minersIds))
minerId := minersIds[k]
host, err := c.Single("SELECT http_host FROM miners_data WHERE miner_id = ?", minerId).String()
if err != nil {
return "", utils.ErrInfo(err)
}
result, err := json.Marshal(map[string]string{"face": host + "public/face_" + utils.Int64ToStr(userId) + ".jpg", "profile": host + "public/profile_" + utils.Int64ToStr(userId) + ".jpg"})
if err != nil {
return "", utils.ErrInfo(err)
}
return string(result), nil
}
示例11: MoneyBackRequest
func (c *Controller) MoneyBackRequest() (string, error) {
txType := "MoneyBackRequest"
txTypeId := utils.TypeInt(txType)
timeNow := utils.Time()
orderId := int64(utils.StrToFloat64(c.Parameters["order_id"]))
order, err := c.OneRow("SELECT * FROM orders WHERE id = ?", orderId).String()
if err != nil {
return "", utils.ErrInfo(err)
}
TemplateStr, err := makeTemplate("money_back_request", "moneyBackRequest", &moneyBackRequestPage{
Alert: c.Alert,
Lang: c.Lang,
ShowSignData: c.ShowSignData,
SignData: "",
UserId: c.SessUserId,
OrderId: orderId,
Order: order,
CountSignArr: c.CountSignArr,
TimeNow: timeNow,
TxType: txType,
TxTypeId: txTypeId})
if err != nil {
return "", utils.ErrInfo(err)
}
return TemplateStr, nil
}
示例12: Type7
func (t *TcpServer) Type7() {
/* Выдаем тело указанного блока
* запрос шлет демон blocksCollection и queue_parser_blocks через p.GetBlocks()
*/
buf := make([]byte, 4)
_, err := t.Conn.Read(buf)
if err != nil {
log.Error("%v", utils.ErrInfo(err))
return
}
blockId := utils.BinToDec(buf)
block, err := t.Single("SELECT data FROM block_chain WHERE id = ?", blockId).Bytes()
if err != nil {
log.Error("%v", utils.ErrInfo(err))
return
}
log.Debug("blockId %x", blockId)
log.Debug("block %x", block)
err = utils.WriteSizeAndData(block, t.Conn)
if err != nil {
log.Error("%v", utils.ErrInfo(err))
return
}
}
示例13: SaveEmailSms
func (c *Controller) SaveEmailSms() (string, error) {
if !c.NodeAdmin || c.SessRestricted != 0 {
return "", utils.ErrInfo(errors.New("Permission denied"))
}
c.r.ParseForm()
err := c.ExecSql(`
UPDATE `+c.MyPrefix+`my_table
SET email = ?,
smtp_server = ?,
use_smtp = ?,
smtp_port = ?,
smtp_ssl = ?,
smtp_auth = ?,
smtp_username = ?,
smtp_password = ?,
sms_http_get_request = ?
`, c.r.FormValue("email"), c.r.FormValue("smtp_server"), c.r.FormValue("use_smtp"), c.r.FormValue("smtp_port"), c.r.FormValue("smtp_ssl"), c.r.FormValue("smtp_auth"), c.r.FormValue("smtp_username"), c.r.FormValue("smtp_password"), c.r.FormValue("sms_http_get_request"))
if err != nil {
return "", utils.ErrInfo(err)
}
return "", nil
}
示例14: Chat
func (c *Controller) Chat() (string, error) {
myChatName := utils.Int64ToStr(c.SessUserId)
// возможно у отпарвителя есть ник
name, err := c.Single(`SELECT name FROM users WHERE user_id = ?`, c.SessUserId).String()
if err != nil {
return "", utils.ErrInfo(err)
}
if len(name) > 0 {
myChatName = name
}
TemplateStr, err := makeTemplate("chat", "chat", &chatPage{
Community: c.Community,
CountSignArr: c.CountSignArr,
CountSign: c.CountSign,
Lang: c.Lang,
ShowSignData: c.ShowSignData,
SignData: "",
MyChatName: myChatName,
UserId: c.SessUserId,
IOS: utils.IOS(),
Mobile: utils.Mobile()})
if err != nil {
return "", utils.ErrInfo(err)
}
return TemplateStr, nil
}
示例15: EPages
func (c *Controller) EPages() (string, error) {
var err error
var title, text string
if len(c.Parameters["page"]) > 0 {
if !utils.CheckInputData(c.Parameters["page"], "string") {
return "", utils.ErrInfo(err)
}
data, err := c.OneRow(`SELECT title, text from e_pages WHERE name = ? AND lang = ?`, c.Parameters["page"], c.LangInt).String()
if err != nil {
return "", utils.ErrInfo(err)
}
title = data["title"]
text = data["text"]
}
TemplateStr, err := makeTemplate("e_pages", "ePages", &ePages{
Lang: c.Lang,
Title: title,
Text: text})
if err != nil {
return "", utils.ErrInfo(err)
}
return TemplateStr, nil
}