data

package
v0.0.0-...-8132f3d Latest Latest
Warning

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

Go to latest
Published: Aug 11, 2024 License: BSD-3-Clause Imports: 14 Imported by: 0

Documentation

Index

Constants

View Source
const ADDRESSES_FILE_NAME = "addresses.json"

path to addresses.json

View Source
const COMPANIES_FILE_NAME = "companies.json"

path to companies.json

View Source
const DATES_FILE_NAME = "dates.json"

path to dates.json

View Source
const EMAIL_DEFAULT_DOMAIN_SUFFIX = "com"
View Source
const PERSONS_FILE_NAME = "persons.json"

path to persons.json file

View Source
const WEBSITES_FILE_NAME = "websites.json"

path to websites.json

Variables

This section is empty.

Functions

func CheckAddressesSorted

func CheckAddressesSorted(unsortedAddresses []Address, autoFix bool) bool

check if addresses are sorted alphabetically

func CheckCompaniesSorted

func CheckCompaniesSorted(unsortedCompanies []Company, autoFix bool) bool

check if companies are sorted alphabetically

func CheckDatesSorted

func CheckDatesSorted(unsortedDates []Date, autoFix bool) bool

check if dates are sorted alphabetically

func CheckPersonsSorted

func CheckPersonsSorted(unsortedPersons []Person, autoFix bool) bool

check if persons are sorted alphabetically

func CheckWebsitesSorted

func CheckWebsitesSorted(unsortedWebsites []Website, autoFix bool) bool

check if websites are sorted alphabetically

func GenerateEmail

func GenerateEmail(firstName string, lastName string, domainName string, domainSuffix string) string

generate email given first and last names, and domain name and suffix

func IsAddressLess

func IsAddressLess(address1 Address, address2 Address) bool

check if address1 is alphabetically lower than address2

func IsCompanyLess

func IsCompanyLess(company1 Company, company2 Company) bool

check if company1 is alphabetically lower than company2

func IsDateLess

func IsDateLess(date1 Date, date2 Date) bool

check if date1 is alphabetically lower than date2

func IsPersonLess

func IsPersonLess(person1 Person, person2 Person) bool

check if person1 is alphabetically lower than person2

func IsWebsiteLess

func IsWebsiteLess(website1 Website, website2 Website) bool

check if website1 is alphabetically lower than website2

func Validate

func Validate(autofix bool) error

validate all data files

func ValidateAddressesData

func ValidateAddressesData(autofix bool) error

validate data in addresses.json

func ValidateCompaniesData

func ValidateCompaniesData(autofix bool) error

validate data in companies.json

func ValidateDatesData

func ValidateDatesData(autofix bool) error

validate data in dates.json

func ValidatePersonsData

func ValidatePersonsData(autofix bool) error

validate data in persons.json

func ValidateWebsitesData

func ValidateWebsitesData(autofix bool) error

validate data in websites.json

func WriteAddresses

func WriteAddresses(addresses []Address) error

write list of addresses to addresses.json

func WriteCompanies

func WriteCompanies(companies []Company) error

write list of companies to companies.json

func WriteDates

func WriteDates(dates []Date) error

write list of dates to dates.json

func WritePersons

func WritePersons(persons []Person) error

write list of persons to persons.json

func WriteWebsites

func WriteWebsites(websites []Website) error

write list of websites to websites.json

Types

type Address

type Address struct {
	StreetName string       `json:"street-name"`
	City       string       `json:"city"`
	State      string       `json:"state"`
	Country    string       `json:"country"`
	PostalCode string       `json:"postal-code"`
	Group      AddressGroup `json:"group"`
	Valid      bool         `json:"valid"`
	Trivia     string       `json:"trivia"`
}

struct representing address from addresses.json

func FilterAddresses

func FilterAddresses(
	addresses []Address,
	streetName string,
	city string,
	state string,
	country string,
	postalCode string,
	group AddressGroup,
	trivia string,
) []Address

filter addresses by properties

func FilterValidAddresses

func FilterValidAddresses(addresses []Address) []Address

filter addresses by validity

func GetAddresses

func GetAddresses() ([]Address, error)

read addresses from addresses.json

type AddressGroup

type AddressGroup string

