strops

package module
v2.0.1 Latest Latest
Warning

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

Go to latest
Published: Aug 13, 2019 License: MIT Imports: 7 Imported by: 0

Documentation

Overview

package strops (string operations) provides string management utilities designed to perform a variety of string operations including string centering, justification, multiple replacements and implementation of the the io.Reader and io.Writer interfaces.

Source file, 'strops.go', is located in source code repository:

https://github.com/MikeAustin71/stringopsgo.git

Currently, the package consists of one type, 'StrOps' which is documented below.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type StrOps

type StrOps struct {
	StrIn  string // public string variable available at user's discretion
	StrOut string // public string variable available at user's discretion
	// contains filtered or unexported fields
}

StrOps - encapsulates a collection of methods used to manage string operations.

Most of the utility offered by this type is provided through its associated methods. However, given that two data elements, 'StrIn' and 'StrOut' are provided, the structure may be used as a data transport object (dto) containing two strings.

Version 2.0.0 and all later versions of this type support Go Modules. For Version 2+ implementations, use the following import statement:

import "github.com/MikeAustin71/stringopsgo/strops/v2"

Earlier Version 1.0.0 implementations require a different import statement:

import "github.com/MikeAustin71/stringopsgo/strops"

Be advised that this type, 'StrOps', implements the io.Reader and io.Writer interfaces. All io.Reader and io.Writer operations utilize the private string data element, 'StrOps.stringData'.

func (StrOps) BreakTextAtLineLength

func (sops StrOps) BreakTextAtLineLength(targetStr string, lineLength int, lineDelimiter rune) (string, error)

BreakTextAtLineLength - Breaks string text into lines. Takes a string and inserts a line delimiter character (a.k.a 'rune') at the specified line length ('lineLength').

------------------------------------------------------------------------

Input Parameters

targetStr	string	- The string which will be parsed into text lines.

lineLength	int	- The maximum length of each line.

Note: If the caller specifies a line length of 50, the line delimiter character may be placed in the 51st character position depending upon the word breaks.

func (*StrOps) CopyIn

func (sops *StrOps) CopyIn(strops2 *StrOps)

CopyIn - Copies string information from another StrOps instance passed as an input parameter to the current StrOps instance.

func (*StrOps) CopyOut

func (sops *StrOps) CopyOut() *StrOps

CopyOut - Creates a 'deep' copy of the current StrOps instance and returns a pointer to a new instance containing that copied information.

func (StrOps) DoesLastCharExist

func (sops StrOps) DoesLastCharExist(testStr string, lastChar rune) bool

DoesLastCharExist - returns true if the last character (rune) of input string 'testStr' is equal to input parameter 'lastChar' which is of type 'rune'.

func (StrOps) FindFirstNonSpaceChar

func (sops StrOps) FindFirstNonSpaceChar(targetStr string, startIndex, endIndex int) (int, error)

FindFirstNonSpaceChar - Returns the string index of the first non-space character in a string segment. The string to be searched is input parameter 'targetStr'. The string segment which will be searched from left to right in 'targetStr' is defined by the starting index ('startIndex') and the ending index ('endIndex').

Searching from left to right, this method identifies the first non-space character (any character that is NOT a space ' ') in the target string segment and returns the index associated with that non-space character.

------------------------------------------------------------------------

Return Values

This method returns the index of the first non-space character in the target string
segment using a left to right search. If the entire string consists of space characters,
this method returns a value of -1.

func (StrOps) FindLastNonSpaceChar

func (sops StrOps) FindLastNonSpaceChar(targetStr string, startIdx, endIdx int) (int, error)

FindLastNonSpaceChar - Returns the string index of the last non-space character in a string segment. The string to be searched is input parameter, 'targetStr'. The string segment is further defined by input parameters 'startIdx' and 'endIdx'. These indexes define a segment within 'targetStr' which will be searched to identify the last non-space character.

The search is a backwards search, from right to left, conducted within the defined 'targetStr' segment. The search therefore starts at 'endIdx' and proceeds towards 'startIdx' until the last non-space character in the string segment is identified.

If the last non-space character is found, that string index is returned. If the string segment consists entirely of space characters, the return value is -1.

if 'targetStr' is a zero length string, an error will be triggered. Likewise, if 'startIdx' of 'endIdx' are invalid, an error will be returned.

func (StrOps) FindLastSpace

