From 1a723d123afbc6a8755acd3cea73a55553f00bb7 Mon Sep 17 00:00:00 2001 From: Makarov Dreyar <80548743+SeRj-ThuramS@users.noreply.github.com> Date: Mon, 17 Jun 2024 10:18:17 +0300 Subject: [PATCH] Update dropdown.go to compile to lib.so Fixing a bug for compiling into a library 2024.06.17 10:13:00 go(build)(error): # /tmp/go-build4195759871/b113/librtl-tview.so panic: runtime error: invalid memory address or nil pointer dereference [signal SIGSEGV: segmentation violation code=0x1 addr=0x0 pc=0x51de66] goroutine 1 [running]: cmd/link/internal/loader.(*Loader).SymSize(0x1?, 0x0?) cmd/link/internal/loader/loader.go:815 +0x46 cmd/link/internal/ld.(*pclntab).generatePctab.func1(0x0) cmd/link/internal/ld/pcln.go:467 +0x56 cmd/link/internal/ld.(*pclntab).generatePctab(0xc000c46f40, 0xc000124200, {0xc001724000, 0x4f3, 0x1?}) cmd/link/internal/ld/pcln.go:490 +0x39f cmd/link/internal/ld.(*Link).pclntab(0xc000124200, {0xc001720000?, 0xc0000126e0?, 0xf?}) cmd/link/internal/ld/pcln.go:804 +0x1ad cmd/link/internal/ld.Main(_, {0x20, 0x20, 0x1, 0x7, 0x10, 0x0, {0xc000012549, 0x1, 0x1}, ...}) cmd/link/internal/ld/main.go:412 +0x175c main.main() cmd/link/main.go:72 +0xdfb --- dropdown.go | 6 ++---- 1 file changed, 2 insertions(+), 4 deletions(-) diff --git a/dropdown.go b/dropdown.go index 11400ed..22a6013 100644 --- a/dropdown.go +++ b/dropdown.go @@ -275,10 +275,8 @@ func (d *DropDown) AddOption(text string, selected func()) *DropDown { func (d *DropDown) SetOptions(texts []string, selected func(text string, index int)) *DropDown { d.list.Clear() d.options = nil - for index, text := range texts { - func(t string, i int) { - d.AddOption(text, nil) - }(text, index) + for _, text := range texts { + d.AddOption(text, nil) } d.selected = selected return d