chore: use go fix to enhance codebase (#29)
This pull request modernizes the codebase by adopting Go 1.21+ features, including built-in functions like min and max, standard library iterators such as strings.SplitSeq and strings.FieldsSeq, utility functions like maps.Copy and slices.Contains, and string manipulation helpers like strings.Cut and strings.CutPrefix. Feedback is provided on a test file where the usage of strings.Builder can be further optimized to avoid unnecessary string allocations during concatenation. `go fix -diff ./...`
This commit is contained in:
@@ -7,9 +7,9 @@ import (
|
||||
"strings"
|
||||
"testing"
|
||||
|
||||
_ "github.com/versenilvis/iris/commands"
|
||||
"github.com/versenilvis/iris/commands/core"
|
||||
"github.com/versenilvis/iris/commands/js"
|
||||
_ "github.com/versenilvis/iris/commands"
|
||||
)
|
||||
|
||||
func TestNpmScriptGenerator(t *testing.T) {
|
||||
@@ -20,11 +20,11 @@ func TestNpmScriptGenerator(t *testing.T) {
|
||||
pkg := map[string]any{
|
||||
"name": "test-app",
|
||||
"scripts": map[string]string{
|
||||
"dev": "vite",
|
||||
"build": "vite build",
|
||||
"test": "vitest",
|
||||
"lint": "eslint .",
|
||||
"preview": "vite preview",
|
||||
"dev": "vite",
|
||||
"build": "vite build",
|
||||
"test": "vitest",
|
||||
"lint": "eslint .",
|
||||
"preview": "vite preview",
|
||||
"typecheck": "tsc --noEmit",
|
||||
},
|
||||
}
|
||||
@@ -173,7 +173,7 @@ func sshHostGeneratorFromPath(configPath string) []core.Suggestion {
|
||||
_ = scanner
|
||||
|
||||
data, _ := os.ReadFile(configPath)
|
||||
for _, line := range strings.Split(string(data), "\n") {
|
||||
for line := range strings.SplitSeq(string(data), "\n") {
|
||||
line = strings.TrimSpace(line)
|
||||
if !strings.HasPrefix(strings.ToLower(line), "host ") {
|
||||
continue
|
||||
|
||||
Reference in New Issue
Block a user