Skip to content

Commit f123788

Browse files
committed
fix: default timeout & duration type
1 parent e17d03f commit f123788

File tree

3 files changed

+6
-2
lines changed

3 files changed

+6
-2
lines changed

VERSION

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1 +1 @@
1-
v0.5.0
1+
v0.5.1

config.go

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -116,5 +116,9 @@ func loadConfig() (*Config, error) {
116116
config.RPS = 5
117117
}
118118

119+
if config.Timeout == 0 {
120+
config.Timeout = 10
121+
}
122+
119123
return &config, nil
120124
}

main.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -201,7 +201,7 @@ func testModels(channel Channel, wg *sync.WaitGroup, mu *sync.Mutex) {
201201
req.Header.Set("Content-Type", "application/json")
202202
req.Header.Set("Authorization", "Bearer "+channel.Key)
203203

204-
client := &http.Client{Timeout: config.Timeout * time.Second}
204+
client := &http.Client{Timeout: time.Duration(config.Timeout) * time.Second}
205205
resp, err := client.Do(req)
206206
if err != nil {
207207
log.Printf("\033[31m请求失败:%v\033[0m\n", err)

0 commit comments

Comments
 (0)