feat: add initial implementation of Go utilities and CI workflows

This commit is contained in:
2025-06-18 16:46:01 -04:00
commit c588ade142
12 changed files with 475 additions and 0 deletions

11
Maps/maps.go Executable file
View File

@@ -0,0 +1,11 @@
package Maps
//goland:noinspection GoUnusedExportedFunction // library function
func IsElementExist(s []string, str string) bool {
for _, v := range s {
if v == str {
return true
}
}
return false
}

26
Maps/maps_test.go Normal file
View File

@@ -0,0 +1,26 @@
package Maps
import "testing"
func TestIsElementExist(t *testing.T) {
tests := []struct {
name string
s []string
str string
expected bool
}{
{"element exists", []string{"a", "b", "c"}, "b", true},
{"element does not exist", []string{"a", "b", "c"}, "d", false},
{"empty slice", []string{}, "a", false},
{"multiple same elements", []string{"a", "b", "a"}, "a", true},
}
for _, tt := range tests {
t.Run(tt.name, func(t *testing.T) {
result := IsElementExist(tt.s, tt.str)
if result != tt.expected {
t.Errorf("IsElementExist(%v, %q) = %v; want %v", tt.s, tt.str, result, tt.expected)
}
})
}
}