Documentation ¶
Index ¶
- func DeepCopy(value any) any
- func ExitFromProgram(err error)
- func FindMaximumValue[T any](comparisonFunc func(T, T) int, inputValues ...T) T
- func FindMinimumValue[T any](comparisonFunc func(T, T) int, inputValues ...T) T
- func MaxInt(a, b int) int
- func MinInt(a, b int) int
- func SplitIntoGroups[T any](slice []T, n int) [][]T
- func WaitForUserConfirmation()
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func ExitFromProgram ¶
func ExitFromProgram(err error)
ExitFromProgram is a utility function that handles program termination in case of an error. It prints the error message if the error is not nil, prompts the user to press enter to exit, and then terminates the program with a status code of 1.
Parameters:
- err: The error that caused the program termination. If err is nil, no error message is printed.
Note: This function does not return. The program is terminated by calling os.Exit(1).
func FindMaximumValue ¶
func FindMinimumValue ¶
func MaxInt ¶
MaxInt takes two integers as input and returns the larger value. If the values are equal, it returns the same value.
Example:
a := 5 b := 7 max := MaxInt(a, b) fmt.Println(max) // Output: 7
func MinInt ¶
MinInt takes two integers as input and returns the smaller value. If the values are equal, it returns the same value.
Example:
a := 5 b := 7 min := MinInt(a, b) fmt.Println(min) // Output: 5
func SplitIntoGroups ¶
SplitIntoGroups takes a slice of any type and an integer n as input. It splits the slice into n groups and returns a 2D slice where each inner slice represents a group. The elements are distributed based on their index in the original slice. If there are more elements than groups, the remaining elements are distributed to the groups in a round-robin fashion. If the number of groups (n) is less than or equal to 0, it panics with the message "The number of groups must be positive and non-zero". If the length of the slice is less than 2 or n is 1, it returns the original slice wrapped in a 2D slice.
Example:
slice := []int{1, 2, 3, 4, 5, 6} n := 3 groups := SplitIntoGroups(slice, n) fmt.Println(groups) // Output: [[1 4] [2 5] [3 6]]
func WaitForUserConfirmation ¶
func WaitForUserConfirmation()
Types ¶
This section is empty.