From 9e998f9a29bed4c4a7b88c629ad605606b01725a Mon Sep 17 00:00:00 2001 From: Carlosokumu Date: Tue, 3 Dec 2024 14:37:55 +0300 Subject: [PATCH] add a zero pad value to unfilled profile item --- models/profile.go | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/models/profile.go b/models/profile.go index bdc1f0d..d698318 100644 --- a/models/profile.go +++ b/models/profile.go @@ -9,6 +9,10 @@ func (p *Profile) InsertOrShift(index int, value string) { if index < len(p.ProfileItems) { p.ProfileItems = append(p.ProfileItems[:index], value) } else { - p.ProfileItems = append(p.ProfileItems, value) + for len(p.ProfileItems) < index { + p.ProfileItems = append(p.ProfileItems, "0") + } + p.ProfileItems = append(p.ProfileItems, "0") + p.ProfileItems[index] = value } }