Rename to craban

This commit is contained in:
Miguel de la Cruz 2021-09-12 18:57:42 +02:00
parent 38767a78d3
commit ca0bfa2398
217 changed files with 23 additions and 23 deletions

26
server/vendor/github.com/icrowley/fake/.gitignore generated vendored Normal file
View file

@ -0,0 +1,26 @@
# Compiled Object files, Static and Dynamic libs (Shared Objects)
*.o
*.a
*.so
# Folders
_obj
_test
/vendor
# Architecture specific extensions/prefixes
*.[568vq]
[568vq].out
*.cgo1.go
*.cgo2.c
_cgo_defun.c
_cgo_gotypes.go
_cgo_export.*
_testmain.go
*.exe
*.test
*.prof
.DS_Store

View file

@ -0,0 +1,11 @@
{
"build_id_generator": "0x$(shell echo $(version) | sha1sum | awk '{print $$1}')",
"host": "github.com",
"include": [],
"kind": "package",
"name": "fake",
"tool": [],
"user": "icrowley",
"version_generator": "$(shell git rev-list --count HEAD).$(shell git rev-parse --short HEAD)",
"version_variable": "cli.version"
}

11
server/vendor/github.com/icrowley/fake/.travis.yml generated vendored Normal file
View file

@ -0,0 +1,11 @@
sudo: false
language: go
go:
- 1.6
- 1.7
- 1.8
- master
- tip
script: make test

22
server/vendor/github.com/icrowley/fake/LICENSE generated vendored Normal file
View file

@ -0,0 +1,22 @@
The MIT License (MIT)
Copyright (c) 2014 Dmitry Afanasyev
Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
in the Software without restriction, including without limitation the rights
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
copies of the Software, and to permit persons to whom the Software is
furnished to do so, subject to the following conditions:
The above copyright notice and this permission notice shall be included in all
copies or substantial portions of the Software.
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
SOFTWARE.

48
server/vendor/github.com/icrowley/fake/Makefile generated vendored Normal file
View file

@ -0,0 +1,48 @@
.DEFAULT_GOAL = all
numcpus := $(shell cat /proc/cpuinfo | grep '^processor\s*:' | wc -l)
version := $(shell git rev-list --count HEAD).$(shell git rev-parse --short HEAD)
name := fake
package := github.com/icrowley/$(name)
.PHONY: all
all:: dependencies
.PHONY: tools
tools::
@if [ ! -e "$(GOPATH)"/bin/glide ]; then go get github.com/Masterminds/glide; fi
@if [ ! -e "$(GOPATH)"/bin/godef ]; then go get github.com/rogpeppe/godef; fi
@if [ ! -e "$(GOPATH)"/bin/gocode ]; then go get github.com/nsf/gocode; fi
@if [ ! -e "$(GOPATH)"/bin/gometalinter ]; then go get github.com/alecthomas/gometalinter && gometalinter --install; fi
@if [ ! -e "$(GOPATH)"/src/github.com/stretchr/testify/assert ]; then go get github.com/stretchr/testify/assert; fi
.PHONY: dependencies
dependencies:: tools
glide install
.PHONY: clean
clean:: tools
glide cache-clear
.PHONY: test
test:: dependencies
go test -v \
$(shell glide novendor)
.PHONY: bench
bench:: dependencies
go test \
-bench=. -v \
$(shell glide novendor)
.PHONY: lint
lint:: dependencies
go vet $(shell glide novendor)
gometalinter \
--deadline=5m \
--concurrency=$(numcpus) \
$(shell glide novendor)
.PHONY: check
check:: lint test

90
server/vendor/github.com/icrowley/fake/README.md generated vendored Normal file
View file

