From 93edde591b0017a9bf790c8238c05755412632c8 Mon Sep 17 00:00:00 2001 From: creamlike1024 Date: Wed, 29 Oct 2025 19:41:45 +0800 Subject: [PATCH] =?UTF-8?q?fix:=20=E5=BD=93totalWeight=E5=B0=8F=E4=BA=8E?= =?UTF-8?q?=E7=AD=89=E4=BA=8E0=E6=97=B6=E8=AE=BE=E7=BD=AE=E4=B8=BA1?= =?UTF-8?q?=E9=80=89=E6=8B=A9=E7=AC=AC=E4=B8=80=E4=B8=AA=E6=B8=A0=E9=81=93?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- model/channel_cache.go | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/model/channel_cache.go b/model/channel_cache.go index 0df14572..ddd1ddde 100644 --- a/model/channel_cache.go +++ b/model/channel_cache.go @@ -166,6 +166,11 @@ func GetRandomSatisfiedChannel(group string, model string, retry int) (*Channel, } // Calculate the total weight of all channels up to endIdx totalWeight := sumWeight * smoothingFactor + + // totalWeight 小于等于0时,设置为1,选择第一个渠道 + if totalWeight <= 0 { + totalWeight = 1 + } // Generate a random value in the range [0, totalWeight) randomWeight := rand.Intn(totalWeight)