GoProfileFromSeed

package module
v0.0.0-...-47f13ba Latest Latest
Warning

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

Go to latest
Published: Apr 7, 2024 License: MIT Imports: 8 Imported by: 0

README

GoProfileFromSeed 🕵️🏾‍♂️

A Go library to generate user profiles based on a seed.

A Profile is a structure with the following fields

  • First Name
  • Last Name
  • Username
  • Email
  • Region
  • Address
  • Seed

You can also generate a unique profile image for each profile.

A seed is a 5 character string. Each character can a number or a lower case or upper case English letter.

How it works 🛠️

The following image shows how each field is determined :

enter image description here

Region: numbers, upper case letters and lower case letters are divided into groups and if the integer representation of the byte (n) of a character is within that group that region is assigned. Same for gender.

First names starting letter will be either, the first non-numerical character after the second character of the seed or if no non-numerical character is present after the second character of the seed, then the letter corresponding to the integer representation of the byte of the 3rd number + 17.

Last names starting letter will be either, the second non-numerical character after the second character of the seed or if only one non-numerical character is present after the second character of the seed, then the letter corresponding to the integer representation of the byte of the 4th number + 17.

Offset : The program will take the integer representation of the byte (n) of a character and will assign the item at the n th line in the data file belonging to the respective field. In the case of two letters, it will multiply those two numbers and get the n.

Username and email is generated using templates determined in the common_templates directory in the data.

Profile Image

Each profile image is a 250 * 250 pixel image. This square is divided into 25, 50*50 squares and according to the image below, five or fewer squares are painted based on each character of the seed starting from the middle square.

enter image description here Examples: enter image description here

Data files

Currently, the data files include common names and addresses of these regions:

  • Sri Lanka 🇱🇰
  • USA 🇺🇸
  • UK 🇬🇧
  • Australia 🇦🇺

Information on how those data is gathered can be found in info.txt files inside each folder.

Documentation

https://pkg.go.dev/github.com/Tharusha-dev/GoProfileFromSeed

Documentation

Overview

GoProfileFromSeed generates user profiles based on a seed. A Profile is a structure with:

  • First Name
  • Last Name -Username -Email -Region -Address -seed

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func GenerateProfileImage

func GenerateProfileImage(profile Profile, fileName string, filePath string, primaryColor string, secondaryColor string) string

Each profile image is a 250 * 250 pixel SVG. For more info https://github.com/Tharusha-dev/GoProfileFromSeed?tab=readme-ov-file#profile-image

Types

type Profile

type Profile struct {
	FirstName string
	LastName  string
	Username  string
	Email     string
	Region    string
	Address   string
	Seed      string
}

func GetProfileFromSeed

func GetProfileFromSeed(seed string) Profile

A seed is a 5 character string. Each character can a number or a lower case or upper case English letter. This function returns a Profile struct. For more info https://github.com/Tharusha-dev/GoProfileFromSeed?tab=readme-ov-file#how-it-works-%EF%B8%8F

Jump to

Keyboard shortcuts

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