gopolutils

package module
v1.14.0 Latest Latest
Warning

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

Go to latest
Published: Mar 14, 2025 License: MIT Imports: 3 Imported by: 2

README

gopolutils

Build Test Go Reference

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func Must added in v1.11.0

func Must[Type any](result Type, except *Exception) Type

If the given exception is nil, the function panics, else this function returns the given result.

Types

type Exception

type Exception struct {
	// contains filtered or unexported fields
}

Representation of a standardized exception.

func NewException

func NewException(message string) *Exception

Construct a new exception with a default name and a given message. Returns a pointer to a new exception.

func NewNamedException

func NewNamedException(name, message string) *Exception

Construct a new exception with a given name and message. Returns a pointer to a new exception.

func (Exception) Error

func (exception Exception) Error() string

Method to adhere to the built-in error type. Returns a string representation of the exception.

func (Exception) Message added in v1.10.0

func (exception Exception) Message() string

Obtain the raw message of the exception without the name. Returns the message of the exception.

func (Exception) Name added in v1.10.0

func (exception Exception) Name() string

Obtain the name of the exception. Returns the name of the exception.

type Logger added in v0.0.3

type Logger struct {
	// contains filtered or unexported fields
}

A logger.

func NewLogger added in v0.0.3

func NewLogger(name string, level LoggingLevel) *Logger

Construct a new logger with a given name and default logging level. The default logging level passed into this constructor is the minimum level of severity that will be ouput by the logger. Returns a pointer to a new logger.

func (*Logger) AddConsole added in v0.0.3

func (logger *Logger) AddConsole() *Exception

Bind the standard output to the logger. If the logger has already allocated the maximum number of allowed outputs, a ValueError is returned.

func (*Logger) AddFile added in v0.0.3

func (logger *Logger) AddFile(fileName string) *Exception

Bind a file to the logger. If the logger has already allocated the maximum number of allowed outputs, a ValueError is returned. If the given file can not be found, an Exception is returned.

func (*Logger) Close added in v0.0.4

func (logger *Logger) Close()

Deallocate the logger. If the logger has a file bound, the file will need to be closed with this method. A good practice is to call this method deferred even if a file is not bound; this method will not close the standard output.

func (*Logger) ConsoleOnly added in v0.0.3

func (logger *Logger) ConsoleOnly() *Exception

Bind only the standard output to the logger. If the logger has already allocated the maximum number of allowed outputs, a ValueError is returned.

func (*Logger) FileOnly added in v0.0.3

func (logger *Logger) FileOnly(fileName string) *Exception

Bind only a file to the logger. If the logger has already allocated the maximum number of allowed outputs, a ValueError is returned. If the given file can not be found, an Exception is returned.

func (*Logger) FullSetup added in v0.0.3

func (logger *Logger) FullSetup(fileName string) *Exception

Bind both a file and the standard output to the logger. If the logger has already allocated the maximum number of allowed outputs, a ValueError is returned. If the given file can not be found, an Exception is returned.

func (Logger) GetLevel added in v1.11.0

func (logger Logger) GetLevel() LoggingLevel

Obtain the level of the logger. Returns the level of the logger.

func (Logger) GetName added in v1.11.0

func (logger Logger) GetName() string

Obtain the name of the logger. Returns the name of the logger.

func (*Logger) Log added in v0.0.6

func (logger *Logger) Log(message string, level LoggingLevel)

Log a message. If the default logging level of the logger is greater than the given logging level of the message, the message will not be logged.

func (*Logger) SetLevel added in v1.5.0

func (logger *Logger) SetLevel(level LoggingLevel)

Set the minimal logging level for the logger.

func (*Logger) SetName added in v1.11.0

func (logger *Logger) SetName(name string)

Set the name of the logger.

type LoggingLevel added in v0.0.3

type LoggingLevel = uint8

An enum representation of the severity of a log message.

const (
	// Lowest severity log message. Used to log debug information for development.
	DEBUG LoggingLevel = iota
	// Used to log info that should be read. It is not an error, but is not a debug message.
	INFO
	// Used to log a non-crashing warning, such as a file already existing when calling a create function.
	WARNING
	// Used to log a non-crashing error. This level should be the default when logging an error.
	ERROR
	// Used to log a crashing error. Used to log a message of a panic or breaking state.
	CRITICAL
)

