contact.go 948 B

12345678910111213141516171819202122232425262728293031323334353637383940
  1. package gofakeit
  2. import (
  3. "strings"
  4. )
  5. // ContactInfo struct full of contact info
  6. type ContactInfo struct {
  7. Phone string
  8. Email string
  9. }
  10. // Contact will generate a struct with information randomly populated contact information
  11. func Contact() *ContactInfo {
  12. return &ContactInfo{
  13. Phone: Phone(),
  14. Email: Email(),
  15. }
  16. }
  17. // Phone will generate a random phone number string
  18. func Phone() string {
  19. return replaceWithNumbers("##########")
  20. }
  21. // PhoneFormatted will generate a random phone number string
  22. func PhoneFormatted() string {
  23. return replaceWithNumbers(getRandValue([]string{"contact", "phone"}))
  24. }
  25. // Email will generate a random email string
  26. func Email() string {
  27. var email string
  28. email = getRandValue([]string{"person", "first"}) + getRandValue([]string{"person", "last"})
  29. email += "@"
  30. email += getRandValue([]string{"person", "last"}) + "." + getRandValue([]string{"internet", "domain_suffix"})
  31. return strings.ToLower(email)
  32. }