Randomdata : a tiny help suite for generating random data

go-randomdata

contributions welcome GoDoc Build Status Go Report Card

randomdata is a tiny help suite for generating random data such as

  • first names (male or female)
  • last names
  • full names (male or female)
  • country names (full name or iso 3166.1 alpha-2 or alpha-3)
  • locales / language tags (bcp-47)
  • random email address
  • city names
  • American state names (two chars or full)
  • random numbers (in an interval)
  • random paragraphs
  • random bool values
  • postal- or zip-codes formatted for a range of different countries.
  • american sounding addresses / street names
  • silly names - suitable for names of things
  • random days
  • random months
  • random full date
  • random full profile
  • random date inside range
  • random phone number

Installation

go get github.com/Pallinder/go-randomdata

Usage

package main

import (
    "fmt"
    "github.com/Pallinder/go-randomdata"
)

func main() {
    // Print a random silly name
    fmt.Println(randomdata.SillyName())

    // Print a male title
    fmt.Println(randomdata.Title(randomdata.Male))

    // Print a female title
    fmt.Println(randomdata.Title(randomdata.Female))

    // Print a title with random gender
    fmt.Println(randomdata.Title(randomdata.RandomGender))

    // Print a male first name
    fmt.Println(randomdata.FirstName(randomdata.Male))

    // Print a female first name
    fmt.Println(randomdata.FirstName(randomdata.Female))

    // Print a last name
    fmt.Println(randomdata.LastName())

    // Print a male name
    fmt.Println(randomdata.FullName(randomdata.Male))

    // Print a female name
    fmt.Println(randomdata.FullName(randomdata.Female))

    // Print a name with random gender
    fmt.Println(randomdata.FullName(randomdata.RandomGender))

    // Print an email
    fmt.Println(randomdata.Email())

    // Print a country with full text representation
    fmt.Println(randomdata.Country(randomdata.FullCountry))

    // Print a country using ISO 3166-1 alpha-2
    fmt.Println(randomdata.Country(randomdata.TwoCharCountry))

    // Print a country using ISO 3166-1 alpha-3
    fmt.Println(randomdata.Country(randomdata.ThreeCharCountry))
    
    // Print BCP 47 language tag
    fmt.Println(randomdata.Locale())

    // Print a currency using ISO 4217
    fmt.Println(randomdata.Currency())

    // Print the name of a random city
    fmt.Println(randomdata.City())

    // Print the name of a random american state
    fmt.Println(randomdata.State(randomdata.Large))

    // Print the name of a random american state using two chars
    fmt.Println(randomdata.State(randomdata.Small))

    // Print an american sounding street name
    fmt.Println(randomdata.Street())

    // Print an american sounding address
    fmt.Println(randomdata.Address())

    // Print a random number >= 10 and < 20
    fmt.Println(randomdata.Number(10, 20))

    // Print a number >= 0 and < 20
    fmt.Println(randomdata.Number(20))

    // Print a random float >= 0 and < 20 with decimal point 3
    fmt.Println(randomdata.Decimal(0, 20, 3))

    // Print a random float >= 10 and < 20
    fmt.Println(randomdata.Decimal(10, 20))

    // Print a random float >= 0 and < 20
    fmt.Println(randomdata.Decimal(20))

    // Print a bool
    fmt.Println(randomdata.Boolean())

    // Print a paragraph
    fmt.Println(randomdata.Paragraph())

    // Print a postal code
    fmt.Println(randomdata.PostalCode("SE"))

    // Print a set of 2 random numbers as a string
    fmt.Println(randomdata.StringNumber(2, "-"))

    // Print a set of 2 random 3-Digits numbers as a string
    fmt.Println(randomdata.StringNumberExt(2, "-", 3))

    // Print a random string sampled from a list of strings
    fmt.Println(randomdata.StringSample("my string 1", "my string 2", "my string 3"))

    // Print a valid random IPv4 address
    fmt.Println(randomdata.IpV4Address())

    // Print a valid random IPv6 address
    fmt.Println(randomdata.IpV6Address())

    // Print a browser's user agent string
    fmt.Println(randomdata.UserAgentString())

    // Print a day
    fmt.Println(randomdata.Day())

    // Print a month
    fmt.Println(randomdata.Month())

    // Print full date like Monday 22 Aug 2016
    fmt.Println(randomdata.FullDate())

    // Print full date <= Monday 22 Aug 2016
    fmt.Println(randomdata.FullDateInRange("2016-08-22"))

    // Print full date >= Monday 01 Aug 2016 and <= Monday 22 Aug 2016
    fmt.Println(randomdata.FullDateInRange("2016-08-01", "2016-08-22"))

    // Print phone number according to e.164
    fmt.Println(randomdata.PhoneNumber())

    // Get a complete and randomised profile of data generally used for users
    // There are many fields in the profile to use check the Profile struct definition in fullprofile.go
    profile := randomdata.GenerateProfile(randomdata.Male | randomdata.Female | randomdata.RandomGender)
    fmt.Printf("The new profile's username is: %s and password (md5): %s\n", profile.Login.Username, profile.Login.Md5)

    // Get a random country-localised street name for Great Britain
    fmt.Println(randomdata.StreetForCountry("GB"))
    // Get a random country-localised street name for USA
    fmt.Println(randomdata.StreetForCountry("US"))

    // Get a random country-localised province for Great Britain
    fmt.Println(randomdata.ProvinceForCountry("GB"))
    // Get a random country-localised province for USA
    fmt.Println(randomdata.ProvinceForCountry("US"))
}