type Version

type Version struct {
	// contains filtered or unexported fields
}

Representation of a semantic versioning object.

func NewFullVersion

func NewFullVersion(name, description string, major, minor, patch uint8) *Version

Construct a full initialized version object. Returns a pointer to a new fully initialized version object.

func NewNamedVersion

func NewNamedVersion(name string) *Version

Construct a new version object initialized with a given name. Returns a pointer to a new version object initialized with the given name.

func NewStringVersion

func NewStringVersion(name, description string) *Version

Construct a new version object with each of its string properties initialized. Returns a pointer to a new version object initialized with the given string parametres.

func NewVersion

func NewVersion() *Version

Construct a new zero-initialized version object. All the string properties are empty and the numeric properties are set to zero. Returns a pointer to a new version object.

func VersionConvert

func VersionConvert(major, minor, patch uint8) *Version

Construct a new version object with given numeric values. The string properties of the version object are empty. Returns a pointer to a new version object with each of the numeric properties initialized with the given parametres.

func (Version) Compare

func (version Version) Compare(operand Version) bool

Compare each of the numeric properties of the version object to a given operand. Returns true if each of the version object's properties are greater than or equal to the given operand's numeric properties.

func (Version) CompareMajor

func (version Version) CompareMajor(major uint8) bool

Determine if the version object's major property is greater than or equal to the given operand. Returns true if the version object's major property is greater than or equal to the given operand.

func (Version) CompareMinor

func (version Version) CompareMinor(minor uint8) bool

Determine if the version object's minor property is greater than or equal to the given operand. Returns true if the version object's minor property is greater than or equal to the given operand.

func (Version) ComparePatch

func (version Version) ComparePatch(patch uint8) bool

Determine if the version object's patch property is greater than or equal to the given operand. Returns true if the version object's patch property is greater than or equal to the given operand.

func (Version) Description

func (version Version) Description() string

Access the description property of the version object. Returns the description property of the version object.

func (*Version) Fix

func (version *Version) Fix()

Increment the version object's patch property. The version object's major and minor property are not modified.

func (Version) IsPublic

func (version Version) IsPublic() bool

Determine if the version object is public. Returns true if the version object's major property is evaluated greater than or equal to 1.

func (Version) IsZero added in v1.5.0

func (version Version) IsZero() bool

Determine if the version object is equal to zero. Returns true if each of the version object's numeric properties are equal to zero, else false.

func (Version) Major

func (version Version) Major() uint8

Access the major property of the version object. Returns the major property of the version object.

func (Version) Minor

func (version Version) Minor() uint8

Access the minor property of the version object. Returns the minor property of the version object.

func (Version) Name

func (version Version) Name() string

Access the name property of the version object. Returns the name property of the version object.

func (Version) NumberString added in v1.6.0

func (version Version) NumberString() string

Render a string representation of the version object's numeric properties. Returns the version object's numeric properties represented as a string.

func (Version) Patch

func (version Version) Patch() uint8

Access the patch property of the version object. Returns the patch property of the version object.

func (*Version) Publish

func (version *Version) Publish() *Exception

Publish a version object. Set the version object's major property to 1. Zero-out all other numeric properties. If the version object is evaluated to have already been published, a ValueError is returned and no properties are modified.

func (*Version) Release

func (version *Version) Release()

Increment the version object's major property. The version object's minor and patch properties are set to 0.

func (*Version) SetDescription

func (version *Version) SetDescription(description string)

Set the description property of the version object.

func (*Version) SetMajor

func (version *Version) SetMajor(major uint8)

Set the major property of the version object.

func (*Version) SetMinor

func (version *Version) SetMinor(minor uint8)

Set the minor property of the version object.

func (*Version) SetName

func (version *Version) SetName(name string)

Set the name property of the version object.

func (*Version) SetPatch

func (version *Version) SetPatch(patch uint8)

Set the patch property of the version object.

func (Version) ToString

func (version Version) ToString() string

Render a string representation of the version object. Returns a version object represented as a string.

func (*Version) Update

func (version *Version) Update()

Increment the version object's minor property. The version object's patch property is set to 0. The version object's major version is not modified.

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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