From 498a0ce7e77c2d5390c250b6ca6d17a108069515 Mon Sep 17 00:00:00 2001 From: "deepsource-autofix[bot]" <62050782+deepsource-autofix[bot]@users.noreply.github.com> Date: Sun, 25 Dec 2022 11:27:34 +0000 Subject: [PATCH] Replace empty slice literal with `var` (#128) * Replace empty slice literal with `var` * Initialize map with make() function Co-authored-by: deepsource-autofix[bot] <62050782+deepsource-autofix[bot]@users.noreply.github.com> Co-authored-by: Jonathan Schweder --- faker.go | 9 ++++++--- 1 file changed, 6 insertions(+), 3 deletions(-) diff --git a/faker.go b/faker.go index d154492..8e11771 100644 --- a/faker.go +++ b/faker.go @@ -229,7 +229,8 @@ func (f Faker) RandomLetter() string { } func (f Faker) RandomStringWithLength(l int) string { - r := []string{} + var r []string + for i := 0; i < l; i++ { r = append(r, f.RandomLetter()) } @@ -344,7 +345,8 @@ func (f Faker) Boolean() Boolean { // Map returns a fake Map instance for Faker func (f Faker) Map() map[string]interface{} { - m := map[string]interface{}{} + m := make(map[string]interface{}) + lorem := f.Lorem() randWordType := func() string { @@ -382,7 +384,8 @@ func (f Faker) Map() map[string]interface{} { case "slice": m[lorem.Word()] = randSlice() case "map": - mm := map[string]interface{}{} + mm := make(map[string]interface{}) + tt := f.RandomStringElement([]string{"string", "int", "float", "slice"}) switch tt { case "string":