func (sops StrOps) FindLastSpace(targetStr string, startIdx, endIdx int) (int, error)

FindLastSpace - Returns a string index indicating the last space character (' ') in a string segment. The string segment is defined by input parameters, 'startIdx' and 'endIdx'.

The string segment search proceeds backwards, from right to left. The search therefore starts at 'endIdx' and proceeds towards 'startIdx' until the last space character in the string segment is identified.

If a valid index for the last space character is found in the string segment, that index value is returned. If a space character is NOT found in the specified string segment, a value of -1 is returned.

if 'targetStr' is a zero length string, an error will be triggered. Likewise, if 'startIdx' of 'endIdx' are invalid, an error will be returned.

func (StrOps) FindLastWord

func (sops StrOps) FindLastWord(
	targetStr string,
	startIndex,
	endIndex int) (beginWrdIdx,
	endWrdIdx int,
	isAllOneWord,
	isAllSpaces bool,
	err error)

FindLastWord - Returns the beginning and ending indexes of the last word in a target string segment. A 'word' is defined here as a contiguous set of non-space characters delimited by spaces or the beginning and ending indexes of the target string segment. Note, for purposes of this method, a 'word' my consist of a single non-space character such as an article 'a' or a punctuation mark '.'

------------------------------------------------------------------------

Examples

Example (1)
	In the text string segment:

		"The cow jumped over the moon."

	The last word would be defined as "moon."

Example (2)
	In the text string segment:

		"  somewhere over the rainbow  "

	The last word would be defined as "rainbow"

------------------------------------------------------------------------

The string to be searched is contained in input parameter, 'targetStr'. The string segment within 'targetStr' is defined by input parameters 'startIndex' and 'endIndex'.

If the entire string segment is classified as a 'word', meaning that there are no space characters in the string segment, the returned values for 'beginWrdIdx' and 'endWrdIdx' will be equal to the input parameters 'startIndex' and 'endIndex'.

If the string segment is consists entirely of space characters, the returned 'beginWrdIdx' and 'endWrdIdx' will be set equal to -1 and the returned value, 'isAllSpaces' will be set to 'true'.

If 'targetStr' is an empty string, an error will be returned.

------------------------------------------------------------------------

Input Parameters

	targetStr	string	- The string containing the string segment which
                     		will be searched to identify the last word
                     		in the string segment.

	startIndex	int	- The index marking the beginning of the string
                     		segment in 'targetStr'.

	endIndex	int	- The index marking the end of the string segment
                     		in 'targetStr'.

------------------------------------------------------------------------

Return Values

beginWrdIdx	int	-	The index marking the beginning of the last word
				in the string segment identified by input parameters
				'startIndex' and 'endIndex'. If the string segment
				consists of all spaces or is empty, this value is
				set to -1.

endWrdIdx	int	-	The index marking the end of the last word in the
				string segment identified by input parameters 'startIndex'
				and 'endIndex'. If the string segment consists of all
				spaces or is empty, this value is set to -1.

isAllOneWord	bool	-	If the string segment identified by input parameters
				'startIndex' and 'endIndex' consists entirely of non-space
				characters (characters other than ' '), this value is set
				to 'true'.

isAllSpaces	bool	-	If the string segment identified by input parameters
				'startIndex' and 'endIndex' consists entirely of space
				characters (character = ' '), this value is set to 'true'.

err		error	-	If targetStr is empty or if startIndex or endIndex is invalid,
				an error is returned. If the method completes successfully,
				err = nil.

func (StrOps) FindRegExIndex

func (sops StrOps) FindRegExIndex(targetStr string, regex string) []int

FindRegExIndex - returns a two-element slice of integers defining the location of the leftmost match in targetStr of the regular expression (regex).

------------------------------------------------------------------------

Return Value

The return value is an array of integers. If no match is found the return
value is 'nil'.  If regular expression is successfully matched, the match
will be located at targetStr[loc[0]:loc[1]]. Again, a return value of 'nil'
signals that no match was found.

func (*StrOps) GetCountBytesRead

func (sops *StrOps) GetCountBytesRead() uint64

GetCountBytesRead - Returns private member variable 'StrOps.cntBytesRead' which holds the number of bytes accumulated through the last Read operation executed through method StrOps.Read().

func (*StrOps) GetCountBytesWritten

func (sops *StrOps) GetCountBytesWritten() uint64

