Skip to content

Commit

Permalink
fix: slice bounds out of range error
Browse files Browse the repository at this point in the history
  • Loading branch information
eljamo committed Dec 7, 2023
1 parent b43ae90 commit c6e48ca
Showing 1 changed file with 3 additions and 3 deletions.
6 changes: 3 additions & 3 deletions service/transformer.go
Original file line number Diff line number Diff line change
Expand Up @@ -11,16 +11,14 @@ import (
"golang.org/x/text/language"
)

var caser = cases.Title(language.English)

// Defines an interface for transforming a slice of strings
type TransformerService interface {
// Transform takes a slice of strings and transforms each element or returns
// an error if the transformation fails.
Transform(slice []string) ([]string, error)
}

// Implementats the TransformerService, providing functionality to transform
// Implements the TransformerService, providing functionality to transform
// string slices based on a predefined configuration.
type DefaultTransformerService struct {
cfg *config.Config
Expand Down Expand Up @@ -136,6 +134,7 @@ func alternateLettercase(slice []string) ([]string, error) {
//
// Example Output: string[]{"Hello", "World"}
func (s *DefaultTransformerService) capitalise(slice []string) []string {
caser := cases.Title(language.English)
for i, w := range slice {
slice[i] = caser.String(w)
}
Expand Down Expand Up @@ -230,6 +229,7 @@ func (s *DefaultTransformerService) random(slice []string) ([]string, error) {
//
// Example Output: string[]{"Hello", "world"}
func (s *DefaultTransformerService) sentence(slice []string) []string {
caser := cases.Title(language.English)
for i, w := range slice {
if i == 0 {
slice[i] = caser.String(w)
Expand Down

0 comments on commit c6e48ca

Please sign in to comment.