X-Git-Url: https://git.arvados.org/arvados.git/blobdiff_plain/66c19e11db2626bd82eb755ea6552ce5caec69af..46f0c0faf4f032697d59c2d663018ae67d1059d4:/sdk/go/blockdigest/blockdigest.go diff --git a/sdk/go/blockdigest/blockdigest.go b/sdk/go/blockdigest/blockdigest.go index d2f1c60ba9..ecb09964ec 100644 --- a/sdk/go/blockdigest/blockdigest.go +++ b/sdk/go/blockdigest/blockdigest.go @@ -1,19 +1,22 @@ -// Stores a Block Locator Digest compactly. Can be used as a map key. +// Copyright (C) The Arvados Authors. All rights reserved. +// +// SPDX-License-Identifier: Apache-2.0 + +// Package blockdigest stores a Block Locator Digest compactly. Can be used as a map key. package blockdigest import ( "fmt" - "log" "regexp" "strconv" "strings" ) var LocatorPattern = regexp.MustCompile( - "^[0-9a-fA-F]{32}\\+[0-9]+(\\+[A-Z][A-Za-z0-9@_-]+)*$") + "^[0-9a-fA-F]{32}\\+[0-9]+(\\+[A-Z][A-Za-z0-9@_-]*)*$") -// Stores a Block Locator Digest compactly, up to 128 bits. -// Can be used as a map key. +// BlockDigest stores a Block Locator Digest compactly, up to 128 bits. Can be +// used as a map key. type BlockDigest struct { H uint64 L uint64 @@ -38,7 +41,7 @@ func (w DigestWithSize) String() string { return fmt.Sprintf("%s+%d", w.Digest.String(), w.Size) } -// Will create a new BlockDigest unless an error is encountered. +// FromString creates a new BlockDigest unless an error is encountered. func FromString(s string) (dig BlockDigest, err error) { if len(s) != 32 { err = fmt.Errorf("Block digest should be exactly 32 characters but this one is %d: %s", len(s), s) @@ -58,15 +61,6 @@ func FromString(s string) (dig BlockDigest, err error) { return } -// Will fatal with the error if an error is encountered -func AssertFromString(s string) BlockDigest { - d, err := FromString(s) - if err != nil { - log.Fatalf("Error creating BlockDigest from %s: %v", s, err) - } - return d -} - func IsBlockLocator(s string) bool { return LocatorPattern.MatchString(s) }