GetCountBytesWritten - Returns private member variable 'StrOps.cntBytesWritten' which holds the number of bytes accumulated through the last Write operation executed through method StrOps.Write().

func (*StrOps) GetReader

func (sops *StrOps) GetReader() io.Reader

GetReader() Returns an io.Reader which will read the private member data element StrOps.stringData.

func (StrOps) GetSoftwareVersion

func (sops StrOps) GetSoftwareVersion() string

GetSoftwareVersion - Returns the software version for type 'StrOps'.

func (*StrOps) GetStringData

func (sops *StrOps) GetStringData() string

GetStringData - Returns the current value of internal member string, StrOps.stringData

func (StrOps) GetValidBytes

func (sops StrOps) GetValidBytes(targetBytes, validBytes []byte) ([]byte, error)

GetValidBytes - Receives an array of 'targetBytes' which will be examined to determine the validity of individual bytes or characters. Each character (byte) in input array 'targetBytes' will be compared to input parameter 'validBytes', another array of bytes. If a character in 'targetBytes' also exists in 'validBytes' it will be considered valid and included in the returned array of bytes.

------------------------------------------------------------------------

Input Parameters

targetBytes	[] byte	- An array of characters (bytes) which will be examined
			for valid characters. The list of valid characters is
			found in input parameter 'validBytes'. Valid characters
			in targetBytes will be returned by this method as an
			array of bytes. Invalid characters will be discarded.

validBytes	[] byte	- An array of bytes containing valid characters. If a character
			(byte) in 'targetBytes' is also present in 'validBytes' it will
			be classified as 'valid' and included in the returned array of
			bytes. Invalid characters will be discarded.

------------------------------------------------------------------------

Return Values

[] byte	- An array of bytes which contains bytes that are present in both 'targetBytes'
	and 'validBytes'. Note: If all characters in 'targetBytes' are classified as
	'invalid', the returned array of bytes will be a zero length array.

error	- If the method completes successfully this value is 'nil'. If an error is
	encountered this value will contain the error message. Examples of possible
	errors include a zero length 'targetBytes array or 'validBytes' array.

func (StrOps) GetValidRunes

func (sops StrOps) GetValidRunes(targetRunes []rune, validRunes []rune) ([]rune, error)

GetValidRunes - Receives an array of 'targetRunes' which will be examined to determine the validity of individual runes or characters. Each character (rune) in input array 'targetRunes' will be compared to input parameter 'validRunes', another array of runes. If a character in 'targetRunes' also exists in 'validRunes', that character will be considered valid and included in the returned array of runes.

------------------------------------------------------------------------

Input Parameters

targetRunes		[] rune	- An array of characters (runes) which will be examined
				for valid characters. The list of valid characters is
				found in input parameter 'validRunes'. Valid characters
				in targetRunes will be returned by this method as an
				array of runes. Invalid characters will be discarded.

validRunes		[] rune	- An array of runes containing valid characters. If a character
				(rune) in targetRunes is also present in 'validRunes' it will
				be classified as 'valid' and included in the returned array of
				runes. Invalid characters will be discarded.

------------------------------------------------------------------------

Return Values

[] rune	- An array of runes which contains runes that are present in 'targetRunes' and
	'validRunes'. Note: If all characters in 'targetRunes' are classified as
	'invalid', the returned array of runes will be a zero length array.

error - If the method completes successfully this value is 'nil'. If an error is
	encountered this value will contain the error message. Examples of possible
	errors include a zero length 'targetRunes array or 'validRunes' array.

func (StrOps) GetValidString

func (sops StrOps) GetValidString(targetStr string, validRunes []rune) (string, error)

GetValidString - Validates the individual characters in input parameter string, 'targetStr'. To identify valid characters, the characters in 'targetStr' are compared against input parameter 'validRunes', an array of type rune. If a character exists in both 'targetStr' and 'validRunes' it is deemed valid and returned in an output string.

------------------------------------------------------------------------

Input Parameter

targetStr	string	-	The string which will be screened for valid characters.

validRunes	[] rune	-	An array of type rune containing valid characters. Characters
				which exist in both 'targetStr' and 'validRunes' will be
				returned as a new string. Invalid characters are discarded.

------------------------------------------------------------------------

Return Values

string	- This string will be returned containing valid characters extracted
	from 'targetStr'. A character is considered valid if it exists in
	both 'targetStr' and 'validRunes'. Invalid characters are discarded.
	This means that if no valid characters are identified, a zero length
	string will be returned.

