conversion

package
v3.0.1 Latest Latest
Warning

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

Go to latest
Published: Nov 3, 2022 License: MIT Imports: 4 Imported by: 0

Documentation

Overview

Package conversion is a package of implementations which converts one data structure to another.

Index

Constants

View Source
const Alphabet = "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/"

Variables

This section is empty.

Functions

func Base64Decode

func Base64Decode(input string) []byte

Base64Decode decodes the received input base64 string into a byte slice. The implementation follows the RFC4648 standard, which is documented at https://datatracker.ietf.org/doc/html/rfc4648#section-4

func Base64Encode

func Base64Encode(input []byte) string

Base64Encode encodes the received input bytes slice into a base64 string. The implementation follows the RFC4648 standard, which is documented at https://datatracker.ietf.org/doc/html/rfc4648#section-4

func BinaryToDecimal

func BinaryToDecimal(binary string) (int, error)

BinaryToDecimal() function that will take Binary number as string, and return it's Decimal equivalent as integer.

func DecimalToBinary

func DecimalToBinary(num int) (string, error)

DecimalToBinary() function that will take Decimal number as int, and return it's Binary equivalent as string.

func HEXToRGB

func HEXToRGB(hex uint) (red, green, blue byte)

HEXToRGB splits an RGB input (e.g. a color in hex format; 0x<color-code>) into the individual components: red, green and blue

func IntToRoman

func IntToRoman(n int) (string, error)

IntToRoman converts an integer value to a roman numeral string. An error is returned if the integer is not between 1 and 3999.

func RGBToHEX

func RGBToHEX(red, green, blue byte) (hex uint)

RGBToHEX does exactly the opposite of HEXToRGB: it combines the three components red, green and blue to an RGB value, which can be converted to e.g. Hex

func Reverse

func Reverse(str string) string

Reverse() function that will take string, and returns the reverse of that string.

func RomanToInteger

func RomanToInteger(input string) (int, error)

RomanToInteger converts a roman numeral string to an integer. Roman numerals for numbers outside the range 1 to 3,999 will return an error. Nil or empty string return 0 with no error thrown.

Types

This section is empty.

Jump to

Keyboard shortcuts

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