ints

package
v0.1.7 Latest Latest
Warning

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

Go to latest
Published: Aug 2, 2024 License: MIT Imports: 2 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func GetOrdinalSuffix

func GetOrdinalSuffix(number int) string

GetOrdinalSuffix returns the ordinal suffix for a given integer.

Parameters:

  • number: The integer for which to get the ordinal suffix. Negative numbers are treated as positive.

Returns:

  • string: The ordinal suffix for the number.

Example:

  • GetOrdinalSuffix(1) returns "1st"
  • GetOrdinalSuffix(2) returns "2nd"

Types

type ErrAt

type ErrAt struct {
	// Index is the index where the error occurred.
	Index int

	// Name is the name of the index.
	Name string

	// Reason is the reason for the error.
	Reason error
}

ErrAt represents an error that occurs at a specific index.

func NewErrAt

func NewErrAt(index int, name string, reason error) *ErrAt

NewErrAt creates a new ErrAt error.

Parameters:

  • index: The index where the error occurred.
  • name: The name of the index.
  • reason: The reason for the error.

Returns:

  • *ErrAt: A pointer to the newly created ErrAt.

func (*ErrAt) ChangeReason

func (e *ErrAt) ChangeReason(reason error)

ChangeReason implements the Unwrapper interface.

func (*ErrAt) Error

func (e *ErrAt) Error() string

Error implements the Unwrapper interface.

Message: "something went wrong at the {index} {name}: {reason}".

However, if the reason is nil, the message is "something went wrong at the {index} {name}" instead.

func (*ErrAt) Unwrap

func (e *ErrAt) Unwrap() error

Unwrap implements the Unwrapper interface.

type ErrWhileAt

type ErrWhileAt struct {
	// Index is the index where the error occurred.
	Index int

	// Element is the element where the index is pointing to.
	Element string

	// Operation is the operation that was being performed.
	Operation string

	// Reason is the reason for the error.
	Reason error
}

ErrWhileAt represents an error that occurs while performing an operation at a specific index.

func NewErrWhileAt

func NewErrWhileAt(operation string, index int, elem string, reason error) *ErrWhileAt

NewErrWhileAt creates a new ErrWhileAt error.

Parameters:

  • operation: The operation that was being performed.
  • index: The index where the error occurred.
  • elem: The element where the index is pointing to.
  • reason: The reason for the error.

Returns:

  • *ErrWhileAt: A pointer to the newly created ErrWhileAt.

func (*ErrWhileAt) ChangeReason

func (e *ErrWhileAt) ChangeReason(reason error)

ChangeReason implements the Unwrapper interface.

func (*ErrWhileAt) Error

func (e *ErrWhileAt) Error() string

Error implements the Unwrapper interface.

Message: "an error occurred while {operation} at index {index} {element}: {reason}"

However, if the reason is nil, the message is "an error occurred while {operation} at index {index} {element}" instead.

func (*ErrWhileAt) Unwrap

func (e *ErrWhileAt) Unwrap() error

Unwrap implements the Unwrapper interface.

Jump to

Keyboard shortcuts

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