cistring

package
v2.0.0+incompatible Latest Latest
Warning

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

Go to latest
Published: Jul 12, 2016 License: BSD-3-Clause Imports: 2 Imported by: 0

Documentation

Overview

Package cistring implements a case-insensitive string type.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func ToStrings

func ToStrings(in []CIString) []string

ToStrings converts a []CIString to a case-preserved []string.

Types

type CIString

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

CIString is an immutable case-insensitive string. It precomputes and stores the lower case version of the string internally. This increases the initial memory cost of the object but saves the CPU (and memory) cost of lowercasing as needed. This should generally trade off favorably because there are many situations where comparisons are performed in a loop against the same object.

func New

func New(str string) CIString

New creates a new CIString.

func (CIString) Equal

func (s CIString) Equal(in CIString) bool

Equal performs a case-insensitive compare. For comparing in a loop, it's beneficial to build a CIString outside the loop and using it to compare with other CIString variables inside the loop.

func (CIString) EqualString

func (s CIString) EqualString(in string) bool

EqualString performs a case-insensitive compare with str. If the input is already lower-cased, it's more efficient to check if s.Lowered()==in.

func (CIString) Lowered

func (s CIString) Lowered() string

Lowered returns the lower-case value of the string. This function should generally be used only for optimizing comparisons.

func (CIString) MarshalJSON

func (s CIString) MarshalJSON() ([]byte, error)

MarshalJSON marshals into JSON.

func (CIString) Original

func (s CIString) Original() string

Original returns the case-preserved value of the string.

func (CIString) String

func (s CIString) String() string

func (*CIString) UnmarshalJSON

func (s *CIString) UnmarshalJSON(b []byte) error

UnmarshalJSON unmarshals from JSON.

Jump to

Keyboard shortcuts

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