gorandom

package module
v0.0.0-...-1d232ec Latest Latest
Warning

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

Go to latest
Published: Oct 5, 2022 License: MIT Imports: 6 Imported by: 1

README

go-random | Random String Generator

The gorandom package provides random string, hex string, vowel check and count of vowel functions.

Installation

go get -u "github.com/zekiahmetbayar/go-random"

Usage


package main

import (
	"fmt"
	"log"

	gorandom "github.com/zekiahmetbayar/go-random"
)

func main() {
	// Returns string containing numbers, letters and special characters of given length
	r_str, err := gorandom.String(true, true, true, 16)
	if err != nil {
		log.Fatalf("error when creating random string: %s", err.Error())
	}
	fmt.Printf("Random String: %s\n", r_str)

	// Returns hex string of given length
	h_str, err := gorandom.HexString(16)
	if err != nil {
		log.Fatalf("error when creating hex string: %s", err.Error())
	}
	fmt.Printf("Hex String: %s\n", h_str)

	// Returns count of vowels in string
	count := gorandom.CountOfVowel("test")
	fmt.Printf("Count: %d\n", count)

	// Returns count of Turkish vowels in string
	t_count := gorandom.CountOfTurkishVowel("ali")
	fmt.Printf("Count: %d\n", t_count)

	// Returns if given character is vowel
	for _, element := range "isvowel" {
		is_vowel := gorandom.IsVowel(element)
		fmt.Printf("Is vowel: %v\n", is_vowel)
	}

	// Returns if given character is Turkish vowel
	for _, element := range "türkçe ünlü karakter mi" {
		is_Tvowel := gorandom.IsTurkishVowel(element)
		fmt.Printf("Is Turkish vowel: %v\n", is_Tvowel)
	}
}

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func CountOfTurkishVowel

func CountOfTurkishVowel(string_ string) int

Count of Turkish vowel in a string

func CountOfVowel

func CountOfVowel(string_ string) int

Count of vowel in a string

func HexString

func HexString(str_length int) (string, error)

HexString returns hex string of given length.

func IsTurkishVowel

func IsTurkishVowel(char rune) bool

Is letter Turkish vowel check

func IsVowel

func IsVowel(char rune) bool

Is letter vowel check

func String

func String(numbers, letters, specials bool, str_length int) (string, error)

String returns random string of given length.

Parameters:

numbers: Include numbers to random string
letters: Include english letters to random string
specials: Include special characters to random string
length: Random string length

Types

This section is empty.

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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