Giter Club home page Giter Club logo

go-simpleutils's Introduction

simpleutils

import "github.com/jimsnab/go-simpleutils"

Index

func CharGet

func CharGet(input string, position int) rune

Charget returns the rune at the logical index position

func CopyFile(srcPath, destPath string) (int64, error)

CopyFile reads file content into memory and writes it to a new file

func DeepCopy(src interface{}) (dest interface{})

DeepCopy generates a separate copy of a source object

func Escape

func Escape(s string) string

Escape translates control characters to backslash escape sequence; e.g., '\r' becomes `\r`

func FileExists(path string) (bool, error)

FileExists returns true if path corresponds to a file, and false if it corresponds to nothing or to a directory.

func GenerateRandomBytes(count int) ([]byte, error)

GenerateRandomBytes returns a byte array of cryptographic (true) random numbers. The byte array length is specified by count.

func GenerateRandomString(count int) (string, error)

GenerateRandomString returns a base-64 encoding of a cryptographic (true) random number byte array. The byte array length is specified by count.

func IndexAt

func IndexAt(testString, substring string, startingIndex int) int

IndexAt is like strings.Index with a starting index

func IndexAtAny(testString, chars string, startingIndex int) int

IndexAtAny is like strings.Index with a starting index

func IsDirectory(path string) (bool, error)

IsDirectory returns true if path corresponds to a directory, and false if it corresponds to nothing or to a file.

func IsTokenCharFirst(ch rune) bool

IsTokenCharFirst returns true if ch is a letter or underscore

func IsTokenCharNext(ch rune) bool

IsTokenCharNext returns true if ch is a letter, number or underscore

func IsTokenName(s string) bool

IsTokenName returns true if s contains only letters, numbers or underscores, and does not start with a number, and has at least one letter

func IsTokenNameWithMiddleChars(s string, middleChars string) bool

IsTokenNameWithMiddleChars returns true if s contains only letters, numbers or underscores, or has allowed characters that are not first or last, does not start with a number, and has at least one letter. A common middleChars string is "-".

func PatternMatch(pattern string, testString string) bool

PatternMatch performs a simple asterisk-based pattern match

func PrintableStr(input string) string

PrintableStr converts non-printable characters in input to a dot

func RuneIndexAt(testString, substring []rune, startingIndex int) int

RuneIndexAt is a version of IndexAt for rune arrays

func RuneIndexAtAny(testString, chars []rune, startingIndex int) int

RuneIndexAtAny is a version of IndexAtAny for rune arrays

func SortedKeys(m interface{}) []string

SortedKeys returns the key array for the map, sorted A-Z

func StringArrayToString(strs []string, delimiter string) string

StringArrayToStrings converts an array of strings to a single string, placing the delimiter string between each

func Substr

func Substr(input string, start int, length int) string

Substr returns a string based on logical character start and length, instead of bytes like a slice

func Utf8len

func Utf8len(data []byte, offset int) int

Utf8len returns the number of bytes in the logical UTF-8 character, 0 if the character is incomplete, or -1 if the character is invalid,

func WhichSuffix(s string, suffixes ...string) *string

WhichSuffix returns a pointer to the first suffix matching s, or nil if none of the suffixes match

HashedText is a typed alias for string

type HashedText string
func HashText(text string) HashedText

HashText returns a sha1 hash of text in base64 encoding.

Generated by gomarkdoc

go-simpleutils's People

Contributors

jimsnab avatar

Watchers

 avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.