kolpa

package module
v0.0.0-...-315f7b3 Latest Latest
Warning

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

Go to latest
Published: Oct 24, 2020 License: MIT Imports: 13 Imported by: 0

README

kolpa Build Status Godoc license

kolpa is a fake data generator written in and for Go.
It's capable of generating fake data for following instances for now,

  • Name
  • Address
  • Phone Number
  • Email Address
  • Gender
  • Payment Card
  • Lorem Ipsum Text
  • Color
  • Datetime
  • User Agent

Installation

run go get github.com/malisit/kolpa on your command line.

Usage

package main

import (
	"fmt"
	"github.com/malisit/kolpa"
	"time"
)

func main() {
	k := kolpa.C() // Initiate kolpa
	
	fmt.Println(k.FirstName()) // Prints John
	fmt.Println(k.Address()) // Prints 729 Richmond Springs Suite 949, Luisborough, VT 85700-5554
	fmt.Println(k.UserAgent()) // Prints Mozilla/5.0 (compatible; MSIE 5.0; Windows 98; Win 9x 4.90; Trident/4.0)
	fmt.Println(k.Color()) // Prints Lime #00FF00
	fmt.Println(k.DateTimeAfter(time.Date(2015, 1, 0, 0, 0, 0, 0, time.UTC))) // Prints 2015-09-08 15:34:29 +0300 EEST
	fmt.Println(k.Email()) // Prints Jay.Hayden@fakemail.com
	fmt.Println(k.Phone()) // Prints +55-44-63311072
	fmt.Println(k.Gender()) // Prints male
	fmt.Println(k.PaymentCard()) // Prints 4083453410931987
	fmt.Println(k.LoremSentence()) // Prints "Provident nobis nostrum blanditiis voluptatem animi rerum harum."

}

List of all possible functions can be seen on godoc.

You can set language when initiating kolpa.

k := kolpa.C("tr_TR")

Language can be setted afterwards as well.

k.SetLanguage("tr_TR")

Documentation

Index

Constants

This section is empty.

Variables

View Source
var Print = fmt.Println

Debugging purposes

Functions

This section is empty.

Types

type Generator

type Generator struct {
	Locale_ string
	Pkg     string
}

Generator struct to access various generator functions

func C

func C(localeVar ...string) Generator

C is the creator function, initiates kolpa with or without locale setting. The default locale setting is "en_US". Returns a generator type that will be used to call generator methods.

func (*Generator) Address

func (g *Generator) Address() string

Address function returns a random full address. A convenience function, same as g.GenericGenerator("address_address"). Sample Output: 52185 Katelyn Court Suite 559, Romanstad, AZ 80645

func (*Generator) BuildingNumber

func (g *Generator) BuildingNumber() string

BuildingNumber function returns a random building number. A convenience function, same as g.GenericGenerator("address_building_number"). Sample Output: 27689

func (*Generator) Chrome

func (g *Generator) Chrome() string

Chrome function returns a random Chrome user agent. A convenience function, same as g.GenericGenerator("user_agent_chrome").

func (*Generator) City

func (g *Generator) City() string

City function returns a random city name. A convenience function, same as g.GenericGenerator("address_building_number"). Sample Output: 27689

func (*Generator) CityPrefix

func (g *Generator) CityPrefix() string

CityPrefix function returns a random city prefix. A convenience function, same as g.GenericGenerator("address_city_prefix"). Sample Output: Lake

func (*Generator) CitySuffix

func (g *Generator) CitySuffix() string

CitySuffix function returns a random city suffix. A convenience function, same as g.GenericGenerator("address_city_suffix"). Sample Output: fort

func (*Generator) Color

func (g *Generator) Color() string

func (*Generator) DateFormatter

func (g *Generator) DateFormatter(layout, datetime string) string

DateFormatter formats given datetime string with given layout. To define your own format, write down what the reference time would look like formatted your way; see the values of constants like ANSIC, StampMicro or Kitchen of time package for examples.

func (*Generator) DateTimeAfter

func (g *Generator) DateTimeAfter(afterObj time.Time) time.Time

DateTimeAfter returns a time.Time typed variable which is a pseudo-random datetime that points to a date and time pair that is after the given datetime parameter.

func (*Generator) DateTimeAfterWithString

func (g *Generator) DateTimeAfterWithString(after string) time.Time

DateTimeAfterWithString is same with DateTimeAfter but takes datetime parameter as string with time.RFC3339 builtin format.

func (*Generator) DateTimeBefore

func (g *Generator) DateTimeBefore(beforeObj time.Time) time.Time

DateTimeBefore returns a time.Time typed variable which is a pseudo-random datetime that points to a date and time pair that is before the given datetime parameter.

func (*Generator) DateTimeBeforeWithString

func (g *Generator) DateTimeBeforeWithString(before string) time.Time

DateTimeBeforeWithString is same with DateTimeBefore but takes datetime parameter as string with time.RFC3339 builtin format.

func (*Generator) DateTimeBetween

