1
0
mirror of https://github.com/duke-git/lancet.git synced 2026-02-04 12:52:28 +08:00

doc: add go playground demo

This commit is contained in:
dudaodong
2024-03-06 14:52:35 +08:00
parent 036847577d
commit 1b31014f81
14 changed files with 86 additions and 56 deletions

View File

@@ -585,7 +585,7 @@ func RemoveWhiteSpace(str string, repalceAll bool) string {
}
// SubInBetween return substring between the start and end position(excluded) of source string.
// Play: todo
// Play: https://go.dev/play/p/EDbaRvjeNsv
func SubInBetween(str string, start string, end string) string {
if _, after, ok := strings.Cut(str, start); ok {
if before, _, ok := strings.Cut(after, end); ok {
@@ -599,7 +599,7 @@ func SubInBetween(str string, start string, end string) string {
// HammingDistance calculates the Hamming distance between two strings.
// The Hamming distance is the number of positions at which the corresponding symbols are different.
// This func returns an error if the input strings are of unequal lengths.
// Play: todo
// Play: https://go.dev/play/p/glNdQEA9HUi
func HammingDistance(a, b string) (int, error) {
if len(a) != len(b) {
return -1, errors.New("a length and b length are unequal")