module
Version:
v0.1.2
Opens a new window with list of versions in this module.
Published: Jan 20, 2026
License: MIT
Opens a new window with license information.
README
¶
Base Module
A simple example of how to create a reusable Go module with commonly used tools.
Installation
go get -u github.com/Base-module/golang-base-module
JSON Processing
- Read JSON
- Write JSON
- Produce a JSON encoded error response
- Post JSON to a remote service
File Operations
- Upload a file to a specified directory
- Upload multiple files
- Download a static file
- Create a directory, including all parent directories, if it does not already exist
String Utilities
- Create a URL safe slug from a string
Random Data Generation
Strings
-
RandomString(n) - Generate random string of length n
-
RandomStringFromCharset(n, charset) - Generate random string from custom charset
-
RandomAlphaString(n) - Generate alphabetic string (letters only)
-
RandomAlphaNumericString(n) - Generate alphanumeric string
-
RandomNumericString(n) - Generate numeric string
-
RandomLowerString(n) - Generate lowercase string
-
RandomUpperString(n) - Generate uppercase string
-
RandomHexString(n) - Generate hexadecimal string
Numbers
-
RandomInt(min, max) - Generate random integer in range
-
RandomInt64(min, max) - Generate random int64 in range
-
RandomFloat64(min, max) - Generate random float64 in range
-
RandomBool() - Generate random boolean
Identifiers
-
RandomUUID() - Generate UUID v4
-
RandomUsername() - Generate random username
-
RandomPassword(length) - Generate strong password (mixed chars)
-
RandomEmail() - Generate random email address
-
RandomEmailWithDomain(domain) - Generate email with specified domain
-
RandomPhone() - Generate random phone number (XXX-XXX-XXXX)
-
RandomPhoneWithPrefix(prefix) - Generate phone with country code
Network
-
RandomIPv4() - Generate random IPv4 address
-
RandomIPv6() - Generate random IPv6 address
-
RandomMAC() - Generate random MAC address
-
RandomURL() - Generate random URL
Date & Time
-
RandomDate(start, end) - Generate random date in range
-
RandomDateString(start, end, format) - Generate formatted random date
Slice Operations
-
RandomSliceElement[T](slice) - Pick random element from slice
-
RandomSliceElements[T](slice, n) - Pick n random elements (with duplicates)
-
RandomUniqueSliceElements[T](slice, n) - Pick n unique random elements
-
ShuffleSlice[T](slice) - Shuffle a slice
Bytes
-
RandomBytes(n) - Generate n random bytes
Directories
¶
|
|
|
|
|
|
|
|
|
randomData
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
Click to show internal directories.
Click to hide internal directories.