gofaker

package module
v0.0.0-...-782a010 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Jul 18, 2013 License: MIT Imports: 10 Imported by: 0

README

GoFaker
================

gofaker is a port of Faker from Ruby.

How to use
-----------------

::

   import (
   	"fmt"
   	"bitbucket.org/r_rudi/gofaker"
   )

   func main(){
   	faker, _ := gofaker.NewFaker("en_US", "src/bitbucket.org/r_rudi/gofaker/dict/")
   	fmt.Printf("Name: %s %s\n", faker.Name.First_name, faker.Name.Last_name)
   	fmt.Printf("Phone: %s\n", faker.Name.Phone)
   	fmt.Printf("%s %s %s, %s\n", faker.Address.Building_number, faker.Address.Street, faker.Address.City, faker.Address.State)
   	fmt.Printf("Zip: %s\n", faker.Address.Zipcode)
   }

Result::

   Name: Lois Evans
   Phone: 2-(078)367-1331
   3 Boyd Tustin, Ohio
   Zip: 65022-1364


Dictonary
---------------

gofaker read dictionary data from "dict" directory and separated as
locale string.

::

   dict
   |-- base
   |   |-- building_numbers
   |   |-- cities
   |   |-- company_names
   |   |-- phone
   |   `-- ...
   `-- ja_JP
       |-- building_numbers
       |-- female_first_names
       |-- last_names
       |-- male_first_names
       |-- phone
       `-- zipcode

gofaker searchs under the locale directory at first, if not find, then
search from "base" directroy.

alt
-----------

A dictonary file has one value by each line. But some files such as
last_names and first_names have multiple values which are separeted by "|". ex) california|CA

This is the alt value and can be used as "_alt" valiable.

::

  fmt.Println(faker.Name.Last_name_alt)

This can be used as "Furigana" or Abbrev value.

Available Data
------------------

name
++++++++

- First_name
- Lirst_name
- First_name_Alt (used for "Furigana", if dict has)
- Lirst_name_Alt
- Phone

address
++++++++

- Country
- City
- State
- Street
- Building_number
- Zipcode

company
++++++++

- Name
- Phone

internet
++++++++

- Url
- Domain
- Email

The giants on whose shoulders this works stands
----------------------------------------------------

- faker: http://faker.rubyforge.org/
- forgery: https://github.com/sevenwire/forgery

  - base data is copied from forgery. many thanks.

License
------------------

MIT License

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func GetValue

func GetValue(locale string, fieldName string) string

GetValue returnes a value from specified locale and fieldName locale example: en_US, ja_JP

Types

type Address

type Address struct {
	Country         string
	City            string
	State           string
	Street          string
	Building_number string

	Latitude  string
	Longitude string

	Zipcode string
}

func NewAddress

func NewAddress(locale string) Address

type Company

type Company struct {
	Name  string
	Phone string
}

func NewCompany

func NewCompany(locale string) Company

type Faker

type Faker struct {
	Name     Name
	Address  Address
	Company  Company
	Internet Internet
}

func NewFaker

func NewFaker(locale string, dict string) (Faker, error)

type Internet

type Internet struct {
	Domain string
	Email  string
	Url    string
}

func NewInternet

func NewInternet(locale string) Internet

type Name

type Name struct {
	First_name     string
	First_name_alt string
	Last_name      string
	Last_name_alt  string
	Phone          string
	Gender         string
	Title          string
}

func NewName

func NewName(locale string) Name

NewName returnes Name struct which includes fake data.

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL