From 587ac99d26a026c4441ce224f52105d2dbd3751b Mon Sep 17 00:00:00 2001 From: Stefan Majewsky Date: Sun, 19 Apr 2026 00:53:33 +0200 Subject: run `go fix ./...` --- object.go | 15 +++------------ 1 file changed, 3 insertions(+), 12 deletions(-) (limited to 'object.go') diff --git a/object.go b/object.go index 28c33da..223c1a3 100644 --- a/object.go +++ b/object.go @@ -32,6 +32,7 @@ import ( "io" "net/http" "net/url" + "slices" "strings" "time" ) @@ -617,16 +618,6 @@ func (o *Object) URL() (string, error) { }.URL(o.c.a.backend, nil) } -// Returns true if string is contained in slice -func contains(s []string, e string) bool { - for _, a := range s { - if a == e { - return true - } - } - return false -} - // TempURL is like Object.URL, but includes a token with a limited lifetime (as // specified by the `expires` argument) that permits anonymous access to this // object using the given HTTP method. This works only when the tempurl @@ -671,9 +662,9 @@ func (o *Object) TempURL(ctx context.Context, key, method string, expires time.T var mac hash.Hash switch { - case contains(allowedDigest, "sha256"): + case slices.Contains(allowedDigest, "sha256"): mac = hmac.New(sha256.New, []byte(key)) - case contains(allowedDigest, "sha1"): + case slices.Contains(allowedDigest, "sha1"): mac = hmac.New(sha1.New, []byte(key)) default: return "", fmt.Errorf("schwift supports sha1 and sha256 digests but the Swift server only supports: %s", strings.Join(allowedDigest, ", ")) -- cgit v1.2.3