doc: add go playground demo

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

No files matched your search

+2 -2
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")