migration: go 1.21

This commit is contained in:
Larvan2
2023-09-17 17:05:13 +08:00
parent 2d3b9364bf
commit 33d41338ef
11 changed files with 20 additions and 63 deletions

View File

@ -136,21 +136,21 @@ func (p *Proxy) ExtraDelayHistory() map[string][]C.DelayHistory {
// LastDelay return last history record. if proxy is not alive, return the max value of uint16.
// implements C.Proxy
func (p *Proxy) LastDelay() (delay uint16) {
var max uint16 = 0xffff
var maxDelay uint16 = 0xffff
if !p.alive.Load() {
return max
return maxDelay
}
history := p.history.Last()
if history.Delay == 0 {
return max
return maxDelay
}
return history.Delay
}
// LastDelayForTestUrl implements C.Proxy
func (p *Proxy) LastDelayForTestUrl(url string) (delay uint16) {
var max uint16 = 0xffff
var maxDelay uint16 = 0xffff
alive := p.alive.Load()
history := p.history.Last()
@ -161,11 +161,11 @@ func (p *Proxy) LastDelayForTestUrl(url string) (delay uint16) {
}
if !alive {
return max
return maxDelay
}
if history.Delay == 0 {
return max
return maxDelay
}
return history.Delay
}