package MyDataParser
import (
"encoding/json"
"io"
)
type Parser interface {
DecodeJSON(r io.Reader) error
}
func (p *MyStruct) DecodeJSON(r io.Reader) error {
return json.NewDecoder(r).Decode(&p)
}
type MyStruct struct {
Success int `json:"success"`
Return struct {
Funds struct {
Ltc int `json:"ltc"`
Nvc float64 `json:"nvc"`
Ppc int `json:"ppc"`
} `json:"funds"`
FundsInclOrders struct {
Ltc int `json:"ltc"`
Nvc float64 `json:"nvc"`
Ppc int `json:"ppc"`
} `json:"funds_incl_orders"`
Rights struct {
Info int `json:"info"`
Trade int `json:"trade"`
Withdraw int `json:"withdraw"`
} `json:"rights"`
TransactionCount int `json:"transaction_count"`
OpenOrders int `json:"open_orders"`
ServerTime int `json:"server_time"`
} `json:"return"`
}
Ну юзать как-то вот так.
var myData MyStruct
res, err := client.Get(uri)
err = posts.DecodeJSON(res.Body)
,,,
#include <iostream>
void dd();
int main(int argc, const char * argv[]) {
s:
if(rand() % 100 == 99){
goto e;
}
goto s;
e:
return 0;
}
int _main(int arg0, int arg1) {
do {
rax = rand();
temp_3 = rax % 0x64;
if (temp_3 == 0x63) {
break;
}
} while (true);
return 0x0;
}
_main:
push rbp
mov rbp, rsp
sub rsp, 0x10
mov dword [ss:rbp+var_4], 0x0
mov dword [ss:rbp+var_8], edi
mov qword [ss:rbp+var_10], rsi
_100000f66: call imp___stubs__rand
mov ecx, 0x64
cdq
idiv ecx
cmp edx, 0x63
jne _100000f81
jmp _100000f86
_100000f81: jmp _100000f66
_100000f86: xor eax, eax
add rsp, 0x10
pop rbp
ret
func InitDatabase(driver, dbPath string) error {
var db gorm.DB
var err error
switch driver {
case "sqlite3":
db, err = gorm.Open("sqlite3", dbPath)
if err != nil {
return err
}
break
case "mysql":
db, err = gorm.Open("mysql", dbPath)
if err != nil {
return err
}
break
case "postgres":
db, err = gorm.Open("postgres", dbPath)
if err != nil {
return err
}
break
default:
return fmt.Errorf("Unknown database driver of %v", driver)
}
type Config struct {
Database struct {
DatabaseName string `json:"database_name"`
DatabasePassword string `json:"database_password"`
DatabaseUser string `json:"database_user"`
DatabasePort int `json:"database_port"`
} `json:"database"`
Accounts struct {
AutoCreate bool `json:"auto_create"`
} `json:"accounts"`
Client struct {
BanTimeForBruteForcing int `json:"ban_time_for_brute_forcing"`
Host string `json:"host"`
LoginTryBeforeBan int `json:"login_try_before_ban"`
Port int `json:"port"`
} `json:"client"`
Server struct {
Pingpong bool `json:"pingpong"`
Host string `json:"host"`
PingpongDelay bool `json:"pingpong_delay"`
PingpongDelayTime int `json:"pingpong_delay_time"`
Port int `json:"port"`
} `json:"server"`
}