commit 90a311b094a2e9f33280f8e48f2ee2d28a24c2cd Author: Braden Jageman Date: Mon Jul 8 14:05:01 2024 -0400 first commit diff --git a/.gitignore b/.gitignore new file mode 100644 index 0000000..64ae7f3 --- /dev/null +++ b/.gitignore @@ -0,0 +1,25 @@ +# If you prefer the allow list template instead of the deny list, see community template: +# https://github.com/github/gitignore/blob/main/community/Golang/Go.AllowList.gitignore +# +# Binaries for programs and plugins +*.exe +*.exe~ +*.dll +*.so +*.dylib + +# Test binary, built with `go test -c` +*.test + +# Output of the go coverage tool, specifically when used with LiteIDE +*.out + +# Dependency directories (remove the comment below to include it) +# vendor/ + +# Go workspace file +go.work +go.work.sum + +# env file +.env \ No newline at end of file diff --git a/go.mod b/go.mod new file mode 100644 index 0000000..9a5d3b9 --- /dev/null +++ b/go.mod @@ -0,0 +1,7 @@ +module codepractice + +go 1.22.5 + +require internal/itertools v0.0.0-00010101000000-000000000000 +replace internal/itertools => ./internal/itertools + diff --git a/internal/itertools/go.mod b/internal/itertools/go.mod new file mode 100644 index 0000000..17462a3 --- /dev/null +++ b/internal/itertools/go.mod @@ -0,0 +1,3 @@ +module itertools + +go 1.22.5 diff --git a/internal/itertools/itertools.go b/internal/itertools/itertools.go new file mode 100644 index 0000000..2fa03e2 --- /dev/null +++ b/internal/itertools/itertools.go @@ -0,0 +1,13 @@ +package itertools + +type Iterator struct { + dict map[string]int +} + +func (iterator Iterator) GetCount(items []string) map[string]int { + iterator.dict = make(map[string]int) + for _, item := range items { + iterator.dict[item]++ + } + return iterator.dict +} diff --git a/main.go b/main.go new file mode 100644 index 0000000..c7effa7 --- /dev/null +++ b/main.go @@ -0,0 +1,12 @@ +package main + +import ( + "fmt" + "internal/itertools" +) + +func main() { + iterator := itertools.Iterator{} + items := []string{"one", "two", "three", "one", "one"} + fmt.Println(iterator.GetCount(items)) +}