mirror of
https://github.com/stashapp/stash.git
synced 2025-12-18 21:04:37 +03:00
Update go dependencies (#3480)
* Bump golang.org/x/text from 0.3.7 to 0.3.8 Bumps [golang.org/x/text](https://github.com/golang/text) from 0.3.7 to 0.3.8. - [Release notes](https://github.com/golang/text/releases) - [Commits](https://github.com/golang/text/compare/v0.3.7...v0.3.8) --- updated-dependencies: - dependency-name: golang.org/x/text dependency-type: direct:production ... Signed-off-by: dependabot[bot] <support@github.com> * Update go dependencies * Update x/net --------- Signed-off-by: dependabot[bot] <support@github.com> Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com>
This commit is contained in:
25
vendor/github.com/xrash/smetrics/hamming.go
generated
vendored
Normal file
25
vendor/github.com/xrash/smetrics/hamming.go
generated
vendored
Normal file
@@ -0,0 +1,25 @@
|
||||
package smetrics
|
||||
|
||||
import (
|
||||
"fmt"
|
||||
)
|
||||
|
||||
// The Hamming distance is the minimum number of substitutions required to change string A into string B. Both strings must have the same size. If the strings have different sizes, the function returns an error.
|
||||
func Hamming(a, b string) (int, error) {
|
||||
al := len(a)
|
||||
bl := len(b)
|
||||
|
||||
if al != bl {
|
||||
return -1, fmt.Errorf("strings are not equal (len(a)=%d, len(b)=%d)", al, bl)
|
||||
}
|
||||
|
||||
var difference = 0
|
||||
|
||||
for i := range a {
|
||||
if a[i] != b[i] {
|
||||
difference = difference + 1
|
||||
}
|
||||
}
|
||||
|
||||
return difference, nil
|
||||
}
|
||||
Reference in New Issue
Block a user