@ -0,0 +1,90 @@
[![Build Status](https://img.shields.io/travis/icrowley/fake.svg?style=flat)](https://travis-ci.org/icrowley/fake) [![Godoc](http://img.shields.io/badge/godoc-reference-blue.svg?style=flat)](https://godoc.org/github.com/icrowley/fake) [![license](http://img.shields.io/badge/license-MIT-red.svg?style=flat)](https://raw.githubusercontent.com/icrowley/fake/master/LICENSE)
Fake
====
Fake is a fake data generator for Go (Golang), heavily inspired by the forgery and ffaker Ruby gems.
## About
Most data and methods are ported from forgery/ffaker Ruby gems.
For the list of available methods please look at https://godoc.org/github.com/icrowley/fake.
Currently english and russian languages are available.
Fake embeds samples data files unless you call `UseExternalData(true)` in order to be able to work without external files dependencies when compiled, so, if you add new data files or make changes to existing ones don't forget to regenerate data.go file using `github.com/mjibson/esc` tool and `esc -o data.go -pkg fake data` command (or you can just use `go generate` command if you are using Go 1.4 or later).
## Install
```shell
go get github.com/icrowley/fake
```
## Import
```go
import (
"github.com/icrowley/fake"
)
```
## Documentation
Documentation can be found at godoc:
https://godoc.org/github.com/icrowley/fake
## Test
To run the project tests:
```shell
cd test
go test
```
## Examples
```go
name := fake.FirstName()
fullname := fake.FullName()
product := fake.Product()
```
Changing language:
```go
err := fake.SetLang("ru")
if err != nil {
panic(err)
}
password := fake.SimplePassword()
```
Using english fallback:
```go
err := fake.SetLang("ru")
if err != nil {
panic(err)
}
fake.EnFallback(true)
password := fake.Paragraph()
```
Using external data:
```go
fake.UseExternalData(true)
password := fake.Paragraph()
```
### Author
Dmitry Afanasyev,
http://twitter.com/i_crowley
dimarzio1986@gmail.com
### Maintainers
Dmitry Moskowski
https://github.com/corpix

69
server/vendor/github.com/icrowley/fake/addresses.go generated vendored Normal file
View file

@ -0,0 +1,69 @@
package fake
import "strconv"
// Continent generates random continent
func Continent() string {
return lookup(lang, "continents", true)
}
// Country generates random country
func Country() string {
return lookup(lang, "countries", true)
}
// City generates random city
func City() string {
city := lookup(lang, "cities", true)
switch r.Intn(5) {
case 0:
return join(cityPrefix(), city)
case 1:
return join(city, citySuffix())
default:
return city
}
}
func cityPrefix() string {
return lookup(lang, "city_prefixes", false)
}
func citySuffix() string {
return lookup(lang, "city_suffixes", false)
}
// State generates random state
func State() string {
return lookup(lang, "states", false)
}
// StateAbbrev generates random state abbreviation
func StateAbbrev() string {
return lookup(lang, "state_abbrevs", false)
}
// Street generates random street name
func Street() string {
street := lookup(lang, "streets", true)
return join(street, streetSuffix())
}
// StreetAddress generates random street name along with building number
func StreetAddress() string {
return join(Street(), strconv.Itoa(r.Intn(100)))
}
func streetSuffix() string {
return lookup(lang, "street_suffixes", true)
}
// Zip generates random zip code using one of the formats specifies in zip_format file
func Zip() string {
return generate(lang, "zips", true)
}
// Phone generates random phone number using one of the formats format specified in phone_format file
func Phone() string {
return generate(lang, "phones", true)
}

69
server/vendor/github.com/icrowley/fake/credit_cards.go generated vendored Normal file
View file

@ -0,0 +1,69 @@
package fake
import (
"strings"
"strconv"
)
type creditCard struct {
vendor string
length int
prefixes []int
}
var creditCards = map[string]creditCard{
"visa": {"VISA", 16, []int{4539, 4556, 4916, 4532, 4929, 40240071, 4485, 4716, 4}},
"mastercard": {"MasterCard", 16, []int{51, 52, 53, 54, 55}},
"amex": {"American Express", 15, []int{34, 37}},
"discover": {"Discover", 16, []int{6011}},
}
// CreditCardType returns one of the following credit values:
// VISA, MasterCard, American Express and Discover
func CreditCardType() string {
n := len(creditCards)
var vendors []string
for _, cc := range creditCards {
vendors = append(vendors, cc.vendor)
}
return vendors[r.Intn(n)]
}
// CreditCardNum generated credit card number according to the card number rules
func CreditCardNum(vendor string) string {
if vendor != "" {
vendor = strings.ToLower(vendor)
} else {
var vendors []string
for v := range creditCards {
vendors = append(vendors, v)
}
vendor = vendors[r.Intn(len(vendors))]
}
card := creditCards[vendor]
prefix := strconv.Itoa(card.prefixes[r.Intn(len(card.prefixes))])
num := []rune(prefix)
for i := 0; i < card.length-len(prefix); i++ {
num = append(num, genCCDigit(num))
}
return string(num)
}
func genCCDigit(num []rune) rune {
sum := 0
for i := len(num) - 1; i >= 0; i-- {
n := int(num[i])
if i%2 != 0 {
sum += n
} else {
if n*2 > 9 {
sum += n*2 - 9
} else {
sum += n * 2
}
}
}
return rune(((sum/10+1)*10 - sum) % 10)
}

11
server/vendor/github.com/icrowley/fake/currencies.go generated vendored Normal file
View file

@ -0,0 +1,11 @@
package fake
// Currency generates currency name
func Currency() string {
return lookup(lang, "currencies", true)
}
// CurrencyCode generates currency code
func CurrencyCode() string {
return lookup(lang, "currency_codes", true)
}

493
server/vendor/github.com/icrowley/fake/data.go generated vendored Normal file

File diff suppressed because one or more lines are too long

42
server/vendor/github.com/icrowley/fake/dates.go generated vendored Normal file
View file

@ -0,0 +1,42 @@
package fake
// Day generates day of the month
func Day() int {
return r.Intn(31) + 1
}
// WeekDay generates name ot the week day
func WeekDay() string {
return lookup(lang, "weekdays", true)
}
// WeekDayShort generates abbreviated name of the week day
func WeekDayShort() string {
return lookup(lang, "weekdays_short", true)
}
// WeekdayNum generates number of the day of the week
func WeekdayNum() int {
return r.Intn(7) + 1
}
// Month generates month name
func Month() string {
return lookup(lang, "months", true)
}
// MonthShort generates abbreviated month name
func MonthShort() string {
return lookup(lang, "months_short", true)
}
// MonthNum generates month number (from 1 to 12)
func MonthNum() int {
return r.Intn(12) + 1
}
// Year generates year using the given boundaries
func Year(from, to int) int {
n := r.Intn(to-from) + 1
return from + n
}

214
server/vendor/github.com/icrowley/fake/fake.go generated vendored Normal file
View file

@ -0,0 +1,214 @@
/*
Package fake is the fake data generatror for go (Golang), heavily inspired by forgery and ffaker Ruby gems
Most data and methods are ported from forgery/ffaker Ruby gems.
Currently english and russian languages are available.
For the list of available methods please look at https://godoc.org/github.com/icrowley/fake.
Fake embeds samples data files unless you call UseExternalData(true) in order to be able to work without external files dependencies when compiled, so, if you add new data files or make changes to existing ones don't forget to regenerate data.go file using github.com/mjibson/esc tool and esc -o data.go -pkg fake data command (or you can just use go generate command if you are using Go 1.4 or later).
Examples:
name := fake.FirstName()
fullname = := fake.FullName()
product := fake.Product()
Changing language:
err := fake.SetLang("ru")
if err != nil {
panic(err)
}
password := fake.SimplePassword()
Using english fallback:
err := fake.SetLang("ru")
if err != nil {
panic(err)
}
fake.EnFallback(true)
password := fake.Paragraph()
Using external data:
fake.UseExternalData(true)
password := fake.Paragraph()
*/
package fake
import (
"fmt"
"io/ioutil"
"math/rand"
"strconv"
"strings"
"sync"
"time"
)
//go:generate go get github.com/mjibson/esc
//go:generate esc -o data.go -pkg fake data
// cat/subcat/lang/samples
type samplesTree map[string]map[string][]string
var samplesLock sync.Mutex
var samplesCache = make(samplesTree)
var r = rand.New(&rndSrc{src: rand.NewSource(time.Now().UnixNano())})
var lang = "en"
var useExternalData = false
var enFallback = true
var availLangs = GetLangs()
var (
// ErrNoLanguageFn is the error that indicates that given language is not available
ErrNoLanguageFn = func(lang string) error { return fmt.Errorf("The language passed (%s) is not available", lang) }
// ErrNoSamplesFn is the error that indicates that there are no samples for the given language
ErrNoSamplesFn = func(lang string) error { return fmt.Errorf("No samples found for language: %s", lang) }
)
// Seed uses the provided seed value to initialize the internal PRNG to a
// deterministic state.
func Seed(seed int64) {
r.Seed(seed)
}
type rndSrc struct {
mtx sync.Mutex
src rand.Source
}
func (s *rndSrc) Int63() int64 {
s.mtx.Lock()
n := s.src.Int63()
s.mtx.Unlock()
return n
}
func (s *rndSrc) Seed(n int64) {
s.mtx.Lock()
s.src.Seed(n)
s.mtx.Unlock()
}
// GetLangs returns a slice of available languages
func GetLangs() []string {
var langs []string
for k, v := range data {
if v.isDir && k != "/" && k != "/data" {
langs = append(langs, strings.Replace(k, "/data/", "", 1))
}
}
return langs
}
// SetLang sets the language in which the data should be generated
// returns error if passed language is not available
func SetLang(newLang string) error {
found := false
for _, l := range availLangs {
if newLang == l {
found = true
break
}
}
if !found {
return ErrNoLanguageFn(newLang)
}
lang = newLang
return nil
}
// UseExternalData sets the flag that allows using of external files as data providers (fake uses embedded ones by default)
func UseExternalData(flag bool) {
useExternalData = flag
}
// EnFallback sets the flag that allows fake to fallback to englsh samples if the ones for the used languaged are not available
func EnFallback(flag bool) {
enFallback = flag
}
func (st samplesTree) hasKeyPath(lang, cat string) bool {
if _, ok := st[lang]; ok {
if _, ok = st[lang][cat]; ok {
return true
}
}
return false
}
func join(parts ...string) string {
var filtered []string
for _, part := range parts {
if part != "" {
filtered = append(filtered, part)
}
}
return strings.Join(filtered, " ")
}
func generate(lang, cat string, fallback bool) string {
format := lookup(lang, cat+"_format", fallback)
var result string
for _, ru := range format {
if ru != '#' {
result += string(ru)
} else {
result += strconv.Itoa(r.Intn(10))
}
}
return result
}
func lookup(lang, cat string, fallback bool) string {
samplesLock.Lock()
s := _lookup(lang, cat, fallback)
samplesLock.Unlock()
return s
}
func _lookup(lang, cat string, fallback bool) string {
var samples []string
if samplesCache.hasKeyPath(lang, cat) {
samples = samplesCache[lang][cat]
} else {
var err error
samples, err = populateSamples(lang, cat)
if err != nil {
if lang != "en" && fallback && enFallback && err.Error() == ErrNoSamplesFn(lang).Error() {
return _lookup("en", cat, false)
}
return ""
}
}
return samples[r.Intn(len(samples))]
}
func populateSamples(lang, cat string) ([]string, error) {
data, err := readFile(lang, cat)
if err != nil {
return nil, err
}
if _, ok := samplesCache[lang]; !ok {
samplesCache[lang] = make(map[string][]string)
}
samples := strings.Split(strings.TrimSpace(string(data)), "\n")
samplesCache[lang][cat] = samples
return samples, nil
}
func readFile(lang, cat string) ([]byte, error) {
fullpath := fmt.Sprintf("/data/%s/%s", lang, cat)
file, err := FS(useExternalData).Open(fullpath)
if err != nil {
return nil, ErrNoSamplesFn(lang)
}
defer file.Close()
return ioutil.ReadAll(file)
}

79
server/vendor/github.com/icrowley/fake/general.go generated vendored Normal file
View file

@ -0,0 +1,79 @@
package fake
var lowerLetters = []rune("abcdefghijklmnopqrstuvwxyz")
var upperLetters = []rune("ABCDEFGHIJKLMNOPQRSTUVWXYZ")
var numeric = []rune("0123456789")
var specialChars = []rune(`!'@#$%^&*()_+-=[]{};:",./?`)
var hexDigits = []rune("0123456789abcdef")
func text(atLeast, atMost int, allowLower, allowUpper, allowNumeric, allowSpecial bool) string {
allowedChars := []rune{}
if allowLower {
allowedChars = append(allowedChars, lowerLetters...)
}
if allowUpper {
allowedChars = append(allowedChars, upperLetters...)
}
if allowNumeric {
allowedChars = append(allowedChars, numeric...)
}
if allowSpecial {
allowedChars = append(allowedChars, specialChars...)
}
result := []rune{}
nTimes := r.Intn(atMost-atLeast+1) + atLeast
for i := 0; i < nTimes; i++ {
result = append(result, allowedChars[r.Intn(len(allowedChars))])
}
return string(result)
}
// Password generates password with the length from atLeast to atMOst charachers,
// allow* parameters specify whether corresponding symbols can be used
func Password(atLeast, atMost int, allowUpper, allowNumeric, allowSpecial bool) string {
return text(atLeast, atMost, true, allowUpper, allowNumeric, allowSpecial)
}
// SimplePassword is a wrapper around Password,
// it generates password with the length from 6 to 12 symbols, with upper characters and numeric symbols allowed
func SimplePassword() string {
return Password(6, 12, true, true, false)
}
// Color generates color name
func Color() string {
return lookup(lang, "colors", true)
}
// DigitsN returns n digits as a string
func DigitsN(n int) string {
digits := make([]rune, n)
for i := 0; i < n; i++ {
digits[i] = numeric[r.Intn(len(numeric))]
}
return string(digits)
}
// Digits returns from 1 to 5 digits as a string
func Digits() string {
return DigitsN(r.Intn(5) + 1)
}
func hexDigitsStr(n int) string {
var num []rune
for i := 0; i < n; i++ {
num = append(num, hexDigits[r.Intn(len(hexDigits))])
}
return string(num)
}
// HexColor generates hex color name
func HexColor() string {
return hexDigitsStr(6)
}
// HexColorShort generates short hex color name
func HexColorShort() string {
return hexDigitsStr(3)
}

57
server/vendor/github.com/icrowley/fake/geo.go generated vendored Normal file
View file

@ -0,0 +1,57 @@
package fake
// Latitude generates latitude (from -90.0 to 90.0)
func Latitude() float32 {
return r.Float32()*180 - 90
}
// LatitudeDegrees generates latitude degrees (from -90 to 90)
func LatitudeDegrees() int {
return r.Intn(180) - 90
}
// LatitudeMinutes generates latitude minutes (from 0 to 60)
func LatitudeMinutes() int {
return r.Intn(60)
}
// LatitudeSeconds generates latitude seconds (from 0 to 60)
func LatitudeSeconds() int {
return r.Intn(60)
}
// LatitudeDirection generates latitude direction (N(orth) o S(outh))
func LatitudeDirection() string {
if r.Intn(2) == 0 {
return "N"
}
return "S"
}
// Longitude generates longitude (from -180 to 180)
func Longitude() float32 {
return r.Float32()*360 - 180
}
// LongitudeDegrees generates longitude degrees (from -180 to 180)
func LongitudeDegrees() int {
return r.Intn(360) - 180
}
// LongitudeMinutes generates (from 0 to 60)
func LongitudeMinutes() int {
return r.Intn(60)
}
// LongitudeSeconds generates (from 0 to 60)
func LongitudeSeconds() int {
return r.Intn(60)
}
// LongitudeDirection generates (W(est) or E(ast))
func LongitudeDirection() string {
if r.Intn(2) == 0 {
return "W"
}
return "E"
}

6
server/vendor/github.com/icrowley/fake/glide.lock generated vendored Normal file
View file

@ -0,0 +1,6 @@
hash: 9238b15272824ad573d8ef645fb468cb646b72598c63eae8977c3410ebfebe4a
updated: 2017-07-23T15:10:00.972860398Z
imports:
- name: github.com/corpix/uarand
version: 031be390f409fb4bac8fb299e3bcd101479f89f8
testImports: []

3
server/vendor/github.com/icrowley/fake/glide.yaml generated vendored Normal file
View file

@ -0,0 +1,3 @@
package: github.com/icrowley/fake
import:
- package: github.com/corpix/uarand

77
server/vendor/github.com/icrowley/fake/internet.go generated vendored Normal file
View file

@ -0,0 +1,77 @@
package fake
import (
"net"
"strings"
"github.com/corpix/uarand"
)
// UserName generates user name in one of the following forms
// first name + last name, letter + last names or concatenation of from 1 to 3 lowercased words
func UserName() string {
gender := randGender()
switch r.Intn(3) {
case 0:
return lookup("en", gender+"_first_names", false) + lookup(lang, gender+"_last_names", false)
case 1:
return Character() + lookup(lang, gender+"_last_names", false)
default:
return strings.Replace(WordsN(r.Intn(3)+1), " ", "_", -1)
}
}
// TopLevelDomain generates random top level domain
func TopLevelDomain() string {
return lookup(lang, "top_level_domains", true)
}
// DomainName generates random domain name
func DomainName() string {
return Company() + "." + TopLevelDomain()
}
// EmailAddress generates email address
func EmailAddress() string {
return UserName() + "@" + DomainName()
}
// EmailSubject generates random email subject
func EmailSubject() string {
return Sentence()
}
// EmailBody generates random email body
func EmailBody() string {
return Paragraphs()
}
// DomainZone generates random domain zone
func DomainZone() string {
return lookup(lang, "domain_zones", true)
}
// IPv4 generates IPv4 address
func IPv4() string {
size := 4
ip := make([]byte, size)
for i := 0; i < size; i++ {
ip[i] = byte(r.Intn(256))
}
return net.IP(ip).To4().String()
}
// IPv6 generates IPv6 address
func IPv6() string {
size := 16
ip := make([]byte, size)
for i := 0; i < size; i++ {
ip[i] = byte(r.Intn(256))
}
return net.IP(ip).To16().String()
}
// UserAgent generates a random user agent.
func UserAgent() string {
return uarand.GetRandom()
}

25
server/vendor/github.com/icrowley/fake/jobs.go generated vendored Normal file
View file

@ -0,0 +1,25 @@
package fake
import (
"strings"
)
// Company generates company name
func Company() string {
return lookup(lang, "companies", true)
}
// JobTitle generates job title
func JobTitle() string {
job := lookup(lang, "jobs", true)
return strings.Replace(job, "#{N}", jobTitleSuffix(), 1)
}
func jobTitleSuffix() string {
return lookup(lang, "jobs_suffixes", false)
}
// Industry generates industry name
func Industry() string {
return lookup(lang, "industries", true)
}

103
server/vendor/github.com/icrowley/fake/lorem_ipsum.go generated vendored Normal file
View file

@ -0,0 +1,103 @@
package fake
import (
"strings"
)
// Character generates random character in the given language
func Character() string {
return lookup(lang, "characters", true)
}
// CharactersN generates n random characters in the given language
func CharactersN(n int) string {
var chars []string
for i := 0; i < n; i++ {
chars = append(chars, Character())
}
return strings.Join(chars, "")
}
// Characters generates from 1 to 5 characters in the given language
func Characters() string {
return CharactersN(r.Intn(5) + 1)
}
// Word generates random word
func Word() string {
return lookup(lang, "words", true)
}
// WordsN generates n random words
func WordsN(n int) string {
words := make([]string, n)
for i := 0; i < n; i++ {
words[i] = Word()
}
return strings.Join(words, " ")
}
// Words generates from 1 to 5 random words
func Words() string {
return WordsN(r.Intn(5) + 1)
}
// Title generates from 2 to 5 titleized words
func Title() string {
return strings.ToTitle(WordsN(2 + r.Intn(4)))
}
// Sentence generates random sentence
func Sentence() string {
var words []string
for i := 0; i < 3+r.Intn(12); i++ {
word := Word()
if r.Intn(5) == 0 {
word += ","
}
words = append(words, Word())
}
sentence := strings.Join(words, " ")
if r.Intn(8) == 0 {
sentence += "!"
} else {
sentence += "."
}
return sentence
}
// SentencesN generates n random sentences
func SentencesN(n int) string {
sentences := make([]string, n)
for i := 0; i < n; i++ {
sentences[i] = Sentence()
}
return strings.Join(sentences, " ")
}
// Sentences generates from 1 to 5 random sentences
func Sentences() string {
return SentencesN(r.Intn(5) + 1)
}
// Paragraph generates paragraph
func Paragraph() string {
return SentencesN(r.Intn(10) + 1)
}
// ParagraphsN generates n paragraphs
func ParagraphsN(n int) string {
var paragraphs []string
for i := 0; i < n; i++ {
paragraphs = append(paragraphs, Paragraph())
}
return strings.Join(paragraphs, "\t")
}
// Paragraphs generates from 1 to 5 paragraphs
func Paragraphs() string {
return ParagraphsN(r.Intn(5) + 1)
}

147
server/vendor/github.com/icrowley/fake/names.go generated vendored Normal file
View file

@ -0,0 +1,147 @@
package fake
func randGender() string {
g := "male"
if r.Intn(2) == 0 {
g = "female"
}
return g
}
func firstName(gender string) string {
return lookup(lang, gender+"_first_names", true)
}
// MaleFirstName generates male first name
func MaleFirstName() string {
return firstName("male")
}
// FemaleFirstName generates female first name
func FemaleFirstName() string {
return firstName("female")
}
// FirstName generates first name
func FirstName() string {
return firstName(randGender())
}
func lastName(gender string) string {
return lookup(lang, gender+"_last_names", true)
}
// MaleLastName generates male last name
func MaleLastName() string {
return lastName("male")
}
// FemaleLastName generates female last name
func FemaleLastName() string {
return lastName("female")
}
// LastName generates last name
func LastName() string {
return lastName(randGender())
}
func patronymic(gender string) string {
return lookup(lang, gender+"_patronymics", false)
}
// MalePatronymic generates male patronymic
func MalePatronymic() string {
return patronymic("male")
}
// FemalePatronymic generates female patronymic
func FemalePatronymic() string {
return patronymic("female")
}
// Patronymic generates patronymic
func Patronymic() string {
return patronymic(randGender())
}
func prefix(gender string) string {
return lookup(lang, gender+"_name_prefixes", false)
}
func suffix(gender string) string {
return lookup(lang, gender+"_name_suffixes", false)
}
func fullNameWithPrefix(gender string) string {
return join(prefix(gender), firstName(gender), lastName(gender))
}
// MaleFullNameWithPrefix generates prefixed male full name
// if prefixes for the given language are available
func MaleFullNameWithPrefix() string {
return fullNameWithPrefix("male")
}
// FemaleFullNameWithPrefix generates prefixed female full name
// if prefixes for the given language are available
func FemaleFullNameWithPrefix() string {
return fullNameWithPrefix("female")
}
// FullNameWithPrefix generates prefixed full name
// if prefixes for the given language are available
func FullNameWithPrefix() string {
return fullNameWithPrefix(randGender())
}
func fullNameWithSuffix(gender string) string {
return join(firstName(gender), lastName(gender), suffix(gender))
}
// MaleFullNameWithSuffix generates suffixed male full name
// if suffixes for the given language are available
func MaleFullNameWithSuffix() string {
return fullNameWithPrefix("male")
}
// FemaleFullNameWithSuffix generates suffixed female full name
// if suffixes for the given language are available
func FemaleFullNameWithSuffix() string {
return fullNameWithPrefix("female")
}
// FullNameWithSuffix generates suffixed full name
// if suffixes for the given language are available
func FullNameWithSuffix() string {
return fullNameWithPrefix(randGender())
}
func fullName(gender string) string {
switch r.Intn(10) {
case 0:
return fullNameWithPrefix(gender)
case 1:
return fullNameWithSuffix(gender)
default:
return join(firstName(gender), lastName(gender))
}
}
// MaleFullName generates male full name
// it can occasionally include prefix or suffix
func MaleFullName() string {
return fullName("male")
}
// FemaleFullName generates female full name
// it can occasionally include prefix or suffix
func FemaleFullName() string {
return fullName("female")
}
// FullName generates full name
// it can occasionally include prefix or suffix
func FullName() string {
return fullName(randGender())
}

24
server/vendor/github.com/icrowley/fake/personal.go generated vendored Normal file
View file

@ -0,0 +1,24 @@
package fake
import (
"strings"
)
// Gender generates random gender
func Gender() string {
return lookup(lang, "genders", true)
}
// GenderAbbrev returns first downcased letter of the random gender
func GenderAbbrev() string {
g := Gender()
if g != "" {
return strings.ToLower(string(g[0]))
}
return ""
}
// Language generates random human language
func Language() string {
return lookup(lang, "languages", true)
}

26
server/vendor/github.com/icrowley/fake/products.go generated vendored Normal file
View file

@ -0,0 +1,26 @@
package fake
// Brand generates brand name
func Brand() string {
return Company()
}
// ProductName generates product name
func ProductName() string {
productName := lookup(lang, "adjectives", true) + " " + lookup(lang, "nouns", true)
if r.Intn(2) == 1 {
productName = lookup(lang, "adjectives", true) + " " + productName
}
return productName
}
// Product generates product title as brand + product name
func Product() string {
return Brand() + " " + ProductName()
}
// Model generates model name that consists of letters and digits, optionally with a hyphen between them
func Model() string {
seps := []string{"", " ", "-"}
return CharactersN(r.Intn(3)+1) + seps[r.Intn(len(seps))] + Digits()
}