enum representing address group

const (
	AddressGroupCartoons AddressGroup = "Cartoons"
	AddressGroupComics   AddressGroup = "Comics"
	AddressGroupTVShows  AddressGroup = "TV-Shows"
)

func (*AddressGroup) IsValid

func (group *AddressGroup) IsValid() bool

check address group enum is valid

type Company

type Company struct {
	Name   string       `json:"name"`
	Group  CompanyGroup `json:"group"`
	Trivia string       `json:"trivia"`
}

struct representing company from companies.json

func FilterCompanies

func FilterCompanies(
	companies []Company,
	name string,
	group CompanyGroup,
	trivia string,
) []Company

filter companies by properties

func GetCompanies

func GetCompanies() ([]Company, error)

read companies from companies.json

type CompanyGroup

type CompanyGroup string

enum representing companies group

const (
	CompanyGroupCartoons CompanyGroup = "Cartoons"
	CompanyGroupComics   CompanyGroup = "Comics"
	CompanyGroupMovies   CompanyGroup = "Movies"
	CompanyGroupTVShows  CompanyGroup = "TV-Shows"
)

func (*CompanyGroup) IsValid

func (group *CompanyGroup) IsValid() bool

check company group enum is valid

type Date

type Date struct {
	Day    int       `json:"day"`
	Month  int       `json:"month"`
	Year   int       `json:"year"`
	Group  DateGroup `json:"group"`
	Trivia string    `json:"trivia"`
}

struct representing website from websites.json

func FilterDates

func FilterDates(
	dates []Date,
	startDate time.Time,
	endDate time.Time,
	group DateGroup,
	trivia string,
) []Date

filter dates by properties

func GetDates

func GetDates() ([]Date, error)

read dates from dates.json

func (*Date) ToTimeObj

func (date *Date) ToTimeObj() time.Time

convert date to time object

type DateGroup

type DateGroup string

enum representing date group

const (
	DateGroupGames   DateGroup = "Games"
	DateGroupMovies  DateGroup = "Movies"
	DateGroupTVShows DateGroup = "TV-Shows"
)

func (*DateGroup) IsValid

func (group *DateGroup) IsValid() bool

check date group enum is valid

type Person

type Person struct {
	FirstName string      `json:"first-name"`
	LastName  string      `json:"last-name"`
	Sex       Sex         `json:"sex"`
	Group     PersonGroup `json:"group"`
	Domain    string      `json:"domain"`
	Trivia    string      `json:"trivia"`
}

struct representing person from persons.json

func FilterPersons

func FilterPersons(
	persons []Person,
	firstName string,
	lastName string,
	sex Sex,
	group PersonGroup,
	domain string,
	trivia string,
) []Person

filter persons by properties

func GetPersons

func GetPersons() ([]Person, error)

read persons from persons.json

type PersonGroup

type PersonGroup string

enum representing person group

const (
	PersonGroupComics  PersonGroup = "Comics"
	PersonGroupMovies  PersonGroup = "Movies"
	PersonGroupTVShows PersonGroup = "TV-Shows"
)

func (*PersonGroup) IsValid

func (group *PersonGroup) IsValid() bool

check person group enum is valid

type Sex

type Sex string

enum representing person sex

const (
	SexMale   Sex = "Male"
	SexFemale Sex = "Female"
	SexOther  Sex = "Other"
)

func (*Sex) IsValid

func (sex *Sex) IsValid() bool

check if sex enum is valid

type Website

type Website struct {
	URL    string       `json:"url"`
	Group  CompanyGroup `json:"group"`
	Trivia string       `json:"trivia"`
}

struct representing website from websites.json

func FilterWebsites

func FilterWebsites(
	websites []Website,
	url string,
	group WebsiteGroup,
	trivia string,
) []Website

filter websites by properties

func GetWebsites

func GetWebsites() ([]Website, error)

read websites from websites.json

type WebsiteGroup

type WebsiteGroup string

enum representing website group

const (
	WebsiteGroupTVShows WebsiteGroup = "TV-Shows"
)

func (*WebsiteGroup) IsValid

func (group *WebsiteGroup) IsValid() bool

check website group enum is valid

Jump to

Keyboard shortcuts

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