Skip to content

Commit

Permalink
Return slice instead of pointer to slice
Browse files Browse the repository at this point in the history
  • Loading branch information
aQaTL committed May 18, 2018
1 parent 5859830 commit 2a576ec
Show file tree
Hide file tree
Showing 2 changed files with 24 additions and 24 deletions.
32 changes: 16 additions & 16 deletions mal/animeparser.go
Original file line number Diff line number Diff line change
Expand Up @@ -23,14 +23,14 @@ func parseDuration(spanDarkText *goquery.Selection) string {
Data)
}

func parseGenres(spanDarkText *goquery.Selection) *[]string {
func parseGenres(spanDarkText *goquery.Selection) []string {
genres := make([]string, 0)
spanDarkText.FilterFunction(isTextEqualFilterFunc("Genres:")).
Siblings().
Each(func(i int, s *goquery.Selection) {
genres = append(genres, s.Text())
})
return &genres
return genres
}

func parseSource(spanDarkText *goquery.Selection) string {
Expand All @@ -41,7 +41,7 @@ func parseSource(spanDarkText *goquery.Selection) string {
Data)
}

func parseStudios(spanDarkText *goquery.Selection) *[]string {
func parseStudios(spanDarkText *goquery.Selection) []string {
studios := make([]string, 0)

spanDarkText.FilterFunction(isTextEqualFilterFunc("Studios:")).
Expand All @@ -50,10 +50,10 @@ func parseStudios(spanDarkText *goquery.Selection) *[]string {
studios = append(studios, s.Text())
})

return &studios
return studios
}

func parseLicensors(spanDarkText *goquery.Selection) *[]string {
func parseLicensors(spanDarkText *goquery.Selection) []string {
licensors := make([]string, 0)

spanDarkText.FilterFunction(isTextEqualFilterFunc("Licensors:")).
Expand All @@ -62,10 +62,10 @@ func parseLicensors(spanDarkText *goquery.Selection) *[]string {
licensors = append(licensors, s.Text())
})

return &licensors
return licensors
}

func parseProducers(spanDarkText *goquery.Selection) *[]string {
func parseProducers(spanDarkText *goquery.Selection) []string {
producers := make([]string, 0)

spanDarkText.FilterFunction(isTextEqualFilterFunc("Producers:")).
Expand All @@ -74,7 +74,7 @@ func parseProducers(spanDarkText *goquery.Selection) *[]string {
producers = append(producers, s.Text())
})

return &producers
return producers
}

func parseBroadcast(spanDarkText *goquery.Selection) string {
Expand Down Expand Up @@ -130,7 +130,7 @@ func parseRelated(reader *goquery.Document) []Related {
return relateds
}

func parseCharacters(reader *goquery.Document) *[]Character {
func parseCharacters(reader *goquery.Document) []Character {
characters := make([]Character, 0)

reader.Selection.
Expand Down Expand Up @@ -165,7 +165,7 @@ func parseCharacters(reader *goquery.Document) *[]Character {
characters = append(characters, c)
})

return &characters
return characters
}

func parseScore(spanDarkText *goquery.Selection) float64 {
Expand Down Expand Up @@ -263,7 +263,7 @@ func parseFavorites(spanDarkText *goquery.Selection) int {
return favorites
}

func parseStaff(reader *goquery.Document) *[]Staff {
func parseStaff(reader *goquery.Document) []Staff {
staff := make([]Staff, 0)

reader.Selection.
Expand All @@ -276,10 +276,10 @@ func parseStaff(reader *goquery.Document) *[]Staff {
staff = append(staff, Staff{name, position})
})

return &staff
return staff
}

func parseOpeningThemes(reader *goquery.Document) *[]string {
func parseOpeningThemes(reader *goquery.Document) []string {
openingThemes := make([]string, 0)

reader.Selection.
Expand All @@ -289,10 +289,10 @@ func parseOpeningThemes(reader *goquery.Document) *[]string {
openingThemes = append(openingThemes, song)
})

return &openingThemes
return openingThemes
}

func parseEndingThemes(reader *goquery.Document) *[]string {
func parseEndingThemes(reader *goquery.Document) []string {
endingThemes := make([]string, 0)

reader.Selection.
Expand All @@ -302,5 +302,5 @@ func parseEndingThemes(reader *goquery.Document) *[]string {
endingThemes = append(endingThemes, song)
})

return &endingThemes
return endingThemes
}
16 changes: 8 additions & 8 deletions mal/mal.go
Original file line number Diff line number Diff line change
Expand Up @@ -225,10 +225,10 @@ func (c *Client) FetchDetails(entry *Anime) (*AnimeDetails, error) {
//All functions used below are in the animeparser.go file
details.JapaneseTitle = parseJapaneseTitle(reader)
details.Related = parseRelated(reader)
details.Characters = *parseCharacters(reader)
details.Staff = *parseStaff(reader)
details.OpeningThemes = *parseOpeningThemes(reader)
details.EndingThemes = *parseEndingThemes(reader)
details.Characters = parseCharacters(reader)
details.Staff = parseStaff(reader)
details.OpeningThemes = parseOpeningThemes(reader)
details.EndingThemes = parseEndingThemes(reader)
details.ScoreVoters = parseScoreVoters(reader)

synopsisNode := reader.Find("span[itemprop=description]")
Expand All @@ -240,11 +240,11 @@ func (c *Client) FetchDetails(entry *Anime) (*AnimeDetails, error) {

details.Premiered = parsePremiered(spanDarkText)
details.Broadcast = parseBroadcast(spanDarkText)
details.Producers = *parseProducers(spanDarkText)
details.Licensors = *parseLicensors(spanDarkText)
details.Studios = *parseStudios(spanDarkText)
details.Producers = parseProducers(spanDarkText)
details.Licensors = parseLicensors(spanDarkText)
details.Studios = parseStudios(spanDarkText)
details.Source = parseSource(spanDarkText)
details.Genres = *parseGenres(spanDarkText)
details.Genres = parseGenres(spanDarkText)
details.Duration = parseDuration(spanDarkText)
details.Rating = parseRating(spanDarkText)
details.Score = parseScore(spanDarkText)
Expand Down

0 comments on commit 2a576ec

Please sign in to comment.