xtype

package
v1.4.0 Latest Latest
Warning

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

Go to latest
Published: Aug 21, 2025 License: Apache-2.0 Imports: 3 Imported by: 0

Documentation

Overview

Package xtype provides extended type definitions with additional utility methods.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Bytes

type Bytes []byte

Bytes is a byte slice type with additional utility methods. It provides convenient methods for common byte slice operations.

func (Bytes) Bytes

func (s Bytes) Bytes() []byte

Bytes returns the underlying byte slice. This method provides a consistent interface for accessing the raw bytes.

func (Bytes) Hex

func (s Bytes) Hex() string

Hex returns the hexadecimal string representation of the byte slice. This is a convenience method that wraps the hex package's EncodeToString function.

func (Bytes) String

func (s Bytes) String() string

String converts the byte slice to a string using unsafe pointer casting. This is more efficient than string() conversion as it avoids copying. Warning: The returned string shares memory with the original byte slice.

type String

type String string

String is an extended string type with additional utility methods. It provides convenient methods for common string operations.

func (String) Bytes

func (s String) Bytes() []byte

Bytes converts the string to a byte slice using unsafe pointer casting. This is more efficient than []byte() conversion as it avoids copying. Warning: The returned byte slice shares memory with the original string.

func (String) Lower

func (s String) Lower() string

Lower converts the string to lowercase. This is a convenience method that wraps strings.ToLower.

func (String) Short

func (s String) Short() string

Short creates an abbreviated version of the string using the default separator "-". It takes the first character of each segment split by hyphens. For example, "hello-world-test" becomes "HWT".

func (String) ShortBySign

func (s String) ShortBySign(sign string) string

ShortBySign creates an abbreviated version of the string using a custom separator. It splits the string by the provided sign, converts to uppercase, and takes the first character of each non-empty segment to form an abbreviation. For example, with sign=".", "hello.world.test" becomes "HWT". Optimized version using strings.Builder to reduce memory allocations.

func (String) String

func (s String) String() string

String returns the underlying string value. This method provides a consistent interface for accessing the raw string.

func (String) Upper

func (s String) Upper() string

Upper converts the string to uppercase. This is a convenience method that wraps strings.ToUpper.

Jump to

Keyboard shortcuts

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