go-faker / faker

Go (Golang) Fake Data Generator for Struct, previously https://github.com/bxcodec/faker
https://pkg.go.dev/github.com/go-faker/faker/v4
MIT License
614 stars 30 forks source link

fix: support for custom key map #16

Closed xesina closed 1 year ago

xesina commented 1 year ago

With a custom key map, we get a panic.

package main

import "github.com/go-faker/faker/v4"

func main()  {
    type CustomString string
    type CustomStruct struct {
        Map map[CustomString]string
    }

    faker.FakeData(&CustomStruct{})
}

This PR will fix this issue by converting the reflected map key.

codecov-commenter commented 1 year ago

Codecov Report

Base: 88.99% // Head: 88.99% // Increases project coverage by +0.00% :tada:

Coverage data is based on head (eb8370e) compared to base (12df95a). Patch coverage: 100.00% of modified lines in pull request are covered.

Additional details and impacted files ```diff @@ Coverage Diff @@ ## main #16 +/- ## ======================================= Coverage 88.99% 88.99% ======================================= Files 12 12 Lines 1735 1736 +1 ======================================= + Hits 1544 1545 +1 Misses 137 137 Partials 54 54 ``` | [Impacted Files](https://codecov.io/gh/go-faker/faker/pull/16?src=pr&el=tree&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=None) | Coverage Δ | | |---|---|---| | [faker.go](https://codecov.io/gh/go-faker/faker/pull/16?src=pr&el=tree&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=None#diff-ZmFrZXIuZ28=) | `85.87% <100.00%> (+0.01%)` | :arrow_up: | Help us with your feedback. Take ten seconds to tell us [how you rate us](https://about.codecov.io/nps?utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=None). Have a feature suggestion? [Share it here.](https://app.codecov.io/gh/feedback/?utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=None)

:umbrella: View full report at Codecov.
:loudspeaker: Do you have feedback about the report comment? Let us know in this issue.