func (g *Generator) DateTimeBetween(afterObj time.Time, beforeObj time.Time) time.Time

DateTimeBetween returns a time.Time typed variable which is a pseudo-random datetime that points to a date and time pair between given datetime interval.

func (*Generator) DateTimeBetweenWithString

func (g *Generator) DateTimeBetweenWithString(after string, before string) time.Time

DateTimeBetweenWithString is same with DateTimeBetween but takes interval as strings with time.RFC3339 builtin format.

func (*Generator) Email

func (g *Generator) Email() string

Address function returns a random email address. A convenience function, same as g.GenericGenerator("email"), but only for en_US language Sample Output: Jay.Hayden@fakemail.com

func (*Generator) EmailFemale

func (g *Generator) EmailFemale() string

Address function returns a random female email address. A convenience function, same as g.GenericGenerator("email_female"), but only for en_US language Sample Output: Alice.Hayden@fakemail.com

func (*Generator) EmailMale

func (g *Generator) EmailMale() string

Address function returns a random male email address. A convenience function, same as g.GenericGenerator("email_male"), but only for en_US language Sample Output: Jay.Hayden@fakemail.com

func (*Generator) Firefox

func (g *Generator) Firefox() string

Firefox function returns a random Mozilla Firefox user agent. A convenience function, same as g.GenericGenerator("user_agent_firefox").

func (*Generator) FirstName

func (g *Generator) FirstName() string

FirstName function returns a random first name. A convenience function, same as g.GenericGenerator("person_first_name"). Sample Output: Jane

func (*Generator) FirstNameFemale

func (g *Generator) FirstNameFemale() string

FirstNameFemale function returns a random female first name. A convenience function, same as g.GenericGenerator("person_first_name_female"). Sample Output: Jane

func (*Generator) FirstNameMale

func (g *Generator) FirstNameMale() string

FirstNameMale function returns a random male first name. A convenience function, same as g.GenericGenerator("person_first_name_male"). Sample Output: John

func (*Generator) Gender

func (g *Generator) Gender() string

Gender function returns a random person gender. Sample Output: "male"

func (*Generator) GenericGenerator

func (g *Generator) GenericGenerator(intended string) string

GenericGenerator is the generic function that powers all generations within kolpa. Recursively generates data for intended data type. Intended variable should be slug version of a valid data type.

func (*Generator) InternetExplorer

func (g *Generator) InternetExplorer() string

InternetExplorer function returns a random Internet Explorer user agent. A convenience function, same as g.GenericGenerator("user_agent_internet_explorer").

func (*Generator) LastName

func (g *Generator) LastName() string

LastName function returns a random last name. A convenience function, same as g.GenericGenerator("person_last_name"). Sample Output: Doe

func (*Generator) LastNameFemale

func (g *Generator) LastNameFemale() string

LastNameFemale function returns a random female last name. A convenience function, same as g.GenericGenerator("person_last_name_female"). Sample Output: Doe

func (*Generator) LastNameMale

func (g *Generator) LastNameMale() string

LastNameMale function returns a random male last name. A convenience function, same as g.GenericGenerator("person_last_name_male"). Sample Output: Doe

func (*Generator) Locale

func (g *Generator) Locale() string

Locale function returns a random locale with format of en-US. A convenience function, same as g.GenericGenerator("locale").

func (*Generator) LocaleWithUnderscore

func (g *Generator) LocaleWithUnderscore() string

LocaleWithUnderscore function returns a random locale with format of en_US. A convenience function, same as g.GenericGenerator("locale_").

func (*Generator) LoremParagraph

func (g *Generator) LoremParagraph() string

LoremParagraph function returns a random lorem paragraph. Sample Output: Quia et minima saepe aspernatur laboriosam non id eum. Nulla iste ea necessitatibus molestiae omnis et est. Nisi cum commodi ex rerum aperiam earum in.

func (*Generator) LoremSentence

func (g *Generator) LoremSentence() string

LoremSentence function returns a random lorem sentence. Sample Output: Provident nobis nostrum blanditiis voluptatem animi rerum harum.

func (*Generator) LoremWord

func (g *Generator) LoremWord() string

LoremWord function returns a random lorem word. A convenience function, same as g.GenericGenerator("lorem_word"). Sample Output: dolores

func (*Generator) MasterCard

func (g *Generator) MasterCard() string

PaymentCard function returns a random master card number. A convenience function, same as g.GenericGenerator("payment_master_card"). Sample Output: 5154214251151243

func (*Generator) MilitaryAPO

func (g *Generator) MilitaryAPO() string

MilitaryAPO function returns a random military APO. A convenience function, same as g.GenericGenerator("address_military_apo"). Sample Output: PSC 3455, Box 7670

func (*Generator) MilitaryDPO

func (g *Generator) MilitaryDPO() string

MilitaryDPO function returns a random military DPO. A convenience function, same as g.GenericGenerator("address_military_dpo"). Sample Output: Unit 5426 Box 1476

func (*Generator) MilitaryShipPrefix

func (g *Generator) MilitaryShipPrefix() string

