xstring

package
v0.25.15 Latest Latest
Warning

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

Go to latest
Published: Apr 21, 2024 License: Apache-2.0 Imports: 8 Imported by: 0

README

GoKit - xstring

String kits for Golang development.

Installation

go get -u github.com/likexian/gokit

Importing

import (
    "github.com/likexian/gokit/xstring"
)

Documentation

Visit the docs on GoDoc

Example

Check string is all letter
s := "abc123"
ok := xstring.IsLetter(s)
fmt.Println("IsLetter:", ok)
Check string is a number
s := "12345.67"
ok := xstring.IsNumeric(s)
fmt.Println("IsNumeric:", ok)
Expand map value to template string
t := "i am {name}, i have ${money}."
m := map[string]interface{}{"name": "Li Kexian", "money": 100}
s := xstring.Expand(t, m)
fmt.Println(s)

License

Copyright 2012-2024 Li Kexian

Licensed under the Apache License 2.0

Donation

If this project is helpful, please share it with friends.

If you want to thank me, you can give me a cup of coffee.

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func Author

func Author() string

Author returns package author

func Expand

func Expand(s string, m map[string]interface{}) string

Expand replaces {var} of string s based on the value map m For example, Expand("i am {name}", map[string]interface{}{"name": "Li Kexian"})

func IsLetter

func IsLetter(s uint8) bool

IsLetter returns if s is an english letter

func IsLetters

func IsLetters(s string) bool

IsLetters returns if s is all english letter

func IsNumeric

func IsNumeric(s string) bool

IsNumeric returns if s is a number

func Join

func Join(v interface{}, sep string) string

Join concatenates the elements and returns string

func LastInIndex

func LastInIndex(s, f string) int

LastInIndex find last position at first index

for example, LastInIndex("{{{{{{{{{{name}", "{")
                                   ↑

func License

func License() string

License returns package license

func Reverse

func Reverse(s string) string

Reverse returns reversed string

func ToCamel added in v0.24.5

func ToCamel(s string) string

ToCamel returns camel case of string

func ToSnake added in v0.24.5

func ToSnake(s string) string

ToSnake returns snake case of string

func ToString

func ToString(v interface{}) string

ToString convert v to string

func Version

func Version() string

Version returns package version

Types

This section is empty.

Jump to

Keyboard shortcuts

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