diff --git a/pkg/gocui/view_test.go b/pkg/gocui/view_test.go index 294f02b32..2ee5eb4b8 100644 --- a/pkg/gocui/view_test.go +++ b/pkg/gocui/view_test.go @@ -11,6 +11,7 @@ import ( "github.com/gdamore/tcell/v3" "github.com/gdamore/tcell/v3/color" "github.com/rivo/uniseg" + "github.com/samber/lo" "github.com/stretchr/testify/assert" ) @@ -106,10 +107,8 @@ func TestWriteString(t *testing.T) { for _, s := range test.stringsToWrite { v.writeString(s) } - var resultingLines [][]string - for _, l := range v.buf.lines { - resultingLines = append(resultingLines, cellsToStrings(l.cells)) - } + resultingLines := lo.Map(v.buf.lines, + func(l lineType, _ int) []string { return cellsToStrings(l.cells) }) assert.Equal(t, test.expectedLines, resultingLines) } } @@ -465,11 +464,7 @@ func cellsToString(cells []cell) string { } func cellsToStrings(cells []cell) []string { - s := []string{} - for _, c := range cells { - s = append(s, c.chr) - } - return s + return lo.Map(cells, func(c cell, _ int) string { return c.chr }) } func TestLineWrap(t *testing.T) { diff --git a/pkg/integration/components/env.go b/pkg/integration/components/env.go index 6306a88ba..39152092e 100644 --- a/pkg/integration/components/env.go +++ b/pkg/integration/components/env.go @@ -3,6 +3,8 @@ package components import ( "fmt" "os" + + "github.com/samber/lo" ) const ( @@ -43,11 +45,9 @@ var hostEnvironmentAllowlist = [...]string{ // Returns a copy of the environment filtered by // hostEnvironmentAllowlist func allowedHostEnvironment() []string { - env := []string{} - for _, envVar := range hostEnvironmentAllowlist { - env = append(env, fmt.Sprintf("%s=%s", envVar, os.Getenv(envVar))) - } - return env + return lo.Map(hostEnvironmentAllowlist[:], func(envVar string, _ int) string { + return fmt.Sprintf("%s=%s", envVar, os.Getenv(envVar)) + }) } func NewTestEnvironment(rootDir string) []string {