MilitaryShipPrefix function returns a random military ship prefix. A convenience function, same as g.GenericGenerator("address_military_ship_prefix"). Sample Output: USCGC

func (*Generator) MilitaryStateAbbr

func (g *Generator) MilitaryStateAbbr() string

MilitaryStateAbbr function returns a random military state abbreviation. A convenience function, same as g.GenericGenerator("address_military_state_abbr"). Sample Output: AE

func (*Generator) Name

func (g *Generator) Name() string

Name function returns a random full person name. A convenience function, same as g.GenericGenerator("person_format"). Sample Output: John Doe

func (*Generator) NameFemale

func (g *Generator) NameFemale() string

NameFemale function returns a random full female name by using a random female name format. A convenience function, same as g.GenericGenerator("person_format_female"). Sample Output: Jane Doe

func (*Generator) NameMale

func (g *Generator) NameMale() string

NameMale function returns a random full male name by using a random male name format. A convenience function, same as g.GenericGenerator("person_format_male"). Sample Output: John Doe

func (*Generator) Opera

func (g *Generator) Opera() string

Opera function returns a random Opera user agent. A convenience function, same as g.GenericGenerator("user_agent_opera").

func (*Generator) PaymentCard

func (g *Generator) PaymentCard() string

PaymentCard function returns a random payment card number. A convenience function, same as g.GenericGenerator("payment_card"). Sample Output: 24208918642114291

func (*Generator) Phone

func (g *Generator) Phone() string

Phone function returns a random phone number. A convenience function, same as g.GenericGenerator("phone") Sample Output: +55-44-63311072

func (*Generator) Postcode

func (g *Generator) Postcode() string

Postcode function returns a random postcode. A convenience function, same as g.GenericGenerator("address_postcode"). Sample Output: 17073

func (*Generator) Prefix

func (g *Generator) Prefix() string

Prefix function returns a random prefix. A convenience function, same as g.GenericGenerator("person_prefix"). Sample Output: Dr.

func (*Generator) PrefixFemale

func (g *Generator) PrefixFemale() string

PrefixFemale function returns a random female prefix. A convenience function, same as g.GenericGenerator("person_prefix_female"). Sample Output: Ms.

func (*Generator) PrefixMale

func (g *Generator) PrefixMale() string

PrefixMale function returns a random male prefix. A convenience function, same as g.GenericGenerator("person_prefix_male"). Sample Output: Mr.

func (*Generator) Safari

func (g *Generator) Safari() string

Safari function returns a random Apple Safari user agent. A convenience function, same as g.GenericGenerator("user_agent_safari").

func (*Generator) SecondaryAddress

func (g *Generator) SecondaryAddress() string

SecondaryAddress function returns a random secondary address. A convenience function, same as g.GenericGenerator("address_secondary_address"). Sample Output: Apt. 786

func (*Generator) SetLanguage

func (g *Generator) SetLanguage(localeVar string)

SetLanguage is the language setter function. Language setting change be changed anytime by using this function.

func (*Generator) State

func (g *Generator) State() string

State function returns a random state name. A convenience function, same as g.GenericGenerator("address_state"). Sample Output: Illinois

func (*Generator) StateAbbr

func (g *Generator) StateAbbr() string

StateAbbr function returns a random state name abbreviation. A convenience function, same as g.GenericGenerator("address_state_abbr"). Sample Output: AL

func (*Generator) StreetAddress

func (g *Generator) StreetAddress() string

StreetAddress function returns a random street address. A convenience function, same as g.GenericGenerator("address_street_address"). Sample Output: 98191 Miranda Knoll

func (*Generator) StreetName

func (g *Generator) StreetName() string

StreetName function returns a random street name. A convenience function, same as g.GenericGenerator("address_street_name"). Sample Output: Rodney Station

func (*Generator) StreetSuffix

func (g *Generator) StreetSuffix() string

StreetSuffix function returns a random street suffix.s A convenience function, same as g.GenericGenerator("address_street_suffix"). Sample Output: Pines

func (*Generator) Suffix

func (g *Generator) Suffix() string

Suffix function returns a random suffix. A convenience function, same as return g.GenericGenerator("person_suffix"). Sample Output: PhD.

func (*Generator) SuffixFemale

func (g *Generator) SuffixFemale() string

SuffixFemale function returns a random female suffix. A convenience function, same as g.GenericGenerator("person_suffix_female"). Sample Output: MD.

func (*Generator) SuffixMale

func (g *Generator) SuffixMale() string

SuffixMale function returns a random male suffix. A convenience function, same as g.GenericGenerator("person_suffix_male"). Sample Output: Jr..

func (*Generator) UserAgent

func (g *Generator) UserAgent() string

UserAgent function returns a random user agent. A convenience function, same as g.GenericGenerator("user_agent").

func (*Generator) VisaCard

func (g *Generator) VisaCard() string

PaymentCard function returns a random master card number. A convenience function, same as g.GenericGenerator("payment_visa_card"). Sample Output: 4292198623077593

Jump to

Keyboard shortcuts

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