diff options
Diffstat (limited to 'NOTICE')
-rw-r--r-- | NOTICE | 63 |
1 files changed, 4 insertions, 59 deletions
@@ -2523,40 +2523,22 @@ import ( "crypto/rand" "encoding/hex" "fmt" - "io" ) // GenerateRandomBytes is used to generate random bytes of given size. func GenerateRandomBytes(size int) ([]byte, error) { - return GenerateRandomBytesWithReader(size, rand.Reader) -} - -// GenerateRandomBytesWithReader is used to generate random bytes of given size read from a given reader. -func GenerateRandomBytesWithReader(size int, reader io.Reader) ([]byte, error) { - if reader == nil { - return nil, fmt.Errorf("provided reader is nil") - } buf := make([]byte, size) - if _, err := io.ReadFull(reader, buf); err != nil { + if _, err := rand.Read(buf); err != nil { return nil, fmt.Errorf("failed to read random bytes: %v", err) } return buf, nil } - const uuidLen = 16 // GenerateUUID is used to generate a random UUID func GenerateUUID() (string, error) { - return GenerateUUIDWithReader(rand.Reader) -} - -// GenerateUUIDWithReader is used to generate a random UUID with a given Reader -func GenerateUUIDWithReader(reader io.Reader) (string, error) { - if reader == nil { - return "", fmt.Errorf("provided reader is nil") - } - buf, err := GenerateRandomBytesWithReader(uuidLen, reader) + buf, err := GenerateRandomBytes(uuidLen) if err != nil { return "", err } @@ -2607,7 +2589,6 @@ package uuid import ( "crypto/rand" - "io" "reflect" "regexp" "testing" @@ -2635,36 +2616,6 @@ func TestGenerateUUID(t *testing.T) { } } -func TestGenerateUUIDWithReader(t *testing.T) { - var nilReader io.Reader - str, err := GenerateUUIDWithReader(nilReader) - if err == nil { - t.Fatalf("should get an error with a nilReader") - } - if str != "" { - t.Fatalf("should get an empty string") - } - - prev, err := GenerateUUIDWithReader(rand.Reader) - if err != nil { - t.Fatal(err) - } - - id, err := GenerateUUIDWithReader(rand.Reader) - if err != nil { - t.Fatal(err) - } - if prev == id { - t.Fatalf("Should get a new ID!") - } - - matched, err := regexp.MatchString( - "[\\da-f]{8}-[\\da-f]{4}-[\\da-f]{4}-[\\da-f]{4}-[\\da-f]{12}", id) - if !matched || err != nil { - t.Fatalf("expected match %s %v %s", id, matched, err) - } -} - func TestParseUUID(t *testing.T) { buf := make([]byte, 16) if _, err := rand.Read(buf); err != nil { @@ -2692,12 +2643,6 @@ func BenchmarkGenerateUUID(b *testing.B) { } } -func BenchmarkGenerateUUIDWithReader(b *testing.B) { - for n := 0; n < b.N; n++ { - _, _ = GenerateUUIDWithReader(rand.Reader) - } -} - ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ .gitignore - github.com/hashicorp/golang-lru # Compiled Object files, Static and Dynamic libs (Shared Objects) @@ -11769,7 +11714,7 @@ LICENSE - github.com/uber/jaeger-lib/metrics limitations under the License. ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ -LICENSE - gitlab.com/gitlab-org/gitaly/internal/middleware/panichandler +LICENSE - gitlab.com/gitlab-org/gitaly/v14/internal/middleware/panichandler Copyright (c) 2016 Masahiro Sano MIT License @@ -11794,7 +11739,7 @@ OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ -LICENSE.txt - gitlab.com/gitlab-org/gitaly/internal/praefect/grpc-proxy/proxy +LICENSE.txt - gitlab.com/gitlab-org/gitaly/v14/internal/praefect/grpc-proxy/proxy Apache License Version 2.0, January 2004 http://www.apache.org/licenses/ |