loveckiy.ivan
3 weeks ago
374 changed files with 4710 additions and 5528 deletions
@ -1,184 +0,0 @@ |
|||
package lib |
|||
|
|||
import ( |
|||
"fmt" |
|||
"sync" |
|||
"time" |
|||
|
|||
"github.com/ReneKroon/ttlcache" |
|||
|
|||
"github.com/pkg/errors" |
|||
) |
|||
|
|||
const cacheKeyPrefix = "cache." |
|||
|
|||
var ( |
|||
cacheCollection cache |
|||
) |
|||
|
|||
type cache struct { |
|||
items map[string]*cacheItem |
|||
mx sync.RWMutex |
|||
} |
|||
|
|||
type cacheItem struct { |
|||
// Getter определяет механизм получения данных от любого источника к/р поддерживает интерфейс
|
|||
reader Reader |
|||
cache *ttlcache.Cache |
|||
persistentCache *ttlcache.Cache |
|||
locks locks |
|||
cacheTTL time.Duration |
|||
} |
|||
|
|||
type Reader interface { |
|||
ReadSource() (res []byte, err error) |
|||
} |
|||
|
|||
func Cache() *cache { |
|||
if &cacheCollection == nil { |
|||
panic("cache has not been initialized, call CacheRegister() before use") |
|||
} |
|||
|
|||
return &cacheCollection |
|||
} |
|||
|
|||
// Register регистрируем новый кеш (указываем фукнцию, кр будет возвращать нужное значение)
|
|||
func (c *cache) Register(key string, source Reader, ttl time.Duration) (err error) { |
|||
c.mx.Lock() |
|||
defer c.mx.Unlock() |
|||
|
|||
cache := ttlcache.NewCache() |
|||
cache.SkipTtlExtensionOnHit(true) |
|||
|
|||
ci := cacheItem{ |
|||
cache: cache, |
|||
persistentCache: ttlcache.NewCache(), |
|||
locks: locks{keys: map[string]bool{}}, |
|||
reader: source, |
|||
cacheTTL: ttl, |
|||
} |
|||
c.items[key] = &ci |
|||
return err |
|||
} |
|||
|
|||
// Unregister
|
|||
func (c *cache) Unregister(key string) (err error) { |
|||
c.mx.Lock() |
|||
defer c.mx.Unlock() |
|||
|
|||
delete(c.items, key) |
|||
return err |
|||
} |
|||
|
|||
// Get возвращает текущее значение параметра в сервисе keeper.
|
|||
// Нужно учитывать, что значения на время кешируются и обновляются с заданной периодичностью.
|
|||
func (c *cache) Get(key string) (value interface{}, err error) { |
|||
var item *cacheItem |
|||
var found bool |
|||
|
|||
item, found = c.items[key] |
|||
if !found { |
|||
return nil, fmt.Errorf("error. key is not found") |
|||
} |
|||
|
|||
if item.cache == nil { |
|||
return nil, fmt.Errorf("cache is not inited") |
|||
} |
|||
|
|||
if item.persistentCache == nil { |
|||
return nil, fmt.Errorf("persistent cache is not inited") |
|||
} |
|||
|
|||
if cachedValue, ok := item.cache.Get(cacheKeyPrefix + key); ok { |
|||
return cachedValue, nil |
|||
} |
|||
|
|||
// Если стоит блокировка, значит кто-то уже обновляет кеш. В этом случае
|
|||
// пытаемся отдать предыдущее значение.
|
|||
if item.locks.Get(key) { |
|||
return c.tryToGetOldValue(key) |
|||
} |
|||
|
|||
// Значение не найдено. Первый из запросов блокирует за собой обновление (на самом деле
|
|||
// может возникнуть ситуация когда несколько запросов поставят блокировку и начнут
|
|||
// обновлять кеш - пока считаем это некритичным).
|
|||
item.locks.Set(key, true) |
|||
defer item.locks.Set(key, false) |
|||
|
|||
var values []byte |
|||
values, err = item.reader.ReadSource() |
|||
if err != nil { |
|||
return nil, errors.Wrap(err, "could not get value from getter") |
|||
} |
|||
|
|||
value = values |
|||
|
|||
item.cache.SetWithTTL(cacheKeyPrefix+key, value, item.cacheTTL) |
|||
item.persistentCache.Set(cacheKeyPrefix+key, value) |
|||
|
|||
return value, nil |
|||
} |
|||
|
|||
// tryToGetOldValue пытается получить старое значение, если в момент запроса на актуальном стоит блокировка.
|
|||
func (c *cache) tryToGetOldValue(key string) (interface{}, error) { |
|||
var item *cacheItem |
|||
var found bool |
|||
|
|||
item, found = c.items[key] |
|||
if !found { |
|||
return nil, fmt.Errorf("error. key is not found") |
|||
} |
|||
|
|||
fnGetPersistentCacheValue := func() (interface{}, error) { |
|||
if cachedValue, ok := item.persistentCache.Get(cacheKeyPrefix + key); ok { |
|||
return cachedValue, nil |
|||
} |
|||
|
|||
return nil, fmt.Errorf("persinstent cache is empty") |
|||
} |
|||
|
|||
oldValue, err := fnGetPersistentCacheValue() |
|||
|
|||
// Повторяем попытку получить значение. При старте сервиса может возникнуть блокировка
|
|||
// обновления ключа, но при этом в постоянном кеше еще может не быть значения.
|
|||
if err != nil { |
|||
time.Sleep(100 * time.Millisecond) |
|||
|
|||
oldValue, err = fnGetPersistentCacheValue() |
|||
} |
|||
|
|||
return oldValue, err |
|||
} |
|||
|
|||
// CacheInit инициализировали глобальную переменную defaultCache
|
|||
// source - источник, откуда мы получаем значения для кеширования
|
|||
func CacheRegister() { |
|||
d := cache{ |
|||
items: map[string]*cacheItem{}, |
|||
mx: sync.RWMutex{}, |
|||
} |
|||
cacheCollection = d |
|||
} |
|||
|
|||
// locks выполняет функции блокировки при одновременном обновлении значений в кеше.
|
|||
type locks struct { |
|||
// keys хранит информацию о локах по каждому отдельному ключу.
|
|||
// Если значение установлено в true, в данный момент обновление кеша захвачено одной из горутин.
|
|||
keys map[string]bool |
|||
mx sync.RWMutex |
|||
} |
|||
|
|||
// Get возвращает информацию о том идет ли в данный момент обновление конкретного ключа.
|
|||
func (l *locks) Get(key string) bool { |
|||
l.mx.RLock() |
|||
defer l.mx.RUnlock() |
|||
|
|||
return l.keys[key] |
|||
} |
|||
|
|||
// Set устанавливает блокировку на обновление конкретного ключа другими горутинами.
|
|||
func (l *locks) Set(key string, value bool) { |
|||
l.mx.Lock() |
|||
l.keys[key] = value |
|||
l.mx.Unlock() |
|||
} |
@ -1,23 +0,0 @@ |
|||
language: go |
|||
sudo: false |
|||
go: |
|||
- 1.2 |
|||
- 1.3 |
|||
- 1.4 |
|||
- 1.5 |
|||
- 1.6 |
|||
- 1.7 |
|||
- 1.8 |
|||
- 1.9 |
|||
- tip |
|||
matrix: |
|||
allow_failures: |
|||
- go: tip |
|||
fast_finish: true |
|||
before_install: |
|||
- go get github.com/mattn/goveralls |
|||
- go get golang.org/x/tools/cmd/cover |
|||
script: |
|||
- $HOME/gopath/bin/goveralls -service=travis-ci |
|||
notifications: |
|||
email: false |
@ -1,20 +0,0 @@ |
|||
Copyright (C) 2013-2018 by Maxim Bublis <b@codemonkey.ru> |
|||
|
|||
Permission is hereby granted, free of charge, to any person obtaining |
|||
a copy of this software and associated documentation files (the |
|||
"Software"), to deal in the Software without restriction, including |
|||
without limitation the rights to use, copy, modify, merge, publish, |
|||
distribute, sublicense, and/or sell copies of the Software, and to |
|||
permit persons to whom the Software is furnished to do so, subject to |
|||
the following conditions: |
|||
|
|||
The above copyright notice and this permission notice shall be |
|||
included in all copies or substantial portions of the Software. |
|||
|
|||
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, |
|||
EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF |
|||
MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND |
|||
NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE |
|||
LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION |
|||
OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION |
|||
WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. |
@ -1,65 +0,0 @@ |
|||
# UUID package for Go language |
|||
|
|||
[![Build Status](https://travis-ci.org/satori/go.uuid.png?branch=master)](https://travis-ci.org/satori/go.uuid) |
|||
[![Coverage Status](https://coveralls.io/repos/github/satori/go.uuid/badge.svg?branch=master)](https://coveralls.io/github/satori/go.uuid) |
|||
[![GoDoc](http://godoc.org/github.com/satori/go.uuid?status.png)](http://godoc.org/github.com/satori/go.uuid) |
|||
|
|||
This package provides pure Go implementation of Universally Unique Identifier (UUID). Supported both creation and parsing of UUIDs. |
|||
|
|||
With 100% test coverage and benchmarks out of box. |
|||
|
|||
Supported versions: |
|||
* Version 1, based on timestamp and MAC address (RFC 4122) |
|||
* Version 2, based on timestamp, MAC address and POSIX UID/GID (DCE 1.1) |
|||
* Version 3, based on MD5 hashing (RFC 4122) |
|||
* Version 4, based on random numbers (RFC 4122) |
|||
* Version 5, based on SHA-1 hashing (RFC 4122) |
|||
|
|||
## Installation |
|||
|
|||
Use the `go` command: |
|||
|
|||
$ go get github.com/satori/go.uuid |
|||
|
|||
## Requirements |
|||
|
|||
UUID package requires Go >= 1.2. |
|||
|
|||
## Example |
|||
|
|||
```go |
|||
package main |
|||
|
|||
import ( |
|||
"fmt" |
|||
"github.com/satori/go.uuid" |
|||
) |
|||
|
|||
func main() { |
|||
// Creating UUID Version 4 |
|||
u1 := uuid.NewV4() |
|||
fmt.Printf("UUIDv4: %s\n", u1) |
|||
|
|||
// Parsing UUID from string input |
|||
u2, err := uuid.FromString("6ba7b810-9dad-11d1-80b4-00c04fd430c8") |
|||
if err != nil { |
|||
fmt.Printf("Something gone wrong: %s", err) |
|||
} |
|||
fmt.Printf("Successfully parsed: %s", u2) |
|||
} |
|||
``` |
|||
|
|||
## Documentation |
|||
|
|||
[Documentation](http://godoc.org/github.com/satori/go.uuid) is hosted at GoDoc project. |
|||
|
|||
## Links |
|||
* [RFC 4122](http://tools.ietf.org/html/rfc4122) |
|||
* [DCE 1.1: Authentication and Security Services](http://pubs.opengroup.org/onlinepubs/9696989899/chap5.htm#tagcjh_08_02_01_01) |
|||
|
|||
## Copyright |
|||
|
|||
Copyright (C) 2013-2018 by Maxim Bublis <b@codemonkey.ru>. |
|||
|
|||
UUID package released under MIT License. |
|||
See [LICENSE](https://github.com/satori/go.uuid/blob/master/LICENSE) for details. |
@ -1,206 +0,0 @@ |
|||
// Copyright (C) 2013-2018 by Maxim Bublis <b@codemonkey.ru>
|
|||
//
|
|||
// Permission is hereby granted, free of charge, to any person obtaining
|
|||
// a copy of this software and associated documentation files (the
|
|||
// "Software"), to deal in the Software without restriction, including
|
|||
// without limitation the rights to use, copy, modify, merge, publish,
|
|||
// distribute, sublicense, and/or sell copies of the Software, and to
|
|||
// permit persons to whom the Software is furnished to do so, subject to
|
|||
// the following conditions:
|
|||
//
|
|||
// The above copyright notice and this permission notice shall be
|
|||
// included in all copies or substantial portions of the Software.
|
|||
//
|
|||
// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
|
|||
// EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
|
|||
// MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
|
|||
// NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
|
|||
// LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
|
|||
// OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
|
|||
// WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
|||
|
|||
package uuid |
|||
|
|||
import ( |
|||
"bytes" |
|||
"encoding/hex" |
|||
"fmt" |
|||
) |
|||
|
|||
// FromBytes returns UUID converted from raw byte slice input.
|
|||
// It will return error if the slice isn't 16 bytes long.
|
|||
func FromBytes(input []byte) (u UUID, err error) { |
|||
err = u.UnmarshalBinary(input) |
|||
return |
|||
} |
|||
|
|||
// FromBytesOrNil returns UUID converted from raw byte slice input.
|
|||
// Same behavior as FromBytes, but returns a Nil UUID on error.
|
|||
func FromBytesOrNil(input []byte) UUID { |
|||
uuid, err := FromBytes(input) |
|||
if err != nil { |
|||
return Nil |
|||
} |
|||
return uuid |
|||
} |
|||
|
|||
// FromString returns UUID parsed from string input.
|
|||
// Input is expected in a form accepted by UnmarshalText.
|
|||
func FromString(input string) (u UUID, err error) { |
|||
err = u.UnmarshalText([]byte(input)) |
|||
return |
|||
} |
|||
|
|||
// FromStringOrNil returns UUID parsed from string input.
|
|||
// Same behavior as FromString, but returns a Nil UUID on error.
|
|||
func FromStringOrNil(input string) UUID { |
|||
uuid, err := FromString(input) |
|||
if err != nil { |
|||
return Nil |
|||
} |
|||
return uuid |
|||
} |
|||
|
|||
// MarshalText implements the encoding.TextMarshaler interface.
|
|||
// The encoding is the same as returned by String.
|
|||
func (u UUID) MarshalText() (text []byte, err error) { |
|||
text = []byte(u.String()) |
|||
return |
|||
} |
|||
|
|||
// UnmarshalText implements the encoding.TextUnmarshaler interface.
|
|||
// Following formats are supported:
|
|||
// "6ba7b810-9dad-11d1-80b4-00c04fd430c8",
|
|||
// "{6ba7b810-9dad-11d1-80b4-00c04fd430c8}",
|
|||
// "urn:uuid:6ba7b810-9dad-11d1-80b4-00c04fd430c8"
|
|||
// "6ba7b8109dad11d180b400c04fd430c8"
|
|||
// ABNF for supported UUID text representation follows:
|
|||
// uuid := canonical | hashlike | braced | urn
|
|||
// plain := canonical | hashlike
|
|||
// canonical := 4hexoct '-' 2hexoct '-' 2hexoct '-' 6hexoct
|
|||
// hashlike := 12hexoct
|
|||
// braced := '{' plain '}'
|
|||
// urn := URN ':' UUID-NID ':' plain
|
|||
// URN := 'urn'
|
|||
// UUID-NID := 'uuid'
|
|||
// 12hexoct := 6hexoct 6hexoct
|
|||
// 6hexoct := 4hexoct 2hexoct
|
|||
// 4hexoct := 2hexoct 2hexoct
|
|||
// 2hexoct := hexoct hexoct
|
|||
// hexoct := hexdig hexdig
|
|||
// hexdig := '0' | '1' | '2' | '3' | '4' | '5' | '6' | '7' | '8' | '9' |
|
|||
// 'a' | 'b' | 'c' | 'd' | 'e' | 'f' |
|
|||
// 'A' | 'B' | 'C' | 'D' | 'E' | 'F'
|
|||
func (u *UUID) UnmarshalText(text []byte) (err error) { |
|||
switch len(text) { |
|||
case 32: |
|||
return u.decodeHashLike(text) |
|||
case 36: |
|||
return u.decodeCanonical(text) |
|||
case 38: |
|||
return u.decodeBraced(text) |
|||
case 41: |
|||
fallthrough |
|||
case 45: |
|||
return u.decodeURN(text) |
|||
default: |
|||
return fmt.Errorf("uuid: incorrect UUID length: %s", text) |
|||
} |
|||
} |
|||
|
|||
// decodeCanonical decodes UUID string in format
|
|||
// "6ba7b810-9dad-11d1-80b4-00c04fd430c8".
|
|||
func (u *UUID) decodeCanonical(t []byte) (err error) { |
|||
if t[8] != '-' || t[13] != '-' || t[18] != '-' || t[23] != '-' { |
|||
return fmt.Errorf("uuid: incorrect UUID format %s", t) |
|||
} |
|||
|
|||
src := t[:] |
|||
dst := u[:] |
|||
|
|||
for i, byteGroup := range byteGroups { |
|||
if i > 0 { |
|||
src = src[1:] // skip dash
|
|||
} |
|||
_, err = hex.Decode(dst[:byteGroup/2], src[:byteGroup]) |
|||
if err != nil { |
|||
return |
|||
} |
|||
src = src[byteGroup:] |
|||
dst = dst[byteGroup/2:] |
|||
} |
|||
|
|||
return |
|||
} |
|||
|
|||
// decodeHashLike decodes UUID string in format
|
|||
// "6ba7b8109dad11d180b400c04fd430c8".
|
|||
func (u *UUID) decodeHashLike(t []byte) (err error) { |
|||
src := t[:] |
|||
dst := u[:] |
|||
|
|||
if _, err = hex.Decode(dst, src); err != nil { |
|||
return err |
|||
} |
|||
return |
|||
} |
|||
|
|||
// decodeBraced decodes UUID string in format
|
|||
// "{6ba7b810-9dad-11d1-80b4-00c04fd430c8}" or in format
|
|||
// "{6ba7b8109dad11d180b400c04fd430c8}".
|
|||
func (u *UUID) decodeBraced(t []byte) (err error) { |
|||
l := len(t) |
|||
|
|||
if t[0] != '{' || t[l-1] != '}' { |
|||
return fmt.Errorf("uuid: incorrect UUID format %s", t) |
|||
} |
|||
|
|||
return u.decodePlain(t[1 : l-1]) |
|||
} |
|||
|
|||
// decodeURN decodes UUID string in format
|
|||
// "urn:uuid:6ba7b810-9dad-11d1-80b4-00c04fd430c8" or in format
|
|||
// "urn:uuid:6ba7b8109dad11d180b400c04fd430c8".
|
|||
func (u *UUID) decodeURN(t []byte) (err error) { |
|||
total := len(t) |
|||
|
|||
urn_uuid_prefix := t[:9] |
|||
|
|||
if !bytes.Equal(urn_uuid_prefix, urnPrefix) { |
|||
return fmt.Errorf("uuid: incorrect UUID format: %s", t) |
|||
} |
|||
|
|||
return u.decodePlain(t[9:total]) |
|||
} |
|||
|
|||
// decodePlain decodes UUID string in canonical format
|
|||
// "6ba7b810-9dad-11d1-80b4-00c04fd430c8" or in hash-like format
|
|||
// "6ba7b8109dad11d180b400c04fd430c8".
|
|||
func (u *UUID) decodePlain(t []byte) (err error) { |
|||
switch len(t) { |
|||
case 32: |
|||
return u.decodeHashLike(t) |
|||
case 36: |
|||
return u.decodeCanonical(t) |
|||
default: |
|||
return fmt.Errorf("uuid: incorrrect UUID length: %s", t) |
|||
} |
|||
} |
|||
|
|||
// MarshalBinary implements the encoding.BinaryMarshaler interface.
|
|||
func (u UUID) MarshalBinary() (data []byte, err error) { |
|||
data = u.Bytes() |
|||
return |
|||
} |
|||
|
|||
// UnmarshalBinary implements the encoding.BinaryUnmarshaler interface.
|
|||
// It will return error if the slice isn't 16 bytes long.
|
|||
func (u *UUID) UnmarshalBinary(data []byte) (err error) { |
|||
if len(data) != Size { |
|||
err = fmt.Errorf("uuid: UUID must be exactly 16 bytes long, got %d bytes", len(data)) |
|||
return |
|||
} |
|||
copy(u[:], data) |
|||
|
|||
return |
|||
} |
@ -1,239 +0,0 @@ |
|||
// Copyright (C) 2013-2018 by Maxim Bublis <b@codemonkey.ru>
|
|||
//
|
|||
// Permission is hereby granted, free of charge, to any person obtaining
|
|||
// a copy of this software and associated documentation files (the
|
|||
// "Software"), to deal in the Software without restriction, including
|
|||
// without limitation the rights to use, copy, modify, merge, publish,
|
|||
// distribute, sublicense, and/or sell copies of the Software, and to
|
|||
// permit persons to whom the Software is furnished to do so, subject to
|
|||
// the following conditions:
|
|||
//
|
|||
// The above copyright notice and this permission notice shall be
|
|||
// included in all copies or substantial portions of the Software.
|
|||
//
|
|||
// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
|
|||
// EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
|
|||
// MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
|
|||
// NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
|
|||
// LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
|
|||
// OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
|
|||
// WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
|||
|
|||
package uuid |
|||
|
|||
import ( |
|||
"crypto/md5" |
|||
"crypto/rand" |
|||
"crypto/sha1" |
|||
"encoding/binary" |
|||
"hash" |
|||
"net" |
|||
"os" |
|||
"sync" |
|||
"time" |
|||
) |
|||
|
|||
// Difference in 100-nanosecond intervals between
|
|||
// UUID epoch (October 15, 1582) and Unix epoch (January 1, 1970).
|
|||
const epochStart = 122192928000000000 |
|||
|
|||
var ( |
|||
global = newDefaultGenerator() |
|||
|
|||
epochFunc = unixTimeFunc |
|||
posixUID = uint32(os.Getuid()) |
|||
posixGID = uint32(os.Getgid()) |
|||
) |
|||
|
|||
// NewV1 returns UUID based on current timestamp and MAC address.
|
|||
func NewV1() UUID { |
|||
return global.NewV1() |
|||
} |
|||
|
|||
// NewV2 returns DCE Security UUID based on POSIX UID/GID.
|
|||
func NewV2(domain byte) UUID { |
|||
return global.NewV2(domain) |
|||
} |
|||
|
|||
// NewV3 returns UUID based on MD5 hash of namespace UUID and name.
|
|||
func NewV3(ns UUID, name string) UUID { |
|||
return global.NewV3(ns, name) |
|||
} |
|||
|
|||
// NewV4 returns random generated UUID.
|
|||
func NewV4() UUID { |
|||
return global.NewV4() |
|||
} |
|||
|
|||
// NewV5 returns UUID based on SHA-1 hash of namespace UUID and name.
|
|||
func NewV5(ns UUID, name string) UUID { |
|||
return global.NewV5(ns, name) |
|||
} |
|||
|
|||
// Generator provides interface for generating UUIDs.
|
|||
type Generator interface { |
|||
NewV1() UUID |
|||
NewV2(domain byte) UUID |
|||
NewV3(ns UUID, name string) UUID |
|||
NewV4() UUID |
|||
NewV5(ns UUID, name string) UUID |
|||
} |
|||
|
|||
// Default generator implementation.
|
|||
type generator struct { |
|||
storageOnce sync.Once |
|||
storageMutex sync.Mutex |
|||
|
|||
lastTime uint64 |
|||
clockSequence uint16 |
|||
hardwareAddr [6]byte |
|||
} |
|||
|
|||
func newDefaultGenerator() Generator { |
|||
return &generator{} |
|||
} |
|||
|
|||
// NewV1 returns UUID based on current timestamp and MAC address.
|
|||
func (g *generator) NewV1() UUID { |
|||
u := UUID{} |
|||
|
|||
timeNow, clockSeq, hardwareAddr := g.getStorage() |
|||
|
|||
binary.BigEndian.PutUint32(u[0:], uint32(timeNow)) |
|||
binary.BigEndian.PutUint16(u[4:], uint16(timeNow>>32)) |
|||
binary.BigEndian.PutUint16(u[6:], uint16(timeNow>>48)) |
|||
binary.BigEndian.PutUint16(u[8:], clockSeq) |
|||
|
|||
copy(u[10:], hardwareAddr) |
|||
|
|||
u.SetVersion(V1) |
|||
u.SetVariant(VariantRFC4122) |
|||
|
|||
return u |
|||
} |
|||
|
|||
// NewV2 returns DCE Security UUID based on POSIX UID/GID.
|
|||
func (g *generator) NewV2(domain byte) UUID { |
|||
u := UUID{} |
|||
|
|||
timeNow, clockSeq, hardwareAddr := g.getStorage() |
|||
|
|||
switch domain { |
|||
case DomainPerson: |
|||
binary.BigEndian.PutUint32(u[0:], posixUID) |
|||
case DomainGroup: |
|||
binary.BigEndian.PutUint32(u[0:], posixGID) |
|||
} |
|||
|
|||
binary.BigEndian.PutUint16(u[4:], uint16(timeNow>>32)) |
|||
binary.BigEndian.PutUint16(u[6:], uint16(timeNow>>48)) |
|||
binary.BigEndian.PutUint16(u[8:], clockSeq) |
|||
u[9] = domain |
|||
|
|||
copy(u[10:], hardwareAddr) |
|||
|
|||
u.SetVersion(V2) |
|||
u.SetVariant(VariantRFC4122) |
|||
|
|||
return u |
|||
} |
|||
|
|||
// NewV3 returns UUID based on MD5 hash of namespace UUID and name.
|
|||
func (g *generator) NewV3(ns UUID, name string) UUID { |
|||
u := newFromHash(md5.New(), ns, name) |
|||
u.SetVersion(V3) |
|||
u.SetVariant(VariantRFC4122) |
|||
|
|||
return u |
|||
} |
|||
|
|||
// NewV4 returns random generated UUID.
|
|||
func (g *generator) NewV4() UUID { |
|||
u := UUID{} |
|||
g.safeRandom(u[:]) |
|||
u.SetVersion(V4) |
|||
u.SetVariant(VariantRFC4122) |
|||
|
|||
return u |
|||
} |
|||
|
|||
// NewV5 returns UUID based on SHA-1 hash of namespace UUID and name.
|
|||
func (g *generator) NewV5(ns UUID, name string) UUID { |
|||
u := newFromHash(sha1.New(), ns, name) |
|||
u.SetVersion(V5) |
|||
u.SetVariant(VariantRFC4122) |
|||
|
|||
return u |
|||
} |
|||
|
|||
func (g *generator) initStorage() { |
|||
g.initClockSequence() |
|||
g.initHardwareAddr() |
|||
} |
|||
|
|||
func (g *generator) initClockSequence() { |
|||
buf := make([]byte, 2) |
|||
g.safeRandom(buf) |
|||
g.clockSequence = binary.BigEndian.Uint16(buf) |
|||
} |
|||
|
|||
func (g *generator) initHardwareAddr() { |
|||
interfaces, err := net.Interfaces() |
|||
if err == nil { |
|||
for _, iface := range interfaces { |
|||
if len(iface.HardwareAddr) >= 6 { |
|||
copy(g.hardwareAddr[:], iface.HardwareAddr) |
|||
return |
|||
} |
|||
} |
|||
} |
|||
|
|||
// Initialize hardwareAddr randomly in case
|
|||
// of real network interfaces absence
|
|||
g.safeRandom(g.hardwareAddr[:]) |
|||
|
|||
// Set multicast bit as recommended in RFC 4122
|
|||
g.hardwareAddr[0] |= 0x01 |
|||
} |
|||
|
|||
func (g *generator) safeRandom(dest []byte) { |
|||
if _, err := rand.Read(dest); err != nil { |
|||
panic(err) |
|||
} |
|||
} |
|||
|
|||
// Returns UUID v1/v2 storage state.
|
|||
// Returns epoch timestamp, clock sequence, and hardware address.
|
|||
func (g *generator) getStorage() (uint64, uint16, []byte) { |
|||
g.storageOnce.Do(g.initStorage) |
|||
|
|||
g.storageMutex.Lock() |
|||
defer g.storageMutex.Unlock() |
|||
|
|||
timeNow := epochFunc() |
|||
// Clock changed backwards since last UUID generation.
|
|||
// Should increase clock sequence.
|
|||
if timeNow <= g.lastTime { |
|||
g.clockSequence++ |
|||
} |
|||
g.lastTime = timeNow |
|||
|
|||
return timeNow, g.clockSequence, g.hardwareAddr[:] |
|||
} |
|||
|
|||
// Returns difference in 100-nanosecond intervals between
|
|||
// UUID epoch (October 15, 1582) and current time.
|
|||
// This is default epoch calculation function.
|
|||
func unixTimeFunc() uint64 { |
|||
return epochStart + uint64(time.Now().UnixNano()/100) |
|||
} |
|||
|
|||
// Returns UUID based on hashing of namespace UUID and name.
|
|||
func newFromHash(h hash.Hash, ns UUID, name string) UUID { |
|||
u := UUID{} |
|||
h.Write(ns[:]) |
|||
h.Write([]byte(name)) |
|||
copy(u[:], h.Sum(nil)) |
|||
|
|||
return u |
|||
} |
@ -1,78 +0,0 @@ |
|||
// Copyright (C) 2013-2018 by Maxim Bublis <b@codemonkey.ru>
|
|||
//
|
|||
// Permission is hereby granted, free of charge, to any person obtaining
|
|||
// a copy of this software and associated documentation files (the
|
|||
// "Software"), to deal in the Software without restriction, including
|
|||
// without limitation the rights to use, copy, modify, merge, publish,
|
|||
// distribute, sublicense, and/or sell copies of the Software, and to
|
|||
// permit persons to whom the Software is furnished to do so, subject to
|
|||
// the following conditions:
|
|||
//
|
|||
// The above copyright notice and this permission notice shall be
|
|||
// included in all copies or substantial portions of the Software.
|
|||
//
|
|||
// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
|
|||
// EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
|
|||
// MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
|
|||
// NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
|
|||
// LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
|
|||
// OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
|
|||
// WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
|||
|
|||
package uuid |
|||
|
|||
import ( |
|||
"database/sql/driver" |
|||
"fmt" |
|||
) |
|||
|
|||
// Value implements the driver.Valuer interface.
|
|||
func (u UUID) Value() (driver.Value, error) { |
|||
return u.String(), nil |
|||
} |
|||
|
|||
// Scan implements the sql.Scanner interface.
|
|||
// A 16-byte slice is handled by UnmarshalBinary, while
|
|||
// a longer byte slice or a string is handled by UnmarshalText.
|
|||
func (u *UUID) Scan(src interface{}) error { |
|||
switch src := src.(type) { |
|||
case []byte: |
|||
if len(src) == Size { |
|||
return u.UnmarshalBinary(src) |
|||
} |
|||
return u.UnmarshalText(src) |
|||
|
|||
case string: |
|||
return u.UnmarshalText([]byte(src)) |
|||
} |
|||
|
|||
return fmt.Errorf("uuid: cannot convert %T to UUID", src) |
|||
} |
|||
|
|||
// NullUUID can be used with the standard sql package to represent a
|
|||
// UUID value that can be NULL in the database
|
|||
type NullUUID struct { |
|||
UUID UUID |
|||
Valid bool |
|||
} |
|||
|
|||
// Value implements the driver.Valuer interface.
|
|||
func (u NullUUID) Value() (driver.Value, error) { |
|||
if !u.Valid { |
|||
return nil, nil |
|||
} |
|||
// Delegate to UUID Value function
|
|||
return u.UUID.Value() |
|||
} |
|||
|
|||
// Scan implements the sql.Scanner interface.
|
|||
func (u *NullUUID) Scan(src interface{}) error { |
|||
if src == nil { |
|||
u.UUID, u.Valid = Nil, false |
|||
return nil |
|||
} |
|||
|
|||
// Delegate to UUID Scan function
|
|||
u.Valid = true |
|||
return u.UUID.Scan(src) |
|||
} |
@ -1,161 +0,0 @@ |
|||
// Copyright (C) 2013-2018 by Maxim Bublis <b@codemonkey.ru>
|
|||
//
|
|||
// Permission is hereby granted, free of charge, to any person obtaining
|
|||
// a copy of this software and associated documentation files (the
|
|||
// "Software"), to deal in the Software without restriction, including
|
|||
// without limitation the rights to use, copy, modify, merge, publish,
|
|||
// distribute, sublicense, and/or sell copies of the Software, and to
|
|||
// permit persons to whom the Software is furnished to do so, subject to
|
|||
// the following conditions:
|
|||
//
|
|||
// The above copyright notice and this permission notice shall be
|
|||
// included in all copies or substantial portions of the Software.
|
|||
//
|
|||
// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
|
|||
// EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
|
|||
// MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
|
|||
// NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
|
|||
// LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
|
|||
// OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
|
|||
// WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
|||
|
|||
// Package uuid provides implementation of Universally Unique Identifier (UUID).
|
|||
// Supported versions are 1, 3, 4 and 5 (as specified in RFC 4122) and
|
|||
// version 2 (as specified in DCE 1.1).
|
|||
package uuid |
|||
|
|||
import ( |
|||
"bytes" |
|||
"encoding/hex" |
|||
) |
|||
|
|||
// Size of a UUID in bytes.
|
|||
const Size = 16 |
|||
|
|||
// UUID representation compliant with specification
|
|||
// described in RFC 4122.
|
|||
type UUID [Size]byte |
|||
|
|||
// UUID versions
|
|||
const ( |
|||
_ byte = iota |
|||
V1 |
|||
V2 |
|||
V3 |
|||
V4 |
|||
V5 |
|||
) |
|||
|
|||
// UUID layout variants.
|
|||
const ( |
|||
VariantNCS byte = iota |
|||
VariantRFC4122 |
|||
VariantMicrosoft |
|||
VariantFuture |
|||
) |
|||
|
|||
// UUID DCE domains.
|
|||
const ( |
|||
DomainPerson = iota |
|||
DomainGroup |
|||
DomainOrg |
|||
) |
|||
|
|||
// String parse helpers.
|
|||
var ( |
|||
urnPrefix = []byte("urn:uuid:") |
|||
byteGroups = []int{8, 4, 4, 4, 12} |
|||
) |
|||
|
|||
// Nil is special form of UUID that is specified to have all
|
|||
// 128 bits set to zero.
|
|||
var Nil = UUID{} |
|||
|
|||
// Predefined namespace UUIDs.
|
|||
var ( |
|||
NamespaceDNS = Must(FromString("6ba7b810-9dad-11d1-80b4-00c04fd430c8")) |
|||
NamespaceURL = Must(FromString("6ba7b811-9dad-11d1-80b4-00c04fd430c8")) |
|||
NamespaceOID = Must(FromString("6ba7b812-9dad-11d1-80b4-00c04fd430c8")) |
|||
NamespaceX500 = Must(FromString("6ba7b814-9dad-11d1-80b4-00c04fd430c8")) |
|||
) |
|||
|
|||
// Equal returns true if u1 and u2 equals, otherwise returns false.
|
|||
func Equal(u1 UUID, u2 UUID) bool { |
|||
return bytes.Equal(u1[:], u2[:]) |
|||
} |
|||
|
|||
// Version returns algorithm version used to generate UUID.
|
|||
func (u UUID) Version() byte { |
|||
return u[6] >> 4 |
|||
} |
|||
|
|||
// Variant returns UUID layout variant.
|
|||
func (u UUID) Variant() byte { |
|||
switch { |
|||
case (u[8] >> 7) == 0x00: |
|||
return VariantNCS |
|||
case (u[8] >> 6) == 0x02: |
|||
return VariantRFC4122 |
|||
case (u[8] >> 5) == 0x06: |
|||
return VariantMicrosoft |
|||
case (u[8] >> 5) == 0x07: |
|||
fallthrough |
|||
default: |
|||
return VariantFuture |
|||
} |
|||
} |
|||
|
|||
// Bytes returns bytes slice representation of UUID.
|
|||
func (u UUID) Bytes() []byte { |
|||
return u[:] |
|||
} |
|||
|
|||
// Returns canonical string representation of UUID:
|
|||
// xxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxxx.
|
|||
func (u UUID) String() string { |
|||
buf := make([]byte, 36) |
|||
|
|||
hex.Encode(buf[0:8], u[0:4]) |
|||
buf[8] = '-' |
|||
hex.Encode(buf[9:13], u[4:6]) |
|||
buf[13] = '-' |
|||
hex.Encode(buf[14:18], u[6:8]) |
|||
buf[18] = '-' |
|||
hex.Encode(buf[19:23], u[8:10]) |
|||
buf[23] = '-' |
|||
hex.Encode(buf[24:], u[10:]) |
|||
|
|||
return string(buf) |
|||
} |
|||
|
|||
// SetVersion sets version bits.
|
|||
func (u *UUID) SetVersion(v byte) { |
|||
u[6] = (u[6] & 0x0f) | (v << 4) |
|||
} |
|||
|
|||
// SetVariant sets variant bits.
|
|||
func (u *UUID) SetVariant(v byte) { |
|||
switch v { |
|||
case VariantNCS: |
|||
u[8] = (u[8]&(0xff>>1) | (0x00 << 7)) |
|||
case VariantRFC4122: |
|||
u[8] = (u[8]&(0xff>>2) | (0x02 << 6)) |
|||
case VariantMicrosoft: |
|||
u[8] = (u[8]&(0xff>>3) | (0x06 << 5)) |
|||
case VariantFuture: |
|||
fallthrough |
|||
default: |
|||
u[8] = (u[8]&(0xff>>3) | (0x07 << 5)) |
|||
} |
|||
} |
|||
|
|||
// Must is a helper that wraps a call to a function returning (UUID, error)
|
|||
// and panics if the error is non-nil. It is intended for use in variable
|
|||
// initializations such as
|
|||
// var packageUUID = uuid.Must(uuid.FromString("123e4567-e89b-12d3-a456-426655440000"));
|
|||
func Must(u UUID, err error) UUID { |
|||
if err != nil { |
|||
panic(err) |
|||
} |
|||
return u |
|||
} |
@ -1,51 +0,0 @@ |
|||
# |
|||
# This Dockerfile builds a recent curl with HTTP/2 client support, using |
|||
# a recent nghttp2 build. |
|||
# |
|||
# See the Makefile for how to tag it. If Docker and that image is found, the |
|||
# Go tests use this curl binary for integration tests. |
|||
# |
|||
|
|||
FROM ubuntu:trusty |
|||
|
|||
RUN apt-get update && \ |
|||
apt-get upgrade -y && \ |
|||
apt-get install -y git-core build-essential wget |
|||
|
|||
RUN apt-get install -y --no-install-recommends \ |
|||
autotools-dev libtool pkg-config zlib1g-dev \ |
|||
libcunit1-dev libssl-dev libxml2-dev libevent-dev \ |
|||
automake autoconf |
|||
|
|||
# The list of packages nghttp2 recommends for h2load: |
|||
RUN apt-get install -y --no-install-recommends make binutils \ |
|||
autoconf automake autotools-dev \ |
|||
libtool pkg-config zlib1g-dev libcunit1-dev libssl-dev libxml2-dev \ |
|||
libev-dev libevent-dev libjansson-dev libjemalloc-dev \ |
|||
cython python3.4-dev python-setuptools |
|||
|
|||
# Note: setting NGHTTP2_VER before the git clone, so an old git clone isn't cached: |
|||
ENV NGHTTP2_VER 895da9a |
|||
RUN cd /root && git clone https://github.com/tatsuhiro-t/nghttp2.git |
|||
|
|||
WORKDIR /root/nghttp2 |
|||
RUN git reset --hard $NGHTTP2_VER |
|||
RUN autoreconf -i |
|||
RUN automake |
|||
RUN autoconf |
|||
RUN ./configure |
|||
RUN make |
|||
RUN make install |
|||
|
|||
WORKDIR /root |
|||
RUN wget https://curl.se/download/curl-7.45.0.tar.gz |
|||
RUN tar -zxvf curl-7.45.0.tar.gz |
|||
WORKDIR /root/curl-7.45.0 |
|||
RUN ./configure --with-ssl --with-nghttp2=/usr/local |
|||
RUN make |
|||
RUN make install |
|||
RUN ldconfig |
|||
|
|||
CMD ["-h"] |
|||
ENTRYPOINT ["/usr/local/bin/curl"] |
|||
|
@ -1,3 +0,0 @@ |
|||
curlimage: |
|||
docker build -t gohttp2/curl . |
|||
|
@ -1,30 +0,0 @@ |
|||
// Copyright 2018 The Go Authors. All rights reserved.
|
|||
// Use of this source code is governed by a BSD-style
|
|||
// license that can be found in the LICENSE file.
|
|||
|
|||
//go:build go1.11
|
|||
// +build go1.11
|
|||
|
|||
package http2 |
|||
|
|||
import ( |
|||
"net/http/httptrace" |
|||
"net/textproto" |
|||
) |
|||
|
|||
func traceHasWroteHeaderField(trace *httptrace.ClientTrace) bool { |
|||
return trace != nil && trace.WroteHeaderField != nil |
|||
} |
|||
|
|||
func traceWroteHeaderField(trace *httptrace.ClientTrace, k, v string) { |
|||
if trace != nil && trace.WroteHeaderField != nil { |
|||
trace.WroteHeaderField(k, []string{v}) |
|||
} |
|||
} |
|||
|
|||
func traceGot1xxResponseFunc(trace *httptrace.ClientTrace) func(int, textproto.MIMEHeader) error { |
|||
if trace != nil { |
|||
return trace.Got1xxResponse |
|||
} |
|||
return nil |
|||
} |
@ -1,27 +0,0 @@ |
|||
// Copyright 2021 The Go Authors. All rights reserved.
|
|||
// Use of this source code is governed by a BSD-style
|
|||
// license that can be found in the LICENSE file.
|
|||
|
|||
//go:build go1.15
|
|||
// +build go1.15
|
|||
|
|||
package http2 |
|||
|
|||
import ( |
|||
"context" |
|||
"crypto/tls" |
|||
) |
|||
|
|||
// dialTLSWithContext uses tls.Dialer, added in Go 1.15, to open a TLS
|
|||
// connection.
|
|||
func (t *Transport) dialTLSWithContext(ctx context.Context, network, addr string, cfg *tls.Config) (*tls.Conn, error) { |
|||
dialer := &tls.Dialer{ |
|||
Config: cfg, |
|||
} |
|||
cn, err := dialer.DialContext(ctx, network, addr) |
|||
if err != nil { |
|||
return nil, err |
|||
} |
|||
tlsCn := cn.(*tls.Conn) // DialContext comment promises this will always succeed
|
|||
return tlsCn, nil |
|||
} |
@ -1,17 +0,0 @@ |
|||
// Copyright 2021 The Go Authors. All rights reserved.
|
|||
// Use of this source code is governed by a BSD-style
|
|||
// license that can be found in the LICENSE file.
|
|||
|
|||
//go:build go1.18
|
|||
// +build go1.18
|
|||
|
|||
package http2 |
|||
|
|||
import ( |
|||
"crypto/tls" |
|||
"net" |
|||
) |
|||
|
|||
func tlsUnderlyingConn(tc *tls.Conn) net.Conn { |
|||
return tc.NetConn() |
|||
} |
@ -1,21 +0,0 @@ |
|||
// Copyright 2018 The Go Authors. All rights reserved.
|
|||
// Use of this source code is governed by a BSD-style
|
|||
// license that can be found in the LICENSE file.
|
|||
|
|||
//go:build !go1.11
|
|||
// +build !go1.11
|
|||
|
|||
package http2 |
|||
|
|||
import ( |
|||
"net/http/httptrace" |
|||
"net/textproto" |
|||
) |
|||
|
|||
func traceHasWroteHeaderField(trace *httptrace.ClientTrace) bool { return false } |
|||
|
|||
func traceWroteHeaderField(trace *httptrace.ClientTrace, k, v string) {} |
|||
|
|||
func traceGot1xxResponseFunc(trace *httptrace.ClientTrace) func(int, textproto.MIMEHeader) error { |
|||
return nil |
|||
} |
@ -1,31 +0,0 @@ |
|||
// Copyright 2021 The Go Authors. All rights reserved.
|
|||
// Use of this source code is governed by a BSD-style
|
|||
// license that can be found in the LICENSE file.
|
|||
|
|||
//go:build !go1.15
|
|||
// +build !go1.15
|
|||
|
|||
package http2 |
|||
|
|||
import ( |
|||
"context" |
|||
"crypto/tls" |
|||
) |
|||
|
|||
// dialTLSWithContext opens a TLS connection.
|
|||
func (t *Transport) dialTLSWithContext(ctx context.Context, network, addr string, cfg *tls.Config) (*tls.Conn, error) { |
|||
cn, err := tls.Dial(network, addr, cfg) |
|||
if err != nil { |
|||
return nil, err |
|||
} |
|||
if err := cn.Handshake(); err != nil { |
|||
return nil, err |
|||
} |
|||
if cfg.InsecureSkipVerify { |
|||
return cn, nil |
|||
} |
|||
if err := cn.VerifyHostname(cfg.ServerName); err != nil { |
|||
return nil, err |
|||
} |
|||
return cn, nil |
|||
} |
@ -1,17 +0,0 @@ |
|||
// Copyright 2021 The Go Authors. All rights reserved.
|
|||
// Use of this source code is governed by a BSD-style
|
|||
// license that can be found in the LICENSE file.
|
|||
|
|||
//go:build !go1.18
|
|||
// +build !go1.18
|
|||
|
|||
package http2 |
|||
|
|||
import ( |
|||
"crypto/tls" |
|||
"net" |
|||
) |
|||
|
|||
func tlsUnderlyingConn(tc *tls.Conn) net.Conn { |
|||
return nil |
|||
} |
File diff suppressed because it is too large
@ -1,30 +0,0 @@ |
|||
// Copyright 2020 The Go Authors. All rights reserved.
|
|||
// Use of this source code is governed by a BSD-style
|
|||
// license that can be found in the LICENSE file.
|
|||
|
|||
// Package unsafeheader contains header declarations for the Go runtime's
|
|||
// slice and string implementations.
|
|||
//
|
|||
// This package allows x/sys to use types equivalent to
|
|||
// reflect.SliceHeader and reflect.StringHeader without introducing
|
|||
// a dependency on the (relatively heavy) "reflect" package.
|
|||
package unsafeheader |
|||
|
|||
import ( |
|||
"unsafe" |
|||
) |
|||
|
|||
// Slice is the runtime representation of a slice.
|
|||
// It cannot be used safely or portably and its representation may change in a later release.
|
|||
type Slice struct { |
|||
Data unsafe.Pointer |
|||
Len int |
|||
Cap int |
|||
} |
|||
|
|||
// String is the runtime representation of a string.
|
|||
// It cannot be used safely or portably and its representation may change in a later release.
|
|||
type String struct { |
|||
Data unsafe.Pointer |
|||
Len int |
|||
} |
Some files were not shown because too many files changed in this diff
Loading…
Reference in new issue