Skip to content

Commit

Permalink
format
Browse files Browse the repository at this point in the history
  • Loading branch information
Birjemin committed Aug 12, 2020
1 parent c82f7b9 commit c7e6420
Showing 1 changed file with 38 additions and 38 deletions.
76 changes: 38 additions & 38 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -46,49 +46,49 @@ go get github.com/birjemin/douyuapi
- 示例

```golang
httpClient := &utils.HTTPClient{
Client: &http.Client{
Timeout: 5 * time.Second,
},
}

token := &Token{
BaseClient: BaseClient{
Client: httpClient,
Secret: "test-secret",
AID: "test-aid",
},
}

timestamp := cast.ToString(utils.GetCurrTime())
if ret, err := token.Handle(timestamp); err != nil {
// handle err
} else {
if ret.Code != 0 {
// handle err
}
// get ret.Data.Token
}

live := &Live{
BaseClient: BaseClient{
Client: httpClient,
Secret: "test-secret",
AID: "test-aid",
},
Token: "test-token",
httpClient := &utils.HTTPClient{
Client: &http.Client{
Timeout: 5 * time.Second,
},
}

token := &Token{
BaseClient: BaseClient{
Client: httpClient,
Secret: "test-secret",
AID: "test-aid",
},
}

timestamp := cast.ToString(utils.GetCurrTime())
if ret, err := token.Handle(timestamp); err != nil {
// handle err
} else {
if ret.Code != 0 {
// handle err
}
// get ret.Data.Token
}

live := &Live{
BaseClient: BaseClient{
Client: httpClient,
Secret: "test-secret",
AID: "test-aid",
},
Token: "test-token",
}

msg := `{"cid_type":1,"cid":1,"limit":10,"offset":0}`
msg := `{"cid_type":1,"cid":1,"limit":10,"offset":0}`

if ret, err := live.Handle(msg, cast.ToString(timestamp)); err != nil {
if ret, err := live.Handle(msg, cast.ToString(timestamp)); err != nil {
// handle err
} else {
if ret.Code != 0 {
// handle err
} else {
if ret.Code != 0 {
// handle err
}
// handle
}
// handle
}
```

### 备注
Expand Down

0 comments on commit c7e6420

Please sign in to comment.