mirror of
https://github.com/go-gitea/gitea.git
synced 2024-12-01 23:02:43 +01:00
b6a95a8cb3
* Dropped unused codekit config * Integrated dynamic and static bindata for public * Ignore public bindata * Add a general generate make task * Integrated flexible public assets into web command * Updated vendoring, added all missiong govendor deps * Made the linter happy with the bindata and dynamic code * Moved public bindata definition to modules directory * Ignoring the new bindata path now * Updated to the new public modules import path * Updated public bindata command and drop the new prefix
69 lines
1.3 KiB
Go
69 lines
1.3 KiB
Go
package uuid
|
|
|
|
/****************
|
|
* Date: 1/02/14
|
|
* Time: 10:08 AM
|
|
***************/
|
|
|
|
const (
|
|
variantIndex = 8
|
|
versionIndex = 6
|
|
)
|
|
|
|
// A clean UUID type for simpler UUID versions
|
|
type Array [length]byte
|
|
|
|
func (Array) Size() int {
|
|
return length
|
|
}
|
|
|
|
func (o Array) Version() int {
|
|
return int(o[versionIndex]) >> 4
|
|
}
|
|
|
|
func (o *Array) setVersion(pVersion int) {
|
|
o[versionIndex] &= 0x0F
|
|
o[versionIndex] |= byte(pVersion) << 4
|
|
}
|
|
|
|
func (o *Array) Variant() byte {
|
|
return variant(o[variantIndex])
|
|
}
|
|
|
|
func (o *Array) setVariant(pVariant byte) {
|
|
setVariant(&o[variantIndex], pVariant)
|
|
}
|
|
|
|
func (o *Array) Unmarshal(pData []byte) {
|
|
copy(o[:], pData)
|
|
}
|
|
|
|
func (o *Array) Bytes() []byte {
|
|
return o[:]
|
|
}
|
|
|
|
func (o Array) String() string {
|
|
return formatter(&o, format)
|
|
}
|
|
|
|
func (o Array) Format(pFormat string) string {
|
|
return formatter(&o, pFormat)
|
|
}
|
|
|
|
// Set the three most significant bits (bits 0, 1 and 2) of the
|
|
// sequenceHiAndVariant equivalent in the array to ReservedRFC4122.
|
|
func (o *Array) setRFC4122Variant() {
|
|
o[variantIndex] &= 0x3F
|
|
o[variantIndex] |= ReservedRFC4122
|
|
}
|
|
|
|
// Marshals the UUID bytes into a slice
|
|
func (o *Array) MarshalBinary() ([]byte, error) {
|
|
return o.Bytes(), nil
|
|
}
|
|
|
|
// Un-marshals the data bytes into the UUID.
|
|
func (o *Array) UnmarshalBinary(pData []byte) error {
|
|
return UnmarshalBinary(o, pData)
|
|
}
|