Documentation ¶
Overview ¶
We use byte instead of rune because this alphabet contains only printable ASCII characters.
Index ¶
- Constants
- func BuildStruct[T any]() *T
- func Check_err(err error)
- func Convert_str_to_uint64(input_str string) uint64
- func Convert_uint64_to_str(bigendian_uint64 uint64, length int) string
- func Copy_Slice_Into_150_Arr(slice []byte, arr [150]byte)
- func Crypto_RandString(length int) string
- func Crypto_Randint(max int) (int, error)
- func Crypto_Random_Choice[T any](arr *[]T) (T, error)
- func Divmod(numerator, denominator int) (int, int)
- func Get_file_size(f *os.File) int64
- func Int64_to_string(num int64) string
- func IsSameType(a, b interface{}) bool
- func Power_Naive(a, b int) int
- func Power_Slow(a, b, m int) int
- func PrintMemUsage()
- func ReplaceString(str string, replacement rune, index int) string
- func Retryfunc(taskname string, dotask retrylib_task, expected_duration time.Duration, ...)
- func Retryproc(procname string, expected_duration time.Duration, max_wait time.Duration)
- func ReverseString(s string) string
- func RunFuncEveryXSeconds(fn fn_type, run_interval_seconds int)
- func SetLogFile(filename string) *os.File
- func String_to_int64(s string) (int64, error)
- func Use(vals ...interface{})
- func Validate_Timestamp_Common(timestamp_unix int64) error
- type Base53ErrorChecksumMismatch
- type Base53ErrorIllegalCharacter
- type Base53ErrorIllegalPair
- type Base53ErrorStrWithoutCsumTooLong
- type Base53ErrorStrWithoutCsumTooShort
- type Base53ID
- type Base53IDManager
- func (b53m *Base53IDManager) B53_generate_all_Base53IDs(n int) ([]Base53ID, error)
- func (b53m *Base53IDManager) B53_generate_all_Base53IDs_int64(n int) ([]uint64, error)
- func (b53m *Base53IDManager) B53_generate_all_Base53IDs_int64_optimized(n int, should_be_added_fn ShouldBase53IDBePlacedIntoSliceFn) ([]uint64, error)
- func (b53m *Base53IDManager) B53_generate_all_Base53IDs_int64_test(n int) ([]uint64, error)
- func (b53m *Base53IDManager) B53_generate_next_Base53ID(old_id Base53ID) (Base53ID, error)
- func (b53m *Base53IDManager) B53_generate_random_Base53ID(n int) (Base53ID, error)
- func (b53m *Base53IDManager) Convert_uint64_to_Base53ID(bigendian_uint64 uint64, length int) (*_base53ID_impl, error)
- func (b53m *Base53IDManager) Convert_uint64_to_byte_array(bigendian_uint64 uint64) []byte
- func (b53m *Base53IDManager) NewBase53ID(str_without_csum string, csum byte, remap bool) (*_base53ID_impl, error)
- type CryptoRandomChoiceEmptySliceError
- type NewBase53IDParams
- type ShouldBase53IDBePlacedIntoSliceFn
- type ValidationResult
Constants ¶
const BASE53_ALPHABET_SIZE = 53
Variables ¶
This section is empty.
Functions ¶
func BuildStruct ¶
func BuildStruct[T any]() *T
func Convert_str_to_uint64 ¶
func Convert_uint64_to_str ¶
func Copy_Slice_Into_150_Arr ¶
func Crypto_RandString ¶
Returns random string consisting of letters and numbers
func Crypto_Randint ¶
This function works, I've manually tested it. Returns integers from 0 up to AND NOT INCLUDING max
func Crypto_Random_Choice ¶
This function works, I've manually tested it.
func Get_file_size ¶
this function assumes file pointer is valid. We could probably make this more efficient by calculating the file size in-process instead of making syscall each time.
func Int64_to_string ¶
func IsSameType ¶
func IsSameType(a, b interface{}) bool
This function works, I've manually tested it.
func Power_Slow ¶
calculates a to the power of b mod m. If m is 0 then just returns a to the power of b. This function seems to create a memory leak, but it doesn't. Anyway, it's better to use custom power
func PrintMemUsage ¶
func PrintMemUsage()
PrintMemUsage outputs the current, total and OS memory being used. As well as the number of garage collection cycles completed.
func ReverseString ¶
func RunFuncEveryXSeconds ¶
func RunFuncEveryXSeconds(fn fn_type, run_interval_seconds int)
Does not tick shift - will run function precisely every X seconds even if function takes some time to run - as long as the function doesn't take too long of course.
Synchronous - next call cannot start until previous call has finished.
func String_to_int64 ¶
func Use ¶
func Use(vals ...interface{})
https://stackoverflow.com/questions/21743841/how-to-avoid-annoying-error-declared-and-not-used
func Validate_Timestamp_Common ¶
Returns error if unix timestamp is before 2023 or after the year 20,000
Otherwise returns nil
Types ¶
type Base53ErrorChecksumMismatch ¶
type Base53ErrorChecksumMismatch struct{}
func (Base53ErrorChecksumMismatch) Error ¶
func (e Base53ErrorChecksumMismatch) Error() string
type Base53ErrorIllegalCharacter ¶
type Base53ErrorIllegalCharacter struct{}
func (Base53ErrorIllegalCharacter) Error ¶
func (e Base53ErrorIllegalCharacter) Error() string
type Base53ErrorIllegalPair ¶
type Base53ErrorIllegalPair struct{}
func (Base53ErrorIllegalPair) Error ¶
func (e Base53ErrorIllegalPair) Error() string
type Base53ErrorStrWithoutCsumTooLong ¶
type Base53ErrorStrWithoutCsumTooLong struct{}
func (Base53ErrorStrWithoutCsumTooLong) Error ¶
func (e Base53ErrorStrWithoutCsumTooLong) Error() string
type Base53ErrorStrWithoutCsumTooShort ¶
type Base53ErrorStrWithoutCsumTooShort struct{}
Custom error types
func (Base53ErrorStrWithoutCsumTooShort) Error ¶
func (e Base53ErrorStrWithoutCsumTooShort) Error() string
type Base53ID ¶
type Base53ID interface { GetStrWithoutCsum() string GetCsum() byte GetCombinedString() string Length() int }
See https://stackoverflow.com/questions/57993809/how-to-hide-the-default-type-constructor-in-golang
type Base53IDManager ¶
type Base53IDManager struct {
// contains filtered or unexported fields
}
func NewBase53IDManager ¶
func NewBase53IDManager() *Base53IDManager
pregenerate means strings up to n characters will be pre-generated and stored in RandomBags for fast PopRandom and Push later.
func (*Base53IDManager) B53_generate_all_Base53IDs ¶
func (b53m *Base53IDManager) B53_generate_all_Base53IDs(n int) ([]Base53ID, error)
Generate all IDs of length n
func (*Base53IDManager) B53_generate_all_Base53IDs_int64 ¶
func (b53m *Base53IDManager) B53_generate_all_Base53IDs_int64(n int) ([]uint64, error)
func (*Base53IDManager) B53_generate_all_Base53IDs_int64_optimized ¶
func (b53m *Base53IDManager) B53_generate_all_Base53IDs_int64_optimized(n int, should_be_added_fn ShouldBase53IDBePlacedIntoSliceFn) ([]uint64, error)
Doesn't push it into slice if it's already in map.
func (*Base53IDManager) B53_generate_all_Base53IDs_int64_test ¶
func (b53m *Base53IDManager) B53_generate_all_Base53IDs_int64_test(n int) ([]uint64, error)
func (*Base53IDManager) B53_generate_next_Base53ID ¶
func (b53m *Base53IDManager) B53_generate_next_Base53ID(old_id Base53ID) (Base53ID, error)
func (*Base53IDManager) B53_generate_random_Base53ID ¶
func (b53m *Base53IDManager) B53_generate_random_Base53ID(n int) (Base53ID, error)
func (*Base53IDManager) Convert_uint64_to_Base53ID ¶
func (b53m *Base53IDManager) Convert_uint64_to_Base53ID(bigendian_uint64 uint64, length int) (*_base53ID_impl, error)
func (*Base53IDManager) Convert_uint64_to_byte_array ¶
func (b53m *Base53IDManager) Convert_uint64_to_byte_array(bigendian_uint64 uint64) []byte
func (*Base53IDManager) NewBase53ID ¶
func (b53m *Base53IDManager) NewBase53ID(str_without_csum string, csum byte, remap bool) (*_base53ID_impl, error)
Construction is validation.
type CryptoRandomChoiceEmptySliceError ¶
type CryptoRandomChoiceEmptySliceError struct{}
Custom error types
func (CryptoRandomChoiceEmptySliceError) Error ¶
func (e CryptoRandomChoiceEmptySliceError) Error() string
type NewBase53IDParams ¶
inspired by StripeIntentParams