Versioning / Release Strategy

Go-Randomdata follows Semver

You can find current releases tagged under the releases section.

The CHANGELOG.md file contains the changelog of the project.

Contributors

All the other contributors are listed here.

Similar Resources

:guardsman: A teeny tiny and somewhat opinionated generator for your next golang project

A Yeoman Golang Generator We are very sorry Gophers, but other names for the generator where taken, so we choose go-lang. But we have gocreate as an a

Sep 27, 2022

💥 Fusion is a tiny stream processing library written in Go.

💥 Fusion Fusion is a tiny stream processing library written in Go. See reactor for a stream processing tool built using fusion. Features Simple & lig

Jun 30, 2021

Tiny 10MinuteMail wrapper for Go.

tmm Tiny package that uses 10MinuteMail to generate temporary email addresses. Zero dependancies. Supports receiving, forwarding and replying to messa

Nov 29, 2021

Squizit is a simple tool, that aim to help you get the grade you want, not the one you have learnt for.

Squizit is a simple tool, that aim to help you get the grade you want, not the one you have learnt for.

Squizit is a simple tool, that aim to help you get the grade you want, not the one you have learnt for. Screenshots First, input PIN Then enjoy! Hoste

Mar 11, 2022

Help to release a project which especially has multiple git repositories

This project aims to help to release a project which especially has multiple git repositories. Installation Install it to a Kubernetes cluster. You ca

Dec 15, 2022

A Golang program for a colleague to help in calculating the ratio between the points obtained in a test and the corresponding evaluation in tenths.

A Golang program for a colleague to help in calculating the ratio between the points obtained in a test and the corresponding evaluation in tenths.

A Golang program for a colleague to help in calculating the ratio between the points obtained in a test and the corresponding evaluation in tenths. If you have not the compiled file (.exe) you can build it with the Go compiler.

Jul 7, 2022

TLDR Page Creator is a program designed to help users make TLDR pages

TLDR Page Creator is a program designed to help users make TLDR pages, while avoiding syntax errors from TLDR-style markdown.

Dec 3, 2022

Hrple is an easy to use tool to help you create habits

Hrple is an easy to use tool to help you create habits

Hrple is an easy to use tool to help you create habits. This is loosely inspired by the book Atomic Habits by James Clear and techniques or frameworks like Kanban and the Pomodoro Technique.

Jun 2, 2022

This repository provides various utilities to help you build your NFT collection!

Attention! A powerful computer may be required! About This repository provides various utilities to help you build your NFT collection: Generate image

Nov 4, 2022
Comments
  • 1.2.0

    1.2.0

    Background MANDATORY Describe WHY this change is being made, be clear, use proper English and don't write lines longer than 80 chars.

    Caveats OPTIONAL Discuss any caveats your code may contain, remove if not needed.

    Changes MANDATORY

    • List your major changes one by one

    Checklist

    • [ ] Tests added
    • [ ] Documentation updated to include changes (if needed)
    • [ ] Gofmt run on your code
Random fake data and struct generator for Go.

Faker Random fake data and struct generator for Go. More than 100 generator functions Struct generator Unique data generator Builtin types support Eas

Oct 3, 2022
Random fake data generator written in go
Random fake data generator written in go

Gofakeit Random data generator written in go Features 160+ Functions!!! Concurrent Global Rand Struct Generator Custom Functions Http Server Command L

Jan 1, 2023
Scripts for generating go code using abigen

Scripts for generating go code using abigen

Nov 15, 2021
An application dedicated to the trivial and boring task of meal planning 📅 and generating shoppings list 🛒.
An application dedicated to the trivial and boring task of meal planning 📅 and generating shoppings list 🛒.

An application dedicated to the trivial and boring task of meal planning ?? and generating shoppings list ??.

Mar 1, 2022
Generate random, pronounceable, sometimes even memorable, "superhero like" codenames - just like Docker does with container names.

Codename an RFC1178 implementation to generate pronounceable, sometimes even memorable, "superheroe like" codenames, consisting of a random combinatio

Dec 11, 2022
A repository of random code snippets used to develop proof of concepts

Oddments Oddments is a repository of random code snippets used to develop proof of concepts for techniques used with the Windows operating system. POC

Oct 13, 2022
Helps exercise your memory by giving you random tokens and poems to memorize.

memory-enhancer Helps exercise your memory by giving you random tokens and poems to memorize. Using Every day when you first open your terminal you wi

Nov 9, 2021
Rfpm - Random Fair Preemption Model For Golang

rfpm RFPM (Random Fair Preemption Model) is absolutely fair to all clients who r

Jan 7, 2022
Go package and associated command line utility to generate random yet human-readable names and identifiers
Go package and associated command line utility to generate random yet human-readable names and identifiers

namegen | What's this? Go package and associated command line utility to generate random yet human-readable names and identifiers. Somewhat inspired b

Oct 19, 2022
Package reservoir samples values uniformly at random from an unbounded sequence of inputs

Package reservoir samples values uniformly at random from an unbounded sequence of inputs

Oct 5, 2022