error - If the method completes successfully this value is 'nil'. If an error is
	encountered this value will contain the error message. Examples of possible
	errors include a zero length 'targetStr' (string) or a zero length
	'validRunes' array.

func (StrOps) IsEmptyOrWhiteSpace

func (sops StrOps) IsEmptyOrWhiteSpace(targetStr string) bool

IsEmptyOrWhiteSpace - If a string is zero length or consists solely of white space (contiguous spaces), this method will return 'true'.

Otherwise, a value of false is returned.

func (StrOps) LowerCaseFirstLetter added in v2.0.1

func (sops StrOps) LowerCaseFirstLetter(str string) string

LowerCaseFirstLetter - Finds the first alphabetic character in a string (a-z A-Z) and converts it to lower case.

func (StrOps) MakeSingleCharString

func (sops StrOps) MakeSingleCharString(charRune rune, strLen int) (string, error)

MakeSingleCharString - Creates a string of length 'strLen' consisting of a single character passed through input parameter, 'charRune' as type 'rune'.

func (StrOps) NewPtr

func (sops StrOps) NewPtr() *StrOps

NewPtr - Returns a pointer to a new instance of StrOps. Useful for cases requiring io.Reader and io.Writer.

func (*StrOps) Read

func (sops *StrOps) Read(p []byte) (n int, err error)

Read - Implements io.Reader interface. Read reads up to len(p) bytes into 'p'. This method supports buffered 'read' operations.

The internal member string variable, 'StrOps.stringData' is written into 'p'.

'StrOps.stringData' can be accessed through Getter an Setter methods, GetStringData() and SetStringData()

func (StrOps) ReadStringFromBytes added in v2.0.1

func (sops StrOps) ReadStringFromBytes(
	bytes []byte,
	startIdx int) (extractedStr string, nextStartIdx int)

ReadStringFromBytes - Receives a byte array and retrieves a string. The beginning of the string is designated by input parameter 'startIdx'. The end of the string is determined when a carriage return ('\r'), vertical tab ('\v') or a new line character ('\n') is encountered.

The parsed string is returned to the caller along with 'nextStartIdx', which is the byte array index of the beginning of the next string.

------------------------------------------------------------------------

Input Parameters

bytes          []byte - An array of bytes from which a string will be extracted
                        and returned.

startIdx          int - The starting index in input parameter 'bytes' where the string
                        extraction will begin. The string extraction will cease when
                        a carriage return ('\r'), a vertical tab ('\v') or a new line
                        character ('\n') is encountered.

------------------------------------------------------------------------

Return Values

extractedStr   string - The string extracted from input parameter 'bytes' beginning
                        at the index in 'bytes' indicated by input parameter 'startIdx'.

nextStartIdx      int - The index of the beginning of the next string in the byte array
                        'bytes' after 'extractedString'. If no more strings exist in the
                        the byte array, 'nextStartIdx' will be set to -1.

func (StrOps) ReplaceBytes

func (sops StrOps) ReplaceBytes(targetBytes []byte, replacementBytes [][]byte) ([]byte, error)

ReplaceBytes - Replaces characters in a target array of bytes ([]bytes) with those specified in a two dimensional slice of bytes.

------------------------------------------------------------------------

Input Parameters

targetBytes	[]byte	- The byte array which will be examined. If characters ('bytes') eligible
			for replacement are identified by replacementBytes[i][0] they will be
			replaced by the character specified in replacementBytes[i][1].

replacementBytes [][]byte - A two dimensional slice of type byte. Element [i][0] contains the target
			character to locate in 'targetBytes'. Element[i][1] contains the replacement
			character which will replace the target character in 'targetBytes'. If
			the replacement character element [i][1] is a zero value, the target character
			will not be replaced. Instead, it will be eliminated or removed from
			the returned byte array ([]byte).

------------------------------------------------------------------------

Return Values

[]byte	- The returned byte array containing the characters and replaced characters
	from the original 'targetBytes' array.

error	- If the method completes successfully this value is 'nil'. If an error is
	encountered this value will contain the error message. Examples of possible
	errors include a zero length targetBytes[] array or replacementBytes[][] array.
	In addition, if any of the replacementBytes[][x] 2nd dimension elements have
	a length less than two, an error will be returned.

func (StrOps) ReplaceMultipleStrs

func (sops StrOps) ReplaceMultipleStrs(targetStr string, replaceArray [][]string) (string, error)

ReplaceMultipleStrs - Replaces all instances of string replaceArray[i][0] with replacement string from replaceArray[i][1] in 'targetStr'.

Note: The original 'targetStr' is NOT altered.

Input parameter 'replaceArray' should be passed as a two-dimensional slice. If the length of the 'replaceArray' second dimension is less than '2', an error will be returned.

func (StrOps) ReplaceNewLines

func (sops StrOps) ReplaceNewLines(targetStr string, replacement string) string

RemoveNewLines - Replaces New Line characters from string. If the specified replacement string is empty, the New Line characters are simply removed from the input parameter, 'targetStr'.

func (StrOps) ReplaceRunes

func (sops StrOps) ReplaceRunes(targetRunes []rune, replacementRunes [][]rune) ([]rune, error)

ReplaceRunes - Replaces characters in a target array of runes ([]rune) with those specified in a two-dimensional slice of runes, 'replacementRunes[][]'.

------------------------------------------------------------------------

Input Parameters

targetRunes	[]rune	- The rune array which will be examined. If target characters ('runes')
			eligible for replacement are identified by replacementRunes[i][0], they
			will be replaced by the character specified in replacementRunes[i][1].

replacementRunes [][]rune - A two dimensional slice of type 'rune'. Element [i][0] contains the target
			 character to locate in 'targetRunes'. Element[i][1] contains the
			 replacement character which will replace the target character in
			 'targetRunes'. If the replacement character element [i][1] is a zero value,
			 the	target character will not be replaced. Instead, it will be eliminated
			 or removed from the returned rune array ([]rune).

------------------------------------------------------------------------

Return Values

[]rune	- The returned rune array containing the characters and replaced characters
	from the original 'targetRunes' array.

error	- If the method completes successfully this value is 'nil'. If an error is
	encountered this value will contain the error message. Examples of possible
	errors include a zero length 'targetRunes' array or 'replacementRunes' array.
	In addition, if any of the replacementRunes[][x] 2nd dimension elements have
	a length less than two, an error will be returned.

func (StrOps) ReplaceStringChars

func (sops StrOps) ReplaceStringChars(
	targetStr string,
	replacementRunes [][]rune) (string, error)

ReplaceStringChars - Replaces string characters in a target string ('targetStr') with those specified in a two dimensional slice of runes, 'replacementRunes[][]'.

------------------------------------------------------------------------

Input Parameters

targetStr	string		- The string which will be examined. If target string characters
				eligible for replacement are identified by replacementRunes[i][0], they
				will be replaced by the character specified in replacementRunes[i][1].

replacementRunes [][]rune	- A two dimensional slice of type 'rune'. Element [i][0] contains the target
			 	character to locate in 'targetStr'. Element[i][1] contains the
				replacement character which will replace the target character in
				'targetStr'. If the replacement character element [i][1] is a zero value,
				the target character will not be replaced. Instead, it will be eliminated
				or removed from the returned string.

------------------------------------------------------------------------

Return Values

string	- The returned string containing the characters and replaced characters
	from the original target string, ('targetStr').

error	- If the method completes successfully this value is 'nil'. If an error is
	encountered this value will contain the error message. Examples of possible
	errors include a zero length 'targetStr' or 'replacementRunes[][]' array.
	In addition, if any of the replacementRunes[][x] 2nd dimension elements have
	a length less than two, an error will be returned.

func (*StrOps) ResetBytesReadCounter

func (sops *StrOps) ResetBytesReadCounter()

ResetBytesReadCounter - Resets the internal 'Bytes Read' counter to zero. As practical matter, this method is rarely if ever used. Its use is restricted primarily to special circumstances or debugging operations.

This method sets StrOps.cntBytesRead equal to zero.

func (*StrOps) ResetBytesWrittenCounter

func (sops *StrOps) ResetBytesWrittenCounter()

ResetBytesWrittenCounter - Resets the internal 'Bytes Written' counter to zero. As practical matter, this method is rarely if ever used. Its use is restricted primarily to special circumstances or debugging operations.

This method sets StrOps.cntBytesWritten equal to zero.

func (*StrOps) SetStringData

func (sops *StrOps) SetStringData(str string)

SetStringData - Sets the value of internal string data element, StrOps.stringData.

func (StrOps) StrCenterInStr

func (sops StrOps) StrCenterInStr(strToCenter string, fieldLen int) (string, error)

StrCenterInStr - returns a string which includes a left pad blank string plus the original string ('strToCenter'), plus a right pad blank string.

The complete string will effectively center the original string is a field of specified length ('fieldLen').

func (StrOps) StrCenterInStrLeft

func (sops StrOps) StrCenterInStrLeft(strToCenter string, fieldLen int) (string, error)

StrCenterInStrLeft - returns a string which includes a left pad blank string plus the original string. It does NOT include the Right pad blank string.

Nevertheless, the complete string will effectively center the original string is a field of specified length.

func (StrOps) StrGetCharCnt

func (sops StrOps) StrGetCharCnt(targetStr string) int

StrGetCharCnt - Uses the 'len' method to return the number of rune characters in a string.

func (StrOps) StrGetRuneCnt

func (sops StrOps) StrGetRuneCnt(targetStr string) int

StrGetRuneCnt - Uses utf8 Rune Count function to return the number of characters in a string.

func (StrOps) StrLeftJustify

func (sops StrOps) StrLeftJustify(strToJustify string, fieldLen int) (string, error)

StrLeftJustify - Creates a new string with a total length equal to input parameter 'fieldLen'.

Input parameter 'strToJustify' is placed on the left side of the output string and spaces are padded to the right in order to create a string with total length of 'fieldLen'.

Example:

fieldLen = 15
strToJustify 	= "Hello World"
Returned String = "Hello World    "
String Index    =  012345648901234

func (StrOps) StrPadLeftToCenter

func (sops StrOps) StrPadLeftToCenter(strToCenter string, fieldLen int) (string, error)

StrPadLeftToCenter - Returns a blank string which allows centering of the target string in a fixed length field.

Example:

Assume that total field length ('fieldlen') is 70. Assume that the string to Center
('strToCenter') is 10-characters. In order to center a 10-character string in a
70-character field, 30-space characters would need to be positioned on each side
of the string to center. This method only returns the left segment, or a string
consisting of 30-spaces.

func (StrOps) StrRightJustify

func (sops StrOps) StrRightJustify(strToJustify string, fieldLen int) (string, error)

StrRightJustify - Returns a string where input parameter 'strToJustify' is right justified. The length of the returned string is determined by input parameter 'fieldlen'.

Example:

If the total field length ('fieldLen') is specified as 50-characters and the
length of string to justify ('strToJustify') is 20-characters, then this method
would return a string consisting of 30-space characters plus the 'strToJustify'.

func (StrOps) SwapRune

func (sops StrOps) SwapRune(targetStr string, oldRune rune, newRune rune) (string, error)

SwapRune - Swaps all instances of 'oldRune' character with 'newRune' character in input parameter target string ('targetStr').

func (StrOps) TrimMultipleChars

func (sops StrOps) TrimMultipleChars(
	targetStr string,
	trimChar rune) (rStr string, err error)

TrimMultipleChars- Performs the following operations on strings:

  1. Trims Right and Left ends of 'targetStr' for all instances of 'trimChar'
  2. Within the interior of a string, multiple instances of 'trimChar' are reduced to a single instance.

Example:

targetStr = "       Hello          World        "
trimChar  = ' ' (One Space)
returned string (rStr) = "Hello World"

func (StrOps) TrimStringEnds

func (sops StrOps) TrimStringEnds(
	targetStr string,
	trimChar rune) (rStr string, err error)

TrimStringEnds - Removes all instances of input parameter 'trimChar' from the beginning and end of input parameter string 'targetStr'.

func (StrOps) UpperCaseFirstLetter added in v2.0.1

func (sops StrOps) UpperCaseFirstLetter(str string) string

UpperCaseFirstLetter - Finds the first alphabetic character in a string (a-z A-Z) and converts it to upper case.

func (*StrOps) Write

func (sops *StrOps) Write(p []byte) (n int, err error)

Write - Implements the io.Writer interface. Write writes len(p) bytes from p to the underlying data stream. In this case the underlying data stream is private member variable string, 'StrOps.stringData'.

Receives a byte array 'p' and writes the contents to a string, private structure data element 'StrOps.stringData'.

'StrOps.stringData' can be accessed through 'Getter' and 'Setter' methods, 'GetStringData()' and 'SetStringData()'.

Jump to

Keyboard shortcuts

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