Categorygithub.com/tlabdotcom/gohelper
modulepackage
1.0.3
Repository: https://github.com/tlabdotcom/gohelper.git
Documentation: pkg.go.dev

# README

GOHELPER

Maintainer: jiharal

Go CI

Go Report Card

Overview

The GOHELPER package provides utility functions for working with pointers and safely retrieving values from maps in Go. These helper functions can make your code cleaner and more concise.

Functions

Pointer Functions

These functions return pointers to values of their respective types. They are useful for creating pointer references for various data types.

Available Functions

  • PointerUUID: Returns a pointer to a uuid.UUID.
  • PointerString: Returns a pointer to a string.
  • PointerBool: Returns a pointer to a bool.
  • PointerInt: Returns a pointer to an int.
  • PointerInt8: Returns a pointer to an int8.
  • PointerInt16: Returns a pointer to an int16.
  • PointerInt32: Returns a pointer to an int32.
  • PointerInt64: Returns a pointer to an int64.
  • PointerUint: Returns a pointer to a uint.
  • PointerUint8: Returns a pointer to a uint8.
  • PointerUint16: Returns a pointer to a uint16.
  • PointerUint32: Returns a pointer to a uint32.
  • PointerUint64: Returns a pointer to a uint64.
  • PointerFloat32: Returns a pointer to a float32.
  • PointerFloat64: Returns a pointer to a float64.
  • PointerComplex64: Returns a pointer to a complex64.
  • PointerComplex128: Returns a pointer to a complex128.
  • PointerByte: Returns a pointer to a byte.
  • PointerRune: Returns a pointer to a rune.

Usage Example

go get github.com/tlabdotcom/gohelper
package main

import (
    "fmt"
    "github.com/google/uuid"
    "github.com/tlabdotcom/gohelper"
)

func main() {
    str := "Hello, World!"
    strPtr := gohelper.PointerString(str)
    fmt.Println(*strPtr) // Output: Hello, World!

    id := uuid.New()
    idPtr := gohelper.PointerUUID(id)
    fmt.Println(*idPtr) // Output: (some UUID value)
}

# Functions

BoolToString converts a bool to a string.
Float64ToInt converts a float64 to an int.
Float64ToString converts a float64 to a string.
GetBoolValue returns the value of a bool pointer.
GetByteValue returns the value of a byte pointer.
GetComplex128Value returns the value of a complex128 pointer.
GetComplex64Value returns the value of a complex64 pointer.
GetEndOfDay returns the end of the day for a given time.
GetFloat32Value returns the value of a float32 pointer.
GetFloat64Value returns the value of a float64 pointer.
GetInt16Value returns the value of an int16 pointer.
GetInt32Value returns the value of an int32 pointer.
GetInt64Value returns the value of an int64 pointer.
GetInt8Value returns the value of an int8 pointer.
GetIntValue returns the value of an int pointer.
GetRuneValue returns the value of a rune pointer.
No description provided by the author
GetStringValue returns the value of a string pointer.
GetRuneValue returns the value of a rune pointer.
GetUint16Value returns the value of a uint16 pointer.
GetUint32Value returns the value of a uint32 pointer.
GetUint64Value returns the value of a uint64 pointer.
GetUint8Value returns the value of a uint8 pointer.
GetUintValue returns the value of a uint pointer.
GetUUIDValue returns the value of a uuid.UUID pointer.
Int64ToInt converts an int64 to an int.
Int64ToString converts an int64 to a string.
IntToFloat64 converts an int to a float64.
IntToInt64 converts an int to an int64.
IntToString converts an int to a string.
NewUUID generates a new UUID.
No description provided by the author
PointerBool returns a pointer to the given bool.
PointerByte returns a pointer to the given byte.
PointerComplex128 returns a pointer to the given complex128.
PointerComplex64 returns a pointer to the given complex64.
PointerFloat32 returns a pointer to the given float32.
PointerFloat64 returns a pointer to the given float64.
PointerInt returns a pointer to the given int.
PointerInt16 returns a pointer to the given int16.
PointerInt32 returns a pointer to the given int32.
PointerInt64 returns a pointer to the given int64.
PointerInt8 returns a pointer to the given int8.
PointerRune returns a pointer to the given rune.
PointerString returns a pointer to the given string.
PointerTime returns a pointer to the given time.
PointerUint returns a pointer to the given uint.
PointerUint16 returns a pointer to the given uint16.
PointerUint32 returns a pointer to the given uint32.
PointerUint64 returns a pointer to the given uint64.
PointerUint8 returns a pointer to the given uint8.
PointerUUID returns a pointer to the given UUID.
SafeGetBoolValue safely retrieves a bool value from a map by key.
SafeGetFloat64Value safely retrieves a float64 value from a map by key.
SafeGetInt64Value safely retrieves an int64 value from a map by key.
SafeGetIntValue safely retrieves an int value from a map by key.
SafeGetStringValue safely retrieves a string value from a map by key.
SafeGetValue safely retrieves a value of any type from a map by key.
StringToBool converts a string to a bool.
StringToFloat64 converts a string to a float64.
StringToInt converts a string to an int.
StringToInt64 converts a string to an int64.
StringToTime converts a string to a time.Time The layout parameter specifies the format of the input string.
StringToUUID converts a string to a UUID.
TimeToString converts a time.Time to a string The layout parameter specifies the desired output format.
No description provided by the author
No description provided by the author
No description provided by the author
No description provided by the author
Interface conversions.
No description provided by the author
UUIDToString converts a UUID to a string.