From 34bc7ddbdc26673ce5c6d5e5e182638daafe3df5 Mon Sep 17 00:00:00 2001 From: Corbin Lazarone Date: Tue, 17 Mar 2026 19:40:41 -0500 Subject: [PATCH] fix: removed string concat in a loop is inefficient warning --- tutorials/basics/main.go | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/tutorials/basics/main.go b/tutorials/basics/main.go index cf2cff9e3d..5d8dc090b2 100644 --- a/tutorials/basics/main.go +++ b/tutorials/basics/main.go @@ -3,6 +3,7 @@ package main import ( "fmt" "os" + "strings" tea "charm.land/bubbletea/v2" ) @@ -57,6 +58,7 @@ func (m model) Update(msg tea.Msg) (tea.Model, tea.Cmd) { } func (m model) View() tea.View { + var sb strings.Builder s := "What should we buy at the market?\n\n" for i, choice := range m.choices { @@ -70,9 +72,10 @@ func (m model) View() tea.View { checked = "x" } - s += fmt.Sprintf("%s [%s] %s\n", cursor, checked, choice) + fmt.Fprintf(&sb, "%s [%s] %s\n", cursor, checked, choice) } + s += sb.String() s += "\nPress q to quit.\n" v := tea.NewView(s)