diff options
author | Yuri Tkachenko <yuri.tam.tkachenko@gmail.com> | 2015-11-30 12:15:28 +0300 |
---|---|---|
committer | Yuri Tkachenko <yuri.tam.tkachenko@gmail.com> | 2015-11-30 12:15:28 +0300 |
commit | 8b982f7effa336a503ab61c676ee0f2473de6e3b (patch) | |
tree | ecd49a12e3cb9e4bff398057df01d44eade70da4 /Godeps/_workspace/src/github.com/pborman/uuid/util.go | |
parent | 71b548ef052d4e84ea0d067df51e4850ffdba572 (diff) | |
parent | d4eb8743e3bd36b6cd2e7939c9a698d893b215d7 (diff) | |
download | chat-8b982f7effa336a503ab61c676ee0f2473de6e3b.tar.gz chat-8b982f7effa336a503ab61c676ee0f2473de6e3b.tar.bz2 chat-8b982f7effa336a503ab61c676ee0f2473de6e3b.zip |
Merge remote-tracking branch 'mattermost/master' into patch-1
Diffstat (limited to 'Godeps/_workspace/src/github.com/pborman/uuid/util.go')
-rw-r--r-- | Godeps/_workspace/src/github.com/pborman/uuid/util.go | 43 |
1 files changed, 43 insertions, 0 deletions
diff --git a/Godeps/_workspace/src/github.com/pborman/uuid/util.go b/Godeps/_workspace/src/github.com/pborman/uuid/util.go new file mode 100644 index 000000000..de40b102c --- /dev/null +++ b/Godeps/_workspace/src/github.com/pborman/uuid/util.go @@ -0,0 +1,43 @@ +// Copyright 2011 Google Inc. All rights reserved. +// Use of this source code is governed by a BSD-style +// license that can be found in the LICENSE file. + +package uuid + +import ( + "io" +) + +// randomBits completely fills slice b with random data. +func randomBits(b []byte) { + if _, err := io.ReadFull(rander, b); err != nil { + panic(err.Error()) // rand should never fail + } +} + +// xvalues returns the value of a byte as a hexadecimal digit or 255. +var xvalues = []byte{ + 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, + 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, + 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, + 0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 255, 255, 255, 255, 255, 255, + 255, 10, 11, 12, 13, 14, 15, 255, 255, 255, 255, 255, 255, 255, 255, 255, + 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, + 255, 10, 11, 12, 13, 14, 15, 255, 255, 255, 255, 255, 255, 255, 255, 255, + 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, + 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, + 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, + 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, + 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, + 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, + 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, + 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, + 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, +} + +// xtob converts the the first two hex bytes of x into a byte. +func xtob(x string) (byte, bool) { + b1 := xvalues[x[0]] + b2 := xvalues[x[1]] + return (b1 << 4) | b2, b1 != 255 && b2 != 255 +} |