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
658 stars 31 forks source link

Add support for Street Address #11

Closed TristanSpeakEasy closed 1 year ago

TristanSpeakEasy commented 1 year ago

would be great to generate street addresses something like:

419 Indian Spring Street
Hattiesburg, MS 39401

could just be US addresses for now, but would be great to also specify regions and get random addresses based on different regions like the UK/Europe/China etc

bxcodec commented 1 year ago

I'll try to look into this in more detail.

cc @wolf-joe

wolf-joe commented 1 year ago

I'll try to look into this in more detail.

cc @wolf-joe

I found some projects like neosergio/random-address / EthanRBrown/rrad can generate US addresses, and some projects like openaddresses/openaddresses provide a global collection of addresses. I think reusing them is a good idea

bxcodec commented 1 year ago

Sadly they're not in the Golang package. Not sure how we can import them into this library Random idea, should we make another package just for addresses that will base on the open address?

wolf-joe commented 1 year ago

Golang support embedding file into binaries after Go 1.16[^1],so we can copy the data file into this project.

[^1]: How to embed files into Go binaries - Stack Overflow

bxcodec commented 1 year ago

I don't think that's good practice. It will make the user must have the file ready.

wolf-joe commented 1 year ago

I don't think that's good practice. It will make the user must have the file ready.

Not really. Golang's embed feature allows binaries contains text file. So we can copy those address files into this project, and users who want random addresses just need to go get this project.

I will try this recently.

wolf-joe commented 1 year ago

I added a new function named GetRealAddress, using data from EthanRBrown/rrad, simple but works.

rscorer commented 1 year ago

This is a great addition, but I keep being informed Tag unsupported: real_address - do we need to add RealAddressTag to initDefaultTag and/or initMappertTagDefault?

I made sure I'm using v4.0.0

wolf-joe commented 1 year ago

This is a great addition, but I keep being informed Tag unsupported: real_address - do we need to add RealAddressTag to initDefaultTag and/or initMappertTagDefault?

I made sure I'm using v4.0.0

Yeah, I made a new MR (#18) to fix this.