From 52226ad2351dd2d3bd4191c1d9cb7cc43939a8d7 Mon Sep 17 00:00:00 2001 From: Steve Manuel Date: Sun, 19 Aug 2018 21:14:52 -0600 Subject: admin richtext updates, uuid package migration (#269) * update CI code to run --dev if on ponzu-dev branch * CI: ensure we have latest from ponzu-dev branch * Replaced satori/go.uuid with gofrs/uuid. (#268) * Changed files to use new uuid pkg. * Replace satori/go.uuid with gofrs/uuid. Closes #257. * Deleted satori/go.uuid folder. Closes #257. * Added heading styles and table to richtext toolbar. (#267) Closes #207. * Override Cobra's 'help' command to remove duplicate. (#266) Closes #206. --- README.md | 2 +- cmd/ponzu/usage.go | 2 +- cmd/ponzu/vendor/github.com/gofrs/uuid/.gitignore | 15 + cmd/ponzu/vendor/github.com/gofrs/uuid/.travis.yml | 19 + cmd/ponzu/vendor/github.com/gofrs/uuid/LICENSE | 20 + cmd/ponzu/vendor/github.com/gofrs/uuid/README.md | 101 +++++ cmd/ponzu/vendor/github.com/gofrs/uuid/codec.go | 214 +++++++++++ .../vendor/github.com/gofrs/uuid/codec_test.go | 303 +++++++++++++++ cmd/ponzu/vendor/github.com/gofrs/uuid/fuzz.go | 47 +++ .../vendor/github.com/gofrs/uuid/generator.go | 299 +++++++++++++++ .../vendor/github.com/gofrs/uuid/generator_test.go | 418 +++++++++++++++++++++ cmd/ponzu/vendor/github.com/gofrs/uuid/sql.go | 105 ++++++ cmd/ponzu/vendor/github.com/gofrs/uuid/sql_test.go | 305 +++++++++++++++ .../1416586f4a34d02bcb506f6107b40df512b9f2f9 | 1 + .../3b46a7e7b02ec193581e6c9fa2c8a72f50a64e08-1 | 1 + .../50c54bb75fcfdc488f162bf2f0c6dec6103bfa18-5 | 1 + .../69c581ab749cbd56be8684d3a58ac2cfab9af0f4-5 | 1 + .../752bf000e0bff06777dd0d6f0be6353844de678a-3 | 1 + .../a4483762d4ece8466d82cca5cacd35a0829c4e60-2 | 1 + .../d0952c45e0c823fc5cc12bcf7d9b877d150ab523-1 | 1 + .../da39a3ee5e6b4b0d3255bfef95601890afd80709 | 0 .../e2b84d2065846891f18ae109b12e01d224e1c7c3-4 | 1 + .../e320d749435115e874f77420e17d0937e07f69f3-2 | 1 + .../ed132d47d757f6468443a22df8a2a965efb34098-7 | 1 + .../eeefb01f7bb3c627aedb292c994b20f739ffd613-6 | 1 + .../gofrs/uuid/testdata/corpus/seed_invalid_0 | 1 + .../gofrs/uuid/testdata/corpus/seed_invalid_1 | 1 + .../gofrs/uuid/testdata/corpus/seed_invalid_10 | 1 + .../gofrs/uuid/testdata/corpus/seed_invalid_11 | 1 + .../gofrs/uuid/testdata/corpus/seed_invalid_12 | 1 + .../gofrs/uuid/testdata/corpus/seed_invalid_13 | 1 + .../gofrs/uuid/testdata/corpus/seed_invalid_14 | 1 + .../gofrs/uuid/testdata/corpus/seed_invalid_15 | 1 + .../gofrs/uuid/testdata/corpus/seed_invalid_16 | 1 + .../gofrs/uuid/testdata/corpus/seed_invalid_17 | 1 + .../gofrs/uuid/testdata/corpus/seed_invalid_18 | 1 + .../gofrs/uuid/testdata/corpus/seed_invalid_19 | 1 + .../gofrs/uuid/testdata/corpus/seed_invalid_2 | 1 + .../gofrs/uuid/testdata/corpus/seed_invalid_20 | 1 + .../gofrs/uuid/testdata/corpus/seed_invalid_21 | 1 + .../gofrs/uuid/testdata/corpus/seed_invalid_22 | 1 + .../gofrs/uuid/testdata/corpus/seed_invalid_23 | 1 + .../gofrs/uuid/testdata/corpus/seed_invalid_3 | 1 + .../gofrs/uuid/testdata/corpus/seed_invalid_4 | 1 + .../gofrs/uuid/testdata/corpus/seed_invalid_5 | 1 + .../gofrs/uuid/testdata/corpus/seed_invalid_6 | 1 + .../gofrs/uuid/testdata/corpus/seed_invalid_7 | 1 + .../gofrs/uuid/testdata/corpus/seed_invalid_8 | 1 + .../gofrs/uuid/testdata/corpus/seed_invalid_9 | 1 + .../testdata/corpus/seed_valid_BracedCanonical | 1 + .../uuid/testdata/corpus/seed_valid_BracedHashlike | 1 + .../uuid/testdata/corpus/seed_valid_Canonical | 1 + .../gofrs/uuid/testdata/corpus/seed_valid_Hashlike | 1 + .../uuid/testdata/corpus/seed_valid_URNCanonical | 1 + .../uuid/testdata/corpus/seed_valid_URNHashlike | 1 + cmd/ponzu/vendor/github.com/gofrs/uuid/uuid.go | 159 ++++++++ .../vendor/github.com/gofrs/uuid/uuid_test.go | 135 +++++++ .../vendor/github.com/satori/go.uuid/.travis.yml | 23 -- cmd/ponzu/vendor/github.com/satori/go.uuid/LICENSE | 20 - .../vendor/github.com/satori/go.uuid/README.md | 74 ---- .../vendor/github.com/satori/go.uuid/codec.go | 206 ---------- .../vendor/github.com/satori/go.uuid/codec_test.go | 251 ------------- .../vendor/github.com/satori/go.uuid/generator.go | 265 ------------- .../github.com/satori/go.uuid/generator_test.go | 224 ----------- cmd/ponzu/vendor/github.com/satori/go.uuid/sql.go | 78 ---- .../vendor/github.com/satori/go.uuid/sql_test.go | 136 ------- cmd/ponzu/vendor/github.com/satori/go.uuid/uuid.go | 161 -------- .../vendor/github.com/satori/go.uuid/uuid_test.go | 100 ----- management/editor/elements.go | 5 +- management/manager/manager.go | 2 +- system/db/content.go | 2 +- system/db/upload.go | 2 +- system/item/item.go | 2 +- 73 files changed, 2190 insertions(+), 1546 deletions(-) create mode 100644 cmd/ponzu/vendor/github.com/gofrs/uuid/.gitignore create mode 100644 cmd/ponzu/vendor/github.com/gofrs/uuid/.travis.yml create mode 100644 cmd/ponzu/vendor/github.com/gofrs/uuid/LICENSE create mode 100644 cmd/ponzu/vendor/github.com/gofrs/uuid/README.md create mode 100644 cmd/ponzu/vendor/github.com/gofrs/uuid/codec.go create mode 100644 cmd/ponzu/vendor/github.com/gofrs/uuid/codec_test.go create mode 100644 cmd/ponzu/vendor/github.com/gofrs/uuid/fuzz.go create mode 100644 cmd/ponzu/vendor/github.com/gofrs/uuid/generator.go create mode 100644 cmd/ponzu/vendor/github.com/gofrs/uuid/generator_test.go create mode 100644 cmd/ponzu/vendor/github.com/gofrs/uuid/sql.go create mode 100644 cmd/ponzu/vendor/github.com/gofrs/uuid/sql_test.go create mode 100644 cmd/ponzu/vendor/github.com/gofrs/uuid/testdata/corpus/1416586f4a34d02bcb506f6107b40df512b9f2f9 create mode 100644 cmd/ponzu/vendor/github.com/gofrs/uuid/testdata/corpus/3b46a7e7b02ec193581e6c9fa2c8a72f50a64e08-1 create mode 100644 cmd/ponzu/vendor/github.com/gofrs/uuid/testdata/corpus/50c54bb75fcfdc488f162bf2f0c6dec6103bfa18-5 create mode 100644 cmd/ponzu/vendor/github.com/gofrs/uuid/testdata/corpus/69c581ab749cbd56be8684d3a58ac2cfab9af0f4-5 create mode 100644 cmd/ponzu/vendor/github.com/gofrs/uuid/testdata/corpus/752bf000e0bff06777dd0d6f0be6353844de678a-3 create mode 100644 cmd/ponzu/vendor/github.com/gofrs/uuid/testdata/corpus/a4483762d4ece8466d82cca5cacd35a0829c4e60-2 create mode 100644 cmd/ponzu/vendor/github.com/gofrs/uuid/testdata/corpus/d0952c45e0c823fc5cc12bcf7d9b877d150ab523-1 create mode 100644 cmd/ponzu/vendor/github.com/gofrs/uuid/testdata/corpus/da39a3ee5e6b4b0d3255bfef95601890afd80709 create mode 100644 cmd/ponzu/vendor/github.com/gofrs/uuid/testdata/corpus/e2b84d2065846891f18ae109b12e01d224e1c7c3-4 create mode 100644 cmd/ponzu/vendor/github.com/gofrs/uuid/testdata/corpus/e320d749435115e874f77420e17d0937e07f69f3-2 create mode 100644 cmd/ponzu/vendor/github.com/gofrs/uuid/testdata/corpus/ed132d47d757f6468443a22df8a2a965efb34098-7 create mode 100644 cmd/ponzu/vendor/github.com/gofrs/uuid/testdata/corpus/eeefb01f7bb3c627aedb292c994b20f739ffd613-6 create mode 100755 cmd/ponzu/vendor/github.com/gofrs/uuid/testdata/corpus/seed_invalid_0 create mode 100755 cmd/ponzu/vendor/github.com/gofrs/uuid/testdata/corpus/seed_invalid_1 create mode 100755 cmd/ponzu/vendor/github.com/gofrs/uuid/testdata/corpus/seed_invalid_10 create mode 100755 cmd/ponzu/vendor/github.com/gofrs/uuid/testdata/corpus/seed_invalid_11 create mode 100755 cmd/ponzu/vendor/github.com/gofrs/uuid/testdata/corpus/seed_invalid_12 create mode 100755 cmd/ponzu/vendor/github.com/gofrs/uuid/testdata/corpus/seed_invalid_13 create mode 100755 cmd/ponzu/vendor/github.com/gofrs/uuid/testdata/corpus/seed_invalid_14 create mode 100755 cmd/ponzu/vendor/github.com/gofrs/uuid/testdata/corpus/seed_invalid_15 create mode 100755 cmd/ponzu/vendor/github.com/gofrs/uuid/testdata/corpus/seed_invalid_16 create mode 100755 cmd/ponzu/vendor/github.com/gofrs/uuid/testdata/corpus/seed_invalid_17 create mode 100755 cmd/ponzu/vendor/github.com/gofrs/uuid/testdata/corpus/seed_invalid_18 create mode 100755 cmd/ponzu/vendor/github.com/gofrs/uuid/testdata/corpus/seed_invalid_19 create mode 100755 cmd/ponzu/vendor/github.com/gofrs/uuid/testdata/corpus/seed_invalid_2 create mode 100755 cmd/ponzu/vendor/github.com/gofrs/uuid/testdata/corpus/seed_invalid_20 create mode 100755 cmd/ponzu/vendor/github.com/gofrs/uuid/testdata/corpus/seed_invalid_21 create mode 100755 cmd/ponzu/vendor/github.com/gofrs/uuid/testdata/corpus/seed_invalid_22 create mode 100755 cmd/ponzu/vendor/github.com/gofrs/uuid/testdata/corpus/seed_invalid_23 create mode 100755 cmd/ponzu/vendor/github.com/gofrs/uuid/testdata/corpus/seed_invalid_3 create mode 100755 cmd/ponzu/vendor/github.com/gofrs/uuid/testdata/corpus/seed_invalid_4 create mode 100755 cmd/ponzu/vendor/github.com/gofrs/uuid/testdata/corpus/seed_invalid_5 create mode 100755 cmd/ponzu/vendor/github.com/gofrs/uuid/testdata/corpus/seed_invalid_6 create mode 100755 cmd/ponzu/vendor/github.com/gofrs/uuid/testdata/corpus/seed_invalid_7 create mode 100755 cmd/ponzu/vendor/github.com/gofrs/uuid/testdata/corpus/seed_invalid_8 create mode 100755 cmd/ponzu/vendor/github.com/gofrs/uuid/testdata/corpus/seed_invalid_9 create mode 100755 cmd/ponzu/vendor/github.com/gofrs/uuid/testdata/corpus/seed_valid_BracedCanonical create mode 100755 cmd/ponzu/vendor/github.com/gofrs/uuid/testdata/corpus/seed_valid_BracedHashlike create mode 100755 cmd/ponzu/vendor/github.com/gofrs/uuid/testdata/corpus/seed_valid_Canonical create mode 100755 cmd/ponzu/vendor/github.com/gofrs/uuid/testdata/corpus/seed_valid_Hashlike create mode 100755 cmd/ponzu/vendor/github.com/gofrs/uuid/testdata/corpus/seed_valid_URNCanonical create mode 100755 cmd/ponzu/vendor/github.com/gofrs/uuid/testdata/corpus/seed_valid_URNHashlike create mode 100644 cmd/ponzu/vendor/github.com/gofrs/uuid/uuid.go create mode 100644 cmd/ponzu/vendor/github.com/gofrs/uuid/uuid_test.go delete mode 100644 cmd/ponzu/vendor/github.com/satori/go.uuid/.travis.yml delete mode 100644 cmd/ponzu/vendor/github.com/satori/go.uuid/LICENSE delete mode 100644 cmd/ponzu/vendor/github.com/satori/go.uuid/README.md delete mode 100644 cmd/ponzu/vendor/github.com/satori/go.uuid/codec.go delete mode 100644 cmd/ponzu/vendor/github.com/satori/go.uuid/codec_test.go delete mode 100644 cmd/ponzu/vendor/github.com/satori/go.uuid/generator.go delete mode 100644 cmd/ponzu/vendor/github.com/satori/go.uuid/generator_test.go delete mode 100644 cmd/ponzu/vendor/github.com/satori/go.uuid/sql.go delete mode 100644 cmd/ponzu/vendor/github.com/satori/go.uuid/sql_test.go delete mode 100644 cmd/ponzu/vendor/github.com/satori/go.uuid/uuid.go delete mode 100644 cmd/ponzu/vendor/github.com/satori/go.uuid/uuid_test.go diff --git a/README.md b/README.md index cc8e217..2632925 100644 --- a/README.md +++ b/README.md @@ -304,7 +304,7 @@ $ ponzu new --dev --fork=github.com/nilslice/ponzu /path/to/new/project - [github.com/nilslice/jwt](https://github.com/nilslice/jwt) - [github.com/nilslice/email](https://github.com/nilslice/email) - [github.com/gorilla/schema](https://github.com/gorilla/schema) -- [github.com/satori/go.uuid](https://github.com/satori/go.uuid) +- [github.com/gofrs/uuid](https://github.com/gofrs/uuid) - [github.com/tidwall/gjson](https://github.com/tidwall/gjson) - [github.com/tidwall/sjson](https://github.com/tidwall/sjson) - [github.com/boltdb/bolt](https://github.com/boltdb/bolt) diff --git a/cmd/ponzu/usage.go b/cmd/ponzu/usage.go index da28b44..b5e9752 100644 --- a/cmd/ponzu/usage.go +++ b/cmd/ponzu/usage.go @@ -85,7 +85,7 @@ func RegisterCmdlineCommand(cmd *cobra.Command) { } func init() { - rootCmd.AddCommand(helpCmd) + rootCmd.SetHelpCommand(helpCmd) } // rpad adds padding to the right of a string. diff --git a/cmd/ponzu/vendor/github.com/gofrs/uuid/.gitignore b/cmd/ponzu/vendor/github.com/gofrs/uuid/.gitignore new file mode 100644 index 0000000..666dbbb --- /dev/null +++ b/cmd/ponzu/vendor/github.com/gofrs/uuid/.gitignore @@ -0,0 +1,15 @@ +# Binaries for programs and plugins +*.exe +*.exe~ +*.dll +*.so +*.dylib + +# Test binary, build with `go test -c` +*.test + +# Output of the go coverage tool, specifically when used with LiteIDE +*.out + +# binary bundle generated by go-fuzz +uuid-fuzz.zip diff --git a/cmd/ponzu/vendor/github.com/gofrs/uuid/.travis.yml b/cmd/ponzu/vendor/github.com/gofrs/uuid/.travis.yml new file mode 100644 index 0000000..bb43fd2 --- /dev/null +++ b/cmd/ponzu/vendor/github.com/gofrs/uuid/.travis.yml @@ -0,0 +1,19 @@ +language: go +sudo: false +go: + - 1.7 + - 1.8 + - 1.9 + - "1.10" + - 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 diff --git a/cmd/ponzu/vendor/github.com/gofrs/uuid/LICENSE b/cmd/ponzu/vendor/github.com/gofrs/uuid/LICENSE new file mode 100644 index 0000000..926d549 --- /dev/null +++ b/cmd/ponzu/vendor/github.com/gofrs/uuid/LICENSE @@ -0,0 +1,20 @@ +Copyright (C) 2013-2018 by Maxim Bublis + +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. diff --git a/cmd/ponzu/vendor/github.com/gofrs/uuid/README.md b/cmd/ponzu/vendor/github.com/gofrs/uuid/README.md new file mode 100644 index 0000000..e1e2b2e --- /dev/null +++ b/cmd/ponzu/vendor/github.com/gofrs/uuid/README.md @@ -0,0 +1,101 @@ +# UUID + +[![License](https://img.shields.io/github/license/gofrs/uuid.svg)](https://github.com/gofrs/uuid/blob/master/LICENSE) +[![Build Status](https://travis-ci.org/gofrs/uuid.svg?branch=master)](https://travis-ci.org/gofrs/uuid) +[![GoDoc](http://godoc.org/github.com/gofrs/uuid?status.svg)](http://godoc.org/github.com/gofrs/uuid) +[![Coverage Status](https://coveralls.io/repos/github/gofrs/uuid/badge.svg?branch=master)](https://coveralls.io/github/gofrs/uuid) +[![Go Report Card](https://goreportcard.com/badge/github.com/gofrs/uuid)](https://goreportcard.com/report/github.com/gofrs/uuid) + +Package uuid provides a pure Go implementation of Universally Unique Identifiers +(UUID) variant as defined in RFC-4122. This package supports both the creation +and parsing of UUIDs in different formats. + +This package supports the following UUID 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 of a named value (RFC-4122) +* Version 4, based on random numbers (RFC-4122) +* Version 5, based on SHA-1 hashing of a named value (RFC-4122) + +## Project History + +This project was originally forked from the +[github.com/satori/go.uuid](https://github.com/satori/go.uuid) repository after +it appeared to be no longer maintained, while exhibiting [critical +flaws](https://github.com/satori/go.uuid/issues/73). We have decided to take +over this project to ensure it receives regular maintenance for the benefit of +the larger Go community. + +We'd like to thank Maxim Bublis for his hard work on the original iteration of +the package. + +## License + +This source code of this package is released under the MIT License. Please see +the [LICENSE](https://github.com/gofrs/uuid/blob/master/LICENSE) for the full +content of the license. + +## Recommended Package Version + +We recommend using v2.0.0+ of this package, as versions prior to 2.0.0 were +created before our fork of the original package and have some known +deficiencies. + +## Installation + +It is recommended to use a package manager like `dep` that understands tagged +releases of a package, as well as semantic versioning. + +If you are unable to make use of a dependency manager with your project, you can +use the `go get` command to download it directly: + +```Shell +$ go get github.com/gofrs/uuid +``` + +## Requirements + +Due to subtests not being supported in older versions of Go, this package is +only regularly tested against Go 1.7+. This package may work perfectly fine with +Go 1.2+, but support for these older versions is not actively maintained. + +## Usage + +Here is a quick overview of how to use this package. For more detailed +documentation, please see the [GoDoc Page](http://godoc.org/github.com/gofrs/uuid). + +```go +package main + +import ( + "log" + + "github.com/gofrs/uuid" +) + +// Create a Version 4 UUID, panicking on error. +// Use this form to initialize package-level variables. +var u1 = uuid.Must(uuid.NewV4()) + +func main() { + // Create a Version 4 UUID. + u2, err := uuid.NewV4() + if err != nil { + log.Fatalf("failed to generate UUID: %v", err) + } + log.Printf("generated Version 4 UUID %v", u2) + + // Parse a UUID from a string. + s := "6ba7b810-9dad-11d1-80b4-00c04fd430c8" + u3, err := uuid.FromString(s) + if err != nil { + log.Fatalf("failed to parse UUID %q: %v", s, err) + } + log.Printf("successfully parsed UUID %v", u3) +} +``` + +## References + +* [RFC-4122](https://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) diff --git a/cmd/ponzu/vendor/github.com/gofrs/uuid/codec.go b/cmd/ponzu/vendor/github.com/gofrs/uuid/codec.go new file mode 100644 index 0000000..2f03b97 --- /dev/null +++ b/cmd/ponzu/vendor/github.com/gofrs/uuid/codec.go @@ -0,0 +1,214 @@ +// Copyright (C) 2013-2018 by Maxim Bublis +// +// 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 a UUID generated from the raw byte slice input. +// It will return an error if the slice isn't 16 bytes long. +func FromBytes(input []byte) (UUID, error) { + u := UUID{} + err := u.UnmarshalBinary(input) + return u, err +} + +// FromBytesOrNil returns a UUID generated from the raw byte slice input. +// Same behavior as FromBytes(), but returns uuid.Nil instead of an error. +func FromBytesOrNil(input []byte) UUID { + uuid, err := FromBytes(input) + if err != nil { + return Nil + } + return uuid +} + +// FromString returns a UUID parsed from the input string. +// Input is expected in a form accepted by UnmarshalText. +func FromString(input string) (UUID, error) { + u := UUID{} + err := u.UnmarshalText([]byte(input)) + return u, err +} + +// FromStringOrNil returns a UUID parsed from the input string. +// Same behavior as FromString(), but returns uuid.Nil instead of an 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 the String() method. +func (u UUID) MarshalText() ([]byte, error) { + return []byte(u.String()), nil +} + +// 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" +// "{6ba7b8109dad11d180b400c04fd430c8}", +// "urn:uuid:6ba7b8109dad11d180b400c04fd430c8" +// +// ABNF for supported UUID text representation follows: +// +// URN := 'urn' +// UUID-NID := 'uuid' +// +// hexdig := '0' | '1' | '2' | '3' | '4' | '5' | '6' | '7' | '8' | '9' | +// 'a' | 'b' | 'c' | 'd' | 'e' | 'f' | +// 'A' | 'B' | 'C' | 'D' | 'E' | 'F' +// +// hexoct := hexdig hexdig +// 2hexoct := hexoct hexoct +// 4hexoct := 2hexoct 2hexoct +// 6hexoct := 4hexoct 2hexoct +// 12hexoct := 6hexoct 6hexoct +// +// hashlike := 12hexoct +// canonical := 4hexoct '-' 2hexoct '-' 2hexoct '-' 6hexoct +// +// plain := canonical | hashlike +// uuid := canonical | hashlike | braced | urn +// +// braced := '{' plain '}' | '{' hashlike '}' +// urn := URN ':' UUID-NID ':' plain +// +func (u *UUID) UnmarshalText(text []byte) error { + switch len(text) { + case 32: + return u.decodeHashLike(text) + case 34, 38: + return u.decodeBraced(text) + case 36: + return u.decodeCanonical(text) + case 41, 45: + return u.decodeURN(text) + default: + return fmt.Errorf("uuid: incorrect UUID length: %s", text) + } +} + +// decodeCanonical decodes UUID strings that are formatted as defined in RFC-4122 (section 3): +// "6ba7b810-9dad-11d1-80b4-00c04fd430c8". +func (u *UUID) decodeCanonical(t []byte) 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 err + } + src = src[byteGroup:] + dst = dst[byteGroup/2:] + } + + return nil +} + +// decodeHashLike decodes UUID strings that are using the following format: +// "6ba7b8109dad11d180b400c04fd430c8". +func (u *UUID) decodeHashLike(t []byte) error { + src := t[:] + dst := u[:] + + if _, err := hex.Decode(dst, src); err != nil { + return err + } + return nil +} + +// decodeBraced decodes UUID strings that are using the following formats: +// "{6ba7b810-9dad-11d1-80b4-00c04fd430c8}" +// "{6ba7b8109dad11d180b400c04fd430c8}". +func (u *UUID) decodeBraced(t []byte) 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 strings that are using the following formats: +// "urn:uuid:6ba7b810-9dad-11d1-80b4-00c04fd430c8" +// "urn:uuid:6ba7b8109dad11d180b400c04fd430c8". +func (u *UUID) decodeURN(t []byte) error { + total := len(t) + + urnUUIDPrefix := t[:9] + + if !bytes.Equal(urnUUIDPrefix, urnPrefix) { + return fmt.Errorf("uuid: incorrect UUID format: %s", t) + } + + return u.decodePlain(t[9:total]) +} + +// decodePlain decodes UUID strings that are using the following formats: +// "6ba7b810-9dad-11d1-80b4-00c04fd430c8" or in hash-like format +// "6ba7b8109dad11d180b400c04fd430c8". +func (u *UUID) decodePlain(t []byte) 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() ([]byte, error) { + return u.Bytes(), nil +} + +// UnmarshalBinary implements the encoding.BinaryUnmarshaler interface. +// It will return an error if the slice isn't 16 bytes long. +func (u *UUID) UnmarshalBinary(data []byte) error { + if len(data) != Size { + return fmt.Errorf("uuid: UUID must be exactly 16 bytes long, got %d bytes", len(data)) + } + copy(u[:], data) + + return nil +} diff --git a/cmd/ponzu/vendor/github.com/gofrs/uuid/codec_test.go b/cmd/ponzu/vendor/github.com/gofrs/uuid/codec_test.go new file mode 100644 index 0000000..f156d1c --- /dev/null +++ b/cmd/ponzu/vendor/github.com/gofrs/uuid/codec_test.go @@ -0,0 +1,303 @@ +// Copyright (C) 2013-2018 by Maxim Bublis +// +// 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" + "flag" + "fmt" + "io/ioutil" + "os" + "path/filepath" + "testing" +) + +// codecTestData holds []byte data for a UUID we commonly use for testing. +var codecTestData = []byte{0x6b, 0xa7, 0xb8, 0x10, 0x9d, 0xad, 0x11, 0xd1, 0x80, 0xb4, 0x00, 0xc0, 0x4f, 0xd4, 0x30, 0xc8} + +// codecTestUUID is the UUID value corresponding to codecTestData. +var codecTestUUID = UUID{0x6b, 0xa7, 0xb8, 0x10, 0x9d, 0xad, 0x11, 0xd1, 0x80, 0xb4, 0x00, 0xc0, 0x4f, 0xd4, 0x30, 0xc8} + +func TestFromBytes(t *testing.T) { + t.Run("Valid", func(t *testing.T) { + got, err := FromBytes(codecTestData) + if err != nil { + t.Fatal(err) + } + if got != codecTestUUID { + t.Fatalf("FromBytes(%x) = %v, want %v", codecTestData, got, codecTestUUID) + } + }) + t.Run("Invalid", func(t *testing.T) { + var short [][]byte + for i := 0; i < len(codecTestData); i++ { + short = append(short, codecTestData[:i]) + } + var long [][]byte + for i := 1; i < 17; i++ { + tmp := append(codecTestData, make([]byte, i)...) + long = append(long, tmp) + } + invalid := append(short, long...) + for _, b := range invalid { + got, err := FromBytes(b) + if err == nil { + t.Fatalf("FromBytes(%x): want err != nil, got %v", b, got) + } + } + }) +} + +func TestFromBytesOrNil(t *testing.T) { + t.Run("Invalid", func(t *testing.T) { + b := []byte{4, 8, 15, 16, 23, 42} + got := FromBytesOrNil(b) + if got != Nil { + t.Errorf("FromBytesOrNil(%x): got %v, want %v", b, got, Nil) + } + }) + t.Run("Valid", func(t *testing.T) { + got := FromBytesOrNil(codecTestData) + if got != codecTestUUID { + t.Errorf("FromBytesOrNil(%x): got %v, want %v", codecTestData, got, codecTestUUID) + } + }) + +} + +type fromStringTest struct { + input string + variant string +} + +// Run runs the FromString test in a subtest of t, named by fst.variant. +func (fst fromStringTest) Run(t *testing.T) { + t.Run(fst.variant, func(t *testing.T) { + got, err := FromString(fst.input) + if err != nil { + t.Fatalf("FromString(%q): %v", fst.input, err) + } + if want := codecTestUUID; got != want { + t.Fatalf("FromString(%q) = %v, want %v", fst.input, got, want) + } + }) +} + +// fromStringTests contains UUID variants that are expected to be parsed +// successfully by UnmarshalText / FromString. +// +// variants must be unique across elements of this slice. Please see the +// comment in fuzz.go if you change this slice or add new tests to it. +var fromStringTests = []fromStringTest{ + { + input: "6ba7b810-9dad-11d1-80b4-00c04fd430c8", + variant: "Canonical", + }, + { + input: "{6ba7b810-9dad-11d1-80b4-00c04fd430c8}", + variant: "BracedCanonical", + }, + { + input: "{6ba7b8109dad11d180b400c04fd430c8}", + variant: "BracedHashlike", + }, + { + input: "6ba7b8109dad11d180b400c04fd430c8", + variant: "Hashlike", + }, + { + input: "urn:uuid:6ba7b810-9dad-11d1-80b4-00c04fd430c8", + variant: "URNCanonical", + }, + { + input: "urn:uuid:6ba7b8109dad11d180b400c04fd430c8", + variant: "URNHashlike", + }, +} + +var invalidFromStringInputs = []string{ + // short + "6ba7b810-9dad-11d1-80b4-00c04fd430c", + "6ba7b8109dad11d180b400c04fd430c", + + // invalid hex + "6ba7b8109dad11d180b400c04fd430q8", + + // long + "6ba7b810-9dad-11d1-80b4-00c04fd430c8=", + "6ba7b810-9dad-11d1-80b4-00c04fd430c8}", + "{6ba7b810-9dad-11d1-80b4-00c04fd430c8}f", + "6ba7b810-9dad-11d1-80b4-00c04fd430c800c04fd430c8", + + // malformed in other ways + "ba7b8109dad11d180b400c04fd430c8}", + "6ba7b8109dad11d180b400c04fd430c86ba7b8109dad11d180b400c04fd430c8", + "urn:uuid:{6ba7b810-9dad-11d1-80b4-00c04fd430c8}", + "uuid:urn:6ba7b810-9dad-11d1-80b4-00c04fd430c8", + "uuid:urn:6ba7b8109dad11d180b400c04fd430c8", + "6ba7b8109-dad-11d1-80b4-00c04fd430c8", + "6ba7b810-9dad1-1d1-80b4-00c04fd430c8", + "6ba7b810-9dad-11d18-0b4-00c04fd430c8", + "6ba7b810-9dad-11d1-80b40-0c04fd430c8", + "6ba7b810+9dad+11d1+80b4+00c04fd430c8", + "(6ba7b810-9dad-11d1-80b4-00c04fd430c8}", + "{6ba7b810-9dad-11d1-80b4-00c04fd430c8>", + "zba7b810-9dad-11d1-80b4-00c04fd430c8", + "6ba7b810-9dad11d180b400c04fd430c8", + "6ba7b8109dad-11d180b400c04fd430c8", + "6ba7b8109dad11d1-80b400c04fd430c8", + "6ba7b8109dad11d180b4-00c04fd430c8", +} + +func TestFromString(t *testing.T) { + t.Run("Valid", func(t *testing.T) { + for _, fst := range fromStringTests { + fst.Run(t) + } + }) + t.Run("Invalid", func(t *testing.T) { + for _, s := range invalidFromStringInputs { + got, err := FromString(s) + if err == nil { + t.Errorf("FromString(%q): want err != nil, got %v", s, got) + } + } + }) +} + +func TestFromStringOrNil(t *testing.T) { + t.Run("Invalid", func(t *testing.T) { + s := "bad" + got := FromStringOrNil(s) + if got != Nil { + t.Errorf("FromStringOrNil(%q): got %v, want Nil", s, got) + } + }) + t.Run("Valid", func(t *testing.T) { + s := "6ba7b810-9dad-11d1-80b4-00c04fd430c8" + got := FromStringOrNil(s) + if got != codecTestUUID { + t.Errorf("FromStringOrNil(%q): got %v, want %v", s, got, codecTestUUID) + } + }) +} + +func TestMarshalBinary(t *testing.T) { + got, err := codecTestUUID.MarshalBinary() + if err != nil { + t.Fatal(err) + } + if !bytes.Equal(got, codecTestData) { + t.Fatalf("%v.MarshalBinary() = %x, want %x", codecTestUUID, got, codecTestData) + } +} + +func TestMarshalText(t *testing.T) { + want := []byte("6ba7b810-9dad-11d1-80b4-00c04fd430c8") + got, err := codecTestUUID.MarshalText() + if err != nil { + t.Fatal(err) + } + if !bytes.Equal(got, want) { + t.Errorf("%v.MarshalText(): got %s, want %s", codecTestUUID, got, want) + } +} + +func TestDecodePlainWithWrongLength(t *testing.T) { + arg := []byte{'4', '2'} + + u := UUID{} + + if u.decodePlain(arg) == nil { + t.Errorf("%v.decodePlain(%q): should return error, but it did not", u, arg) + } +} + +var stringBenchmarkSink string + +func BenchmarkString(b *testing.B) { + for i := 0; i < b.N; i++ { + stringBenchmarkSink = codecTestUUID.String() + } +} + +func BenchmarkFromBytes(b *testing.B) { + for i := 0; i < b.N; i++ { + FromBytes(codecTestData) + } +} + +func BenchmarkFromString(b *testing.B) { + b.Run("canonical", func(b *testing.B) { + for i := 0; i < b.N; i++ { + FromString("6ba7b810-9dad-11d1-80b4-00c04fd430c8") + } + }) + b.Run("urn", func(b *testing.B) { + for i := 0; i < b.N; i++ { + FromString("urn:uuid:6ba7b810-9dad-11d1-80b4-00c04fd430c8") + } + }) + b.Run("braced", func(b *testing.B) { + for i := 0; i < b.N; i++ { + FromString("{6ba7b810-9dad-11d1-80b4-00c04fd430c8}") + } + }) +} + +func BenchmarkMarshalBinary(b *testing.B) { + for i := 0; i < b.N; i++ { + codecTestUUID.MarshalBinary() + } +} + +func BenchmarkMarshalText(b *testing.B) { + for i := 0; i < b.N; i++ { + codecTestUUID.MarshalText() + } +} + +var seedFuzzCorpus = flag.Bool("seed_fuzz_corpus", false, "seed fuzz test corpus") + +func TestSeedFuzzCorpus(t *testing.T) { + // flag.Parse() is called for us by the test binary. + if !*seedFuzzCorpus { + t.Skip("seeding fuzz test corpus only on demand") + } + corpusDir := filepath.Join(".", "testdata", "corpus") + writeSeedFile := func(name, data string) error { + path := filepath.Join(corpusDir, name) + return ioutil.WriteFile(path, []byte(data), os.ModePerm) + } + for _, fst := range fromStringTests { + name := "seed_valid_" + fst.variant + if err := writeSeedFile(name, fst.input); err != nil { + t.Fatal(err) + } + } + for i, s := range invalidFromStringInputs { + name := fmt.Sprintf("seed_invalid_%d", i) + if err := writeSeedFile(name, s); err != nil { + t.Fatal(err) + } + } +} diff --git a/cmd/ponzu/vendor/github.com/gofrs/uuid/fuzz.go b/cmd/ponzu/vendor/github.com/gofrs/uuid/fuzz.go new file mode 100644 index 0000000..afaefbc --- /dev/null +++ b/cmd/ponzu/vendor/github.com/gofrs/uuid/fuzz.go @@ -0,0 +1,47 @@ +// Copyright (c) 2018 Andrei Tudor Călin +// +// 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. + +// +build gofuzz + +package uuid + +// Fuzz implements a simple fuzz test for FromString / UnmarshalText. +// +// To run: +// +// $ go get github.com/dvyukov/go-fuzz/... +// $ cd $GOPATH/src/github.com/gofrs/uuid +// $ go-fuzz-build github.com/gofrs/uuid +// $ go-fuzz -bin=uuid-fuzz.zip -workdir=./testdata +// +// If you make significant changes to FromString / UnmarshalText and add +// new cases to fromStringTests (in codec_test.go), please run +// +// $ go test -seed_fuzz_corpus +// +// to seed the corpus with the new interesting inputs, then run the fuzzer. +func Fuzz(data []byte) int { + _, err := FromString(string(data)) + if err != nil { + return 0 + } + return 1 +} diff --git a/cmd/ponzu/vendor/github.com/gofrs/uuid/generator.go b/cmd/ponzu/vendor/github.com/gofrs/uuid/generator.go new file mode 100644 index 0000000..4257761 --- /dev/null +++ b/cmd/ponzu/vendor/github.com/gofrs/uuid/generator.go @@ -0,0 +1,299 @@ +// Copyright (C) 2013-2018 by Maxim Bublis +// +// 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" + "fmt" + "hash" + "io" + "net" + "os" + "sync" + "time" +) + +// Difference in 100-nanosecond intervals between +// UUID epoch (October 15, 1582) and Unix epoch (January 1, 1970). +const epochStart = 122192928000000000 + +type epochFunc func() time.Time + +// HWAddrFunc is the function type used to provide hardware (MAC) addresses. +type HWAddrFunc func() (net.HardwareAddr, error) + +// DefaultGenerator is the default UUID Generator used by this package. +var DefaultGenerator Generator = NewGen() + +var ( + posixUID = uint32(os.Getuid()) + posixGID = uint32(os.Getgid()) +) + +// NewV1 returns a UUID based on the current timestamp and MAC address. +func NewV1() (UUID, error) { + return DefaultGenerator.NewV1() +} + +// NewV2 returns a DCE Security UUID based on the POSIX UID/GID. +func NewV2(domain byte) (UUID, error) { + return DefaultGenerator.NewV2(domain) +} + +// NewV3 returns a UUID based on the MD5 hash of the namespace UUID and name. +func NewV3(ns UUID, name string) UUID { + return DefaultGenerator.NewV3(ns, name) +} + +// NewV4 returns a randomly generated UUID. +func NewV4() (UUID, error) { + return DefaultGenerator.NewV4() +} + +// NewV5 returns a UUID based on SHA-1 hash of the namespace UUID and name. +func NewV5(ns UUID, name string) UUID { + return DefaultGenerator.NewV5(ns, name) +} + +// Generator provides an interface for generating UUIDs. +type Generator interface { + NewV1() (UUID, error) + NewV2(domain byte) (UUID, error) + NewV3(ns UUID, name string) UUID + NewV4() (UUID, error) + NewV5(ns UUID, name string) UUID +} + +// Gen is a reference UUID generator based on the specifications laid out in +// RFC-4122 and DCE 1.1: Authentication and Security Services. This type +// satisfies the Generator interface as defined in this package. +// +// For consumers who are generating V1 UUIDs, but don't want to expose the MAC +// address of the node generating the UUIDs, the NewGenWithHWAF() function has been +// provided as a convenience. See the function's documentation for more info. +// +// The authors of this package do not feel that the majority of users will need +// to obfuscate their MAC address, and so we recommend using NewGen() to create +// a new generator. +type Gen struct { + clockSequenceOnce sync.Once + hardwareAddrOnce sync.Once + storageMutex sync.Mutex + + rand io.Reader + + epochFunc epochFunc + hwAddrFunc HWAddrFunc + lastTime uint64 + clockSequence uint16 + hardwareAddr [6]byte +} + +// interface check -- build will fail if *Gen doesn't satisfy Generator +var _ Generator = (*Gen)(nil) + +// NewGen returns a new instance of Gen with some default values set. Most +// people should use this. +func NewGen() *Gen { + return NewGenWithHWAF(defaultHWAddrFunc) +} + +// NewGenWithHWAF builds a new UUID generator with the HWAddrFunc provided. Most +// consumers should use NewGen() instead. +// +// This is used so that consumers can generate their own MAC addresses, for use +// in the generated UUIDs, if there is some concern about exposing the physical +// address of the machine generating the UUID. +// +// The Gen generator will only invoke the HWAddrFunc once, and cache that MAC +// address for all the future UUIDs generated by it. If you'd like to switch the +// MAC address being used, you'll need to create a new generator using this +// function. +func NewGenWithHWAF(hwaf HWAddrFunc) *Gen { + return &Gen{ + epochFunc: time.Now, + hwAddrFunc: hwaf, + rand: rand.Reader, + } +} + +// NewV1 returns a UUID based on the current timestamp and MAC address. +func (g *Gen) NewV1() (UUID, error) { + u := UUID{} + + timeNow, clockSeq, err := g.getClockSequence() + if err != nil { + return Nil, err + } + 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) + + hardwareAddr, err := g.getHardwareAddr() + if err != nil { + return Nil, err + } + copy(u[10:], hardwareAddr) + + u.SetVersion(V1) + u.SetVariant(VariantRFC4122) + + return u, nil +} + +// NewV2 returns a DCE Security UUID based on the POSIX UID/GID. +func (g *Gen) NewV2(domain byte) (UUID, error) { + u, err := g.NewV1() + if err != nil { + return Nil, err + } + + switch domain { + case DomainPerson: + binary.BigEndian.PutUint32(u[:], posixUID) + case DomainGroup: + binary.BigEndian.PutUint32(u[:], posixGID) + } + + u[9] = domain + + u.SetVersion(V2) + u.SetVariant(VariantRFC4122) + + return u, nil +} + +// NewV3 returns a UUID based on the MD5 hash of the namespace UUID and name. +func (g *Gen) NewV3(ns UUID, name string) UUID { + u := newFromHash(md5.New(), ns, name) + u.SetVersion(V3) + u.SetVariant(VariantRFC4122) + + return u +} + +// NewV4 returns a randomly generated UUID. +func (g *Gen) NewV4() (UUID, error) { + u := UUID{} + if _, err := io.ReadFull(g.rand, u[:]); err != nil { + return Nil, err + } + u.SetVersion(V4) + u.SetVariant(VariantRFC4122) + + return u, nil +} + +// NewV5 returns a UUID based on SHA-1 hash of the namespace UUID and name. +func (g *Gen) NewV5(ns UUID, name string) UUID { + u := newFromHash(sha1.New(), ns, name) + u.SetVersion(V5) + u.SetVariant(VariantRFC4122) + + return u +} + +// Returns the epoch and clock sequence. +func (g *Gen) getClockSequence() (uint64, uint16, error) { + var err error + g.clockSequenceOnce.Do(func() { + buf := make([]byte, 2) + if _, err = io.ReadFull(g.rand, buf); err != nil { + return + } + g.clockSequence = binary.BigEndian.Uint16(buf) + }) + if err != nil { + return 0, 0, err + } + + g.storageMutex.Lock() + defer g.storageMutex.Unlock() + + timeNow := g.getEpoch() + // Clock didn't change since last UUID generation. + // Should increase clock sequence. + if timeNow <= g.lastTime { + g.clockSequence++ + } + g.lastTime = timeNow + + return timeNow, g.clockSequence, nil +} + +// Returns the hardware address. +func (g *Gen) getHardwareAddr() ([]byte, error) { + var err error + g.hardwareAddrOnce.Do(func() { + var hwAddr net.HardwareAddr + if hwAddr, err = g.hwAddrFunc(); err == nil { + copy(g.hardwareAddr[:], hwAddr) + return + } + + // Initialize hardwareAddr randomly in case + // of real network interfaces absence. + if _, err = io.ReadFull(g.rand, g.hardwareAddr[:]); err != nil { + return + } + // Set multicast bit as recommended by RFC-4122 + g.hardwareAddr[0] |= 0x01 + }) + if err != nil { + return []byte{}, err + } + return g.hardwareAddr[:], nil +} + +// Returns the difference between UUID epoch (October 15, 1582) +// and current time in 100-nanosecond intervals. +func (g *Gen) getEpoch() uint64 { + return epochStart + uint64(g.epochFunc().UnixNano()/100) +} + +// Returns the UUID based on the hashing of the 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 +} + +// Returns the hardware address. +func defaultHWAddrFunc() (net.HardwareAddr, error) { + ifaces, err := net.Interfaces() + if err != nil { + return []byte{}, err + } + for _, iface := range ifaces { + if len(iface.HardwareAddr) >= 6 { + return iface.HardwareAddr, nil + } + } + return []byte{}, fmt.Errorf("uuid: no HW address found") +} diff --git a/cmd/ponzu/vendor/github.com/gofrs/uuid/generator_test.go b/cmd/ponzu/vendor/github.com/gofrs/uuid/generator_test.go new file mode 100644 index 0000000..35b59b7 --- /dev/null +++ b/cmd/ponzu/vendor/github.com/gofrs/uuid/generator_test.go @@ -0,0 +1,418 @@ +// Copyright (C) 2013-2018 by Maxim Bublis +// +// 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" + "crypto/rand" + "fmt" + "net" + "testing" + "time" +) + +func TestGenerator(t *testing.T) { + t.Run("NewV1", testNewV1) + t.Run("NewV2", testNewV2) + t.Run("NewV3", testNewV3) + t.Run("NewV4", testNewV4) + t.Run("NewV5", testNewV5) +} + +func testNewV1(t *testing.T) { + t.Run("Basic", testNewV1Basic) + t.Run("DifferentAcrossCalls", testNewV1DifferentAcrossCalls) + t.Run("StaleEpoch", testNewV1StaleEpoch) + t.Run("FaultyRand", testNewV1FaultyRand) + t.Run("MissingNetwork", testNewV1MissingNetwork) + t.Run("MissingNetworkFaultyRand", testNewV1MissingNetworkFaultyRand) +} + +func TestNewGenWithHWAF(t *testing.T) { + addr := []byte{0, 1, 2, 3, 4, 42} + + fn := func() (net.HardwareAddr, error) { + return addr, nil + } + + var g *Gen + var err error + var uuid UUID + + g = NewGenWithHWAF(fn) + + if g == nil { + t.Fatal("g is unexpectedly nil") + } + + uuid, err = g.NewV1() + if err != nil { + t.Fatalf("g.NewV1() err = %v, want ", err) + } + + node := uuid[10:] + + if !bytes.Equal(addr, node) { + t.Fatalf("node = %v, want %v", node, addr) + } +} + +func testNewV1Basic(t *testing.T) { + u, err := NewV1() + if err != nil { + t.Fatal(err) + } + if got, want := u.Version(), V1; got != want { + t.Errorf("generated UUID with version %d, want %d", got, want) + } + if got, want := u.Variant(), VariantRFC4122; got != want { + t.Errorf("generated UUID with variant %d, want %d", got, want) + } +} + +func testNewV1DifferentAcrossCalls(t *testing.T) { + u1, err := NewV1() + if err != nil { + t.Fatal(err) + } + u2, err := NewV1() + if err != nil { + t.Fatal(err) + } + if u1 == u2 { + t.Errorf("generated identical UUIDs across calls: %v", u1) + } +} + +func testNewV1StaleEpoch(t *testing.T) { + g := &Gen{ + epochFunc: func() time.Time { + return time.Unix(0, 0) + }, + hwAddrFunc: defaultHWAddrFunc, + rand: rand.Reader, + } + u1, err := g.NewV1() + if err != nil { + t.Fatal(err) + } + u2, err := g.NewV1() + if err != nil { + t.Fatal(err) + } + if u1 == u2 { + t.Errorf("generated identical UUIDs across calls: %v", u1) + } +} + +func testNewV1FaultyRand(t *testing.T) { + g := &Gen{ + epochFunc: time.Now, + hwAddrFunc: defaultHWAddrFunc, + rand: &faultyReader{ + readToFail: 0, // fail immediately + }, + } + u, err := g.NewV1() + if err == nil { + t.Fatalf("got %v, want error", u) + } + if u != Nil { + t.Fatalf("got %v on error, want Nil", u) + } +} + +func testNewV1MissingNetwork(t *testing.T) { + g := &Gen{ + epochFunc: time.Now, + hwAddrFunc: func() (net.HardwareAddr, error) { + return []byte{}, fmt.Errorf("uuid: no hw address found") + }, + rand: rand.Reader, + } + _, err := g.NewV1() + if err != nil { + t.Errorf("did not handle missing network interfaces: %v", err) + } +} + +func testNewV1MissingNetworkFaultyRand(t *testing.T) { + g := &Gen{ + epochFunc: time.Now, + hwAddrFunc: func() (net.HardwareAddr, error) { + return []byte{}, fmt.Errorf("uuid: no hw address found") + }, + rand: &faultyReader{ + readToFail: 1, + }, + } + u, err := g.NewV1() + if err == nil { + t.Errorf("did not error on faulty reader and missing network, got %v", u) + } +} + +func testNewV2(t *testing.T) { + t.Run("Basic", testNewV2Basic) + t.Run("DifferentAcrossCalls", testNewV2DifferentAcrossCalls) + t.Run("FaultyRand", testNewV2FaultyRand) +} + +func testNewV2Basic(t *testing.T) { + domains := []byte{ + DomainPerson, + DomainGroup, + DomainOrg, + } + for _, domain := range domains { + u, err := NewV2(domain) + if err != nil { + t.Errorf("NewV2(%d): %v", domain, err) + } + if got, want := u.Version(), V2; got != want { + t.Errorf("NewV2(%d) generated UUID with version %d, want %d", domain, got, want) + } + if got, want := u.Variant(), VariantRFC4122; got != want { + t.Errorf("NewV2(%d) generated UUID with variant %d, want %d", domain, got, want) + } + } +} + +func testNewV2DifferentAcrossCalls(t *testing.T) { + u1, err := NewV2(DomainOrg) + if err != nil { + t.Fatal(err) + } + u2, err := NewV2(DomainOrg) + if err != nil { + t.Fatal(err) + } + if u1 == u2 { + t.Errorf("generated identical UUIDs across calls: %v", u1) + } +} + +func testNewV2FaultyRand(t *testing.T) { + g := &Gen{ + epochFunc: time.Now, + hwAddrFunc: defaultHWAddrFunc, + rand: &faultyReader{ + readToFail: 0, // fail immediately + }, + } + u, err := g.NewV2(DomainPerson) + if err == nil { + t.Fatalf("got %v, want error", u) + } + if u != Nil { + t.Fatalf("got %v on error, want Nil", u) + } +} + +func testNewV3(t *testing.T) { + t.Run("Basic", testNewV3Basic) + t.Run("EqualNames", testNewV3EqualNames) + t.Run("DifferentNamespaces", testNewV3DifferentNamespaces) +} + +func testNewV3Basic(t *testing.T) { + ns := NamespaceDNS + name := "www.example.com" + u := NewV3(ns, name) + if got, want := u.Version(), V3; got != want { + t.Errorf("NewV3(%v, %q): got version %d, want %d", ns, name, got, want) + } + if got, want := u.Variant(), VariantRFC4122; got != want { + t.Errorf("NewV3(%v, %q): got variant %d, want %d", ns, name, got, want) + } + want := "5df41881-3aed-3515-88a7-2f4a814cf09e" + if got := u.String(); got != want { + t.Errorf("NewV3(%v, %q) = %q, want %q", ns, name, got, want) + } +} + +func testNewV3EqualNames(t *testing.T) { + ns := NamespaceDNS + name := "example.com" + u1 := NewV3(ns, name) + u2 := NewV3(ns, name) + if u1 != u2 { + t.Errorf("NewV3(%v, %q) generated %v and %v across two calls", ns, name, u1, u2) + } +} + +func testNewV3DifferentNamespaces(t *testing.T) { + name := "example.com" + ns1 := NamespaceDNS + ns2 := NamespaceURL + u1 := NewV3(ns1, name) + u2 := NewV3(ns2, name) + if u1 == u2 { + t.Errorf("NewV3(%v, %q) == NewV3(%d, %q) (%v)", ns1, name, ns2, name, u1) + } +} + +func testNewV4(t *testing.T) { + t.Run("Basic", testNewV4Basic) + t.Run("DifferentAcrossCalls", testNewV4DifferentAcrossCalls) + t.Run("FaultyRand", testNewV4FaultyRand) + t.Run("ShortRandomRead", testNewV4ShortRandomRead) +} + +func testNewV4Basic(t *testing.T) { + u, err := NewV4() + if err != nil { + t.Fatal(err) + } + if got, want := u.Version(), V4; got != want { + t.Errorf("got version %d, want %d", got, want) + } + if got, want := u.Variant(), VariantRFC4122; got != want { + t.Errorf("got variant %d, want %d", got, want) + } +} + +func testNewV4DifferentAcrossCalls(t *testing.T) { + u1, err := NewV4() + if err != nil { + t.Fatal(err) + } + u2, err := NewV4() + if err != nil { + t.Fatal(err) + } + if u1 == u2 { + t.Errorf("generated identical UUIDs across calls: %v", u1) + } +} + +func testNewV4FaultyRand(t *testing.T) { + g := &Gen{ + epochFunc: time.Now, + hwAddrFunc: defaultHWAddrFunc, + rand: &faultyReader{ + readToFail: 0, // fail immediately + }, + } + u, err := g.NewV4() + if err == nil { + t.Errorf("got %v, nil error", u) + } +} + +func testNewV4ShortRandomRead(t *testing.T) { + g := &Gen{ + epochFunc: time.Now, + hwAddrFunc: func() (net.HardwareAddr, error) { + return []byte{}, fmt.Errorf("uuid: no hw address found") + }, + rand: bytes.NewReader([]byte{42}), + } + u, err := g.NewV4() + if err == nil { + t.Errorf("got %v, nil error", u) + } +} + +func testNewV5(t *testing.T) { + t.Run("Basic", testNewV5Basic) + t.Run("EqualNames", testNewV5EqualNames) + t.Run("DifferentNamespaces", testNewV5DifferentNamespaces) +} + +func testNewV5Basic(t *testing.T) { + ns := NamespaceDNS + name := "www.example.com" + u := NewV5(ns, name) + if got, want := u.Version(), V5; got != want { + t.Errorf("NewV5(%v, %q): got version %d, want %d", ns, name, got, want) + } + if got, want := u.Variant(), VariantRFC4122; got != want { + t.Errorf("NewV5(%v, %q): got variant %d, want %d", ns, name, got, want) + } + want := "2ed6657d-e927-568b-95e1-2665a8aea6a2" + if got := u.String(); got != want { + t.Errorf("NewV5(%v, %q) = %q, want %q", ns, name, got, want) + } +} + +func testNewV5EqualNames(t *testing.T) { + ns := NamespaceDNS + name := "example.com" + u1 := NewV5(ns, name) + u2 := NewV5(ns, name) + if u1 != u2 { + t.Errorf("NewV5(%v, %q) generated %v and %v across two calls", ns, name, u1, u2) + } +} + +func testNewV5DifferentNamespaces(t *testing.T) { + name := "example.com" + ns1 := NamespaceDNS + ns2 := NamespaceURL + u1 := NewV5(ns1, name) + u2 := NewV5(ns2, name) + if u1 == u2 { + t.Errorf("NewV5(%v, %q) == NewV5(%v, %q) (%v)", ns1, name, ns2, name, u1) + } +} + +func BenchmarkGenerator(b *testing.B) { + b.Run("NewV1", func(b *testing.B) { + for i := 0; i < b.N; i++ { + NewV1() + } + }) + b.Run("NewV2", func(b *testing.B) { + for i := 0; i < b.N; i++ { + NewV2(DomainOrg) + } + }) + b.Run("NewV3", func(b *testing.B) { + for i := 0; i < b.N; i++ { + NewV3(NamespaceDNS, "www.example.com") + } + }) + b.Run("NewV4", func(b *testing.B) { + for i := 0; i < b.N; i++ { + NewV4() + } + }) + b.Run("NewV5", func(b *testing.B) { + for i := 0; i < b.N; i++ { + NewV5(NamespaceDNS, "www.example.com") + } + }) +} + +type faultyReader struct { + callsNum int + readToFail int // Read call number to fail +} + +func (r *faultyReader) Read(dest []byte) (int, error) { + r.callsNum++ + if (r.callsNum - 1) == r.readToFail { + return 0, fmt.Errorf("io: reader is faulty") + } + return rand.Read(dest) +} diff --git a/cmd/ponzu/vendor/github.com/gofrs/uuid/sql.go b/cmd/ponzu/vendor/github.com/gofrs/uuid/sql.go new file mode 100644 index 0000000..78558ab --- /dev/null +++ b/cmd/ponzu/vendor/github.com/gofrs/uuid/sql.go @@ -0,0 +1,105 @@ +// Copyright (C) 2013-2018 by Maxim Bublis +// +// 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" + "database/sql/driver" + "encoding/json" + "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 will be handled by UnmarshalBinary, while +// a longer byte slice or a string will be 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) +} + +// MarshalJSON marshals the NullUUID as null or the nested UUID +func (u NullUUID) MarshalJSON() ([]byte, error) { + if !u.Valid { + return json.Marshal(nil) + } + + return json.Marshal(u.UUID) +} + +// UnmarshalJSON unmarshals a NullUUID +func (u *NullUUID) UnmarshalJSON(b []byte) error { + if bytes.Equal(b, []byte("null")) { + u.UUID, u.Valid = Nil, false + return nil + } + + if err := json.Unmarshal(b, &u.UUID); err != nil { + return err + } + + u.Valid = true + + return nil +} diff --git a/cmd/ponzu/vendor/github.com/gofrs/uuid/sql_test.go b/cmd/ponzu/vendor/github.com/gofrs/uuid/sql_test.go new file mode 100644 index 0000000..a2d3941 --- /dev/null +++ b/cmd/ponzu/vendor/github.com/gofrs/uuid/sql_test.go @@ -0,0 +1,305 @@ +// Copyright (C) 2013-2018 by Maxim Bublis +// +// 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 ( + "encoding/json" + "fmt" + "testing" +) + +func TestSQL(t *testing.T) { + t.Run("Value", testSQLValue) + t.Run("Scan", func(t *testing.T) { + t.Run("Binary", testSQLScanBinary) + t.Run("String", testSQLScanString) + t.Run("Text", testSQLScanText) + t.Run("Unsupported", testSQLScanUnsupported) + t.Run("Nil", testSQLScanNil) + }) +} + +func testSQLValue(t *testing.T) { + v, err := codecTestUUID.Value() + if err != nil { + t.Fatal(err) + } + got, ok := v.(string) + if !ok { + t.Fatalf("Value() returned %T, want string", v) + } + if want := codecTestUUID.String(); got != want { + t.Errorf("Value() == %q, want %q", got, want) + } +} + +func testSQLScanBinary(t *testing.T) { + got := UUID{} + err := got.Scan(codecTestData) + if err != nil { + t.Fatal(err) + } + if got != codecTestUUID { + t.Errorf("Scan(%x): got %v, want %v", codecTestData, got, codecTestUUID) + } +} + +func testSQLScanString(t *testing.T) { + s := "6ba7b810-9dad-11d1-80b4-00c04fd430c8" + got := UUID{} + err := got.Scan(s) + if err != nil { + t.Fatal(err) + } + if got != codecTestUUID { + t.Errorf("Scan(%q): got %v, want %v", s, got, codecTestUUID) + } +} + +func testSQLScanText(t *testing.T) { + text := []byte("6ba7b810-9dad-11d1-80b4-00c04fd430c8") + got := UUID{} + err := got.Scan(text) + if err != nil { + t.Fatal(err) + } + if got != codecTestUUID { + t.Errorf("Scan(%q): got %v, want %v", text, got, codecTestUUID) + } +} + +func testSQLScanUnsupported(t *testing.T) { + unsupported := []interface{}{ + true, + 42, + } + for _, v := range unsupported { + got := UUID{} + err := got.Scan(v) + if err == nil { + t.Errorf("Scan(%T) succeeded, got %v", v, got) + } + } +} + +func testSQLScanNil(t *testing.T) { + got := UUID{} + err := got.Scan(nil) + if err == nil { + t.Errorf("Scan(nil) succeeded, got %v", got) + } +} + +func TestNullUUID(t *testing.T) { + t.Run("Value", func(t *testing.T) { + t.Run("Nil", testNullUUIDValueNil) + t.Run("Valid", testNullUUIDValueValid) + }) + + t.Run("Scan", func(t *testing.T) { + t.Run("Nil", testNullUUIDScanNil) + t.Run("Valid", testNullUUIDScanValid) + }) + + t.Run("MarshalJSON", func(t *testing.T) { + t.Run("Nil", testNullUUIDMarshalJSONNil) + t.Run("Null", testNullUUIDMarshalJSONNull) + t.Run("Valid", testNullUUIDMarshalJSONValid) + }) + + t.Run("UnmarshalJSON", func(t *testing.T) { + t.Run("Nil", testNullUUIDUnmarshalJSONNil) + t.Run("Null", testNullUUIDUnmarshalJSONNull) + t.Run("Valid", testNullUUIDUnmarshalJSONValid) + t.Run("Malformed", testNullUUIDUnmarshalJSONMalformed) + }) +} + +func testNullUUIDValueNil(t *testing.T) { + nu := NullUUID{} + got, err := nu.Value() + if got != nil { + t.Errorf("null NullUUID.Value returned non-nil driver.Value") + } + if err != nil { + t.Errorf("null NullUUID.Value returned non-nil error") + } +} + +func testNullUUIDValueValid(t *testing.T) { + nu := NullUUID{ + Valid: true, + UUID: codecTestUUID, + } + got, err := nu.Value() + if err != nil { + t.Fatal(err) + } + s, ok := got.(string) + if !ok { + t.Errorf("Value() returned %T, want string", got) + } + want := "6ba7b810-9dad-11d1-80b4-00c04fd430c8" + if s != want { + t.Errorf("%v.Value() == %s, want %s", nu, s, want) + } +} + +func testNullUUIDScanNil(t *testing.T) { + u := NullUUID{} + err := u.Scan(nil) + if err != nil { + t.Fatal(err) + } + if u.Valid { + t.Error("NullUUID is valid after Scan(nil)") + } + if u.UUID != Nil { + t.Errorf("NullUUID.UUID is %v after Scan(nil) want Nil", u.UUID) + } +} + +func testNullUUIDScanValid(t *testing.T) { + s := "6ba7b810-9dad-11d1-80b4-00c04fd430c8" + u := NullUUID{} + err := u.Scan(s) + if err != nil { + t.Fatal(err) + } + if !u.Valid { + t.Errorf("Valid == false after Scan(%q)", s) + } + if u.UUID != codecTestUUID { + t.Errorf("UUID == %v after Scan(%q), want %v", u.UUID, s, codecTestUUID) + } +} + +func testNullUUIDMarshalJSONNil(t *testing.T) { + u := NullUUID{Valid: true} + + data, err := u.MarshalJSON() + if err != nil { + t.Fatalf("(%#v).MarshalJSON err want: , got: %v", u, err) + } + + dataStr := string(data) + + if dataStr != fmt.Sprintf("%q", Nil) { + t.Fatalf("(%#v).MarshalJSON value want: %s, got: %s", u, Nil, dataStr) + } +} + +func testNullUUIDMarshalJSONValid(t *testing.T) { + u := NullUUID{ + Valid: true, + UUID: codecTestUUID, + } + + data, err := u.MarshalJSON() + if err != nil { + t.Fatalf("(%#v).MarshalJSON err want: , got: %v", u, err) + } + + dataStr := string(data) + + if dataStr != fmt.Sprintf("%q", codecTestUUID) { + t.Fatalf("(%#v).MarshalJSON value want: %s, got: %s", u, codecTestUUID, dataStr) + } +} + +func testNullUUIDMarshalJSONNull(t *testing.T) { + u := NullUUID{} + + data, err := u.MarshalJSON() + if err != nil { + t.Fatalf("(%#v).MarshalJSON err want: , got: %v", u, err) + } + + dataStr := string(data) + + if dataStr != "null" { + t.Fatalf("(%#v).MarshalJSON value want: %s, got: %s", u, "null", dataStr) + } +} + +func testNullUUIDUnmarshalJSONNil(t *testing.T) { + var u NullUUID + + data := []byte(`"00000000-0000-0000-0000-000000000000"`) + + if err := json.Unmarshal(data, &u); err != nil { + t.Fatalf("json.Unmarshal err = %v, want ", err) + } + + if !u.Valid { + t.Fatalf("u.Valid = false, want true") + } + + if u.UUID != Nil { + t.Fatalf("u.UUID = %v, want %v", u.UUID, Nil) + } +} + +func testNullUUIDUnmarshalJSONNull(t *testing.T) { + var u NullUUID + + data := []byte(`null`) + + if err := json.Unmarshal(data, &u); err != nil { + t.Fatalf("json.Unmarshal err = %v, want ", err) + } + + if u.Valid { + t.Fatalf("u.Valid = true, want false") + } + + if u.UUID != Nil { + t.Fatalf("u.UUID = %v, want %v", u.UUID, Nil) + } +} +func testNullUUIDUnmarshalJSONValid(t *testing.T) { + var u NullUUID + + data := []byte(`"6ba7b810-9dad-11d1-80b4-00c04fd430c8"`) + + if err := json.Unmarshal(data, &u); err != nil { + t.Fatalf("json.Unmarshal err = %v, want ", err) + } + + if !u.Valid { + t.Fatalf("u.Valid = false, want true") + } + + if u.UUID != codecTestUUID { + t.Fatalf("u.UUID = %v, want %v", u.UUID, Nil) + } +} + +func testNullUUIDUnmarshalJSONMalformed(t *testing.T) { + var u NullUUID + + data := []byte(`257`) + + if err := json.Unmarshal(data, &u); err == nil { + t.Fatal("json.Unmarshal err = , want error") + } +} diff --git a/cmd/ponzu/vendor/github.com/gofrs/uuid/testdata/corpus/1416586f4a34d02bcb506f6107b40df512b9f2f9 b/cmd/ponzu/vendor/github.com/gofrs/uuid/testdata/corpus/1416586f4a34d02bcb506f6107b40df512b9f2f9 new file mode 100644 index 0000000..cfb2480 --- /dev/null +++ b/cmd/ponzu/vendor/github.com/gofrs/uuid/testdata/corpus/1416586f4a34d02bcb506f6107b40df512b9f2f9 @@ -0,0 +1 @@ +zba7b810-9dad-11d1-80b4-00c04fd4 \ No newline at end of file diff --git a/cmd/ponzu/vendor/github.com/gofrs/uuid/testdata/corpus/3b46a7e7b02ec193581e6c9fa2c8a72f50a64e08-1 b/cmd/ponzu/vendor/github.com/gofrs/uuid/testdata/corpus/3b46a7e7b02ec193581e6c9fa2c8a72f50a64e08-1 new file mode 100644 index 0000000..77b9420 --- /dev/null +++ b/cmd/ponzu/vendor/github.com/gofrs/uuid/testdata/corpus/3b46a7e7b02ec193581e6c9fa2c8a72f50a64e08-1 @@ -0,0 +1 @@ +6ba7b810-9dad-11d1-80F4-00c"4fd430c8 \ No newline at end of file diff --git a/cmd/ponzu/vendor/github.com/gofrs/uuid/testdata/corpus/50c54bb75fcfdc488f162bf2f0c6dec6103bfa18-5 b/cmd/ponzu/vendor/github.com/gofrs/uuid/testdata/corpus/50c54bb75fcfdc488f162bf2f0c6dec6103bfa18-5 new file mode 100644 index 0000000..17e57ce --- /dev/null +++ b/cmd/ponzu/vendor/github.com/gofrs/uuid/testdata/corpus/50c54bb75fcfdc488f162bf2f0c6dec6103bfa18-5 @@ -0,0 +1 @@ +6ad1DdE8dda91DdE80F400c0Bool30t: \ No newline at end of file diff --git a/cmd/ponzu/vendor/github.com/gofrs/uuid/testdata/corpus/69c581ab749cbd56be8684d3a58ac2cfab9af0f4-5 b/cmd/ponzu/vendor/github.com/gofrs/uuid/testdata/corpus/69c581ab749cbd56be8684d3a58ac2cfab9af0f4-5 new file mode 100644 index 0000000..f53c1bd --- /dev/null +++ b/cmd/ponzu/vendor/github.com/gofrs/uuid/testdata/corpus/69c581ab749cbd56be8684d3a58ac2cfab9af0f4-5 @@ -0,0 +1 @@ +6ba7b810Edad1DdE80F400c0Bool30c8 \ No newline at end of file diff --git a/cmd/ponzu/vendor/github.com/gofrs/uuid/testdata/corpus/752bf000e0bff06777dd0d6f0be6353844de678a-3 b/cmd/ponzu/vendor/github.com/gofrs/uuid/testdata/corpus/752bf000e0bff06777dd0d6f0be6353844de678a-3 new file mode 100644 index 0000000..6bcb9a1 --- /dev/null +++ b/cmd/ponzu/vendor/github.com/gofrs/uuid/testdata/corpus/752bf000e0bff06777dd0d6f0be6353844de678a-3 @@ -0,0 +1 @@ +6ba7b8109dad1Dd180F400c0Bool30c8 \ No newline at end of file diff --git a/cmd/ponzu/vendor/github.com/gofrs/uuid/testdata/corpus/a4483762d4ece8466d82cca5cacd35a0829c4e60-2 b/cmd/ponzu/vendor/github.com/gofrs/uuid/testdata/corpus/a4483762d4ece8466d82cca5cacd35a0829c4e60-2 new file mode 100644 index 0000000..88427b7 --- /dev/null +++ b/cmd/ponzu/vendor/github.com/gofrs/uuid/testdata/corpus/a4483762d4ece8466d82cca5cacd35a0829c4e60-2 @@ -0,0 +1 @@ +6ba7b810-9dad-11d1-80F4-F0c"4fd430c8 \ No newline at end of file diff --git a/cmd/ponzu/vendor/github.com/gofrs/uuid/testdata/corpus/d0952c45e0c823fc5cc12bcf7d9b877d150ab523-1 b/cmd/ponzu/vendor/github.com/gofrs/uuid/testdata/corpus/d0952c45e0c823fc5cc12bcf7d9b877d150ab523-1 new file mode 100644 index 0000000..b3b8228 --- /dev/null +++ b/cmd/ponzu/vendor/github.com/gofrs/uuid/testdata/corpus/d0952c45e0c823fc5cc12bcf7d9b877d150ab523-1 @@ -0,0 +1 @@ +6ba7b8109dad11d180b400c0Bool30c8 \ No newline at end of file diff --git a/cmd/ponzu/vendor/github.com/gofrs/uuid/testdata/corpus/da39a3ee5e6b4b0d3255bfef95601890afd80709 b/cmd/ponzu/vendor/github.com/gofrs/uuid/testdata/corpus/da39a3ee5e6b4b0d3255bfef95601890afd80709 new file mode 100644 index 0000000..e69de29 diff --git a/cmd/ponzu/vendor/github.com/gofrs/uuid/testdata/corpus/e2b84d2065846891f18ae109b12e01d224e1c7c3-4 b/cmd/ponzu/vendor/github.com/gofrs/uuid/testdata/corpus/e2b84d2065846891f18ae109b12e01d224e1c7c3-4 new file mode 100644 index 0000000..abff4da --- /dev/null +++ b/cmd/ponzu/vendor/github.com/gofrs/uuid/testdata/corpus/e2b84d2065846891f18ae109b12e01d224e1c7c3-4 @@ -0,0 +1 @@ +6ba7b8109dad1DdE80F400c0Bool30c8 \ No newline at end of file diff --git a/cmd/ponzu/vendor/github.com/gofrs/uuid/testdata/corpus/e320d749435115e874f77420e17d0937e07f69f3-2 b/cmd/ponzu/vendor/github.com/gofrs/uuid/testdata/corpus/e320d749435115e874f77420e17d0937e07f69f3-2 new file mode 100644 index 0000000..b71e8b2 --- /dev/null +++ b/cmd/ponzu/vendor/github.com/gofrs/uuid/testdata/corpus/e320d749435115e874f77420e17d0937e07f69f3-2 @@ -0,0 +1 @@ +6ba7b8109dad1Dd180b400c0Bool30c8 \ No newline at end of file diff --git a/cmd/ponzu/vendor/github.com/gofrs/uuid/testdata/corpus/ed132d47d757f6468443a22df8a2a965efb34098-7 b/cmd/ponzu/vendor/github.com/gofrs/uuid/testdata/corpus/ed132d47d757f6468443a22df8a2a965efb34098-7 new file mode 100644 index 0000000..a40ccde --- /dev/null +++ b/cmd/ponzu/vendor/github.com/gofrs/uuid/testdata/corpus/ed132d47d757f6468443a22df8a2a965efb34098-7 @@ -0,0 +1 @@ +6ba1DdE8dDAE8DdE80F400c0BoUl30to \ No newline at end of file diff --git a/cmd/ponzu/vendor/github.com/gofrs/uuid/testdata/corpus/eeefb01f7bb3c627aedb292c994b20f739ffd613-6 b/cmd/ponzu/vendor/github.com/gofrs/uuid/testdata/corpus/eeefb01f7bb3c627aedb292c994b20f739ffd613-6 new file mode 100644 index 0000000..4117221 --- /dev/null +++ b/cmd/ponzu/vendor/github.com/gofrs/uuid/testdata/corpus/eeefb01f7bb3c627aedb292c994b20f739ffd613-6 @@ -0,0 +1 @@ +6ad1DdE8dDdE8DdE80F400c0Bool30t: \ No newline at end of file diff --git a/cmd/ponzu/vendor/github.com/gofrs/uuid/testdata/corpus/seed_invalid_0 b/cmd/ponzu/vendor/github.com/gofrs/uuid/testdata/corpus/seed_invalid_0 new file mode 100755 index 0000000..02965f8 --- /dev/null +++ b/cmd/ponzu/vendor/github.com/gofrs/uuid/testdata/corpus/seed_invalid_0 @@ -0,0 +1 @@ +6ba7b810-9dad-11d1-80b4-00c04fd430c \ No newline at end of file diff --git a/cmd/ponzu/vendor/github.com/gofrs/uuid/testdata/corpus/seed_invalid_1 b/cmd/ponzu/vendor/github.com/gofrs/uuid/testdata/corpus/seed_invalid_1 new file mode 100755 index 0000000..3c7f5f6 --- /dev/null +++ b/cmd/ponzu/vendor/github.com/gofrs/uuid/testdata/corpus/seed_invalid_1 @@ -0,0 +1 @@ +6ba7b8109dad11d180b400c04fd430c \ No newline at end of file diff --git a/cmd/ponzu/vendor/github.com/gofrs/uuid/testdata/corpus/seed_invalid_10 b/cmd/ponzu/vendor/github.com/gofrs/uuid/testdata/corpus/seed_invalid_10 new file mode 100755 index 0000000..ec890f3 --- /dev/null +++ b/cmd/ponzu/vendor/github.com/gofrs/uuid/testdata/corpus/seed_invalid_10 @@ -0,0 +1 @@ +uuid:urn:6ba7b810-9dad-11d1-80b4-00c04fd430c8 \ No newline at end of file diff --git a/cmd/ponzu/vendor/github.com/gofrs/uuid/testdata/corpus/seed_invalid_11 b/cmd/ponzu/vendor/github.com/gofrs/uuid/testdata/corpus/seed_invalid_11 new file mode 100755 index 0000000..266a823 --- /dev/null +++ b/cmd/ponzu/vendor/github.com/gofrs/uuid/testdata/corpus/seed_invalid_11 @@ -0,0 +1 @@ +uuid:urn:6ba7b8109dad11d180b400c04fd430c8 \ No newline at end of file diff --git a/cmd/ponzu/vendor/github.com/gofrs/uuid/testdata/corpus/seed_invalid_12 b/cmd/ponzu/vendor/github.com/gofrs/uuid/testdata/corpus/seed_invalid_12 new file mode 100755 index 0000000..06f8ad2 --- /dev/null +++ b/cmd/ponzu/vendor/github.com/gofrs/uuid/testdata/corpus/seed_invalid_12 @@ -0,0 +1 @@ +6ba7b8109-dad-11d1-80b4-00c04fd430c8 \ No newline at end of file diff --git a/cmd/ponzu/vendor/github.com/gofrs/uuid/testdata/corpus/seed_invalid_13 b/cmd/ponzu/vendor/github.com/gofrs/uuid/testdata/corpus/seed_invalid_13 new file mode 100755 index 0000000..302b9c3 --- /dev/null +++ b/cmd/ponzu/vendor/github.com/gofrs/uuid/testdata/corpus/seed_invalid_13 @@ -0,0 +1 @@ +6ba7b810-9dad1-1d1-80b4-00c04fd430c8 \ No newline at end of file diff --git a/cmd/ponzu/vendor/github.com/gofrs/uuid/testdata/corpus/seed_invalid_14 b/cmd/ponzu/vendor/github.com/gofrs/uuid/testdata/corpus/seed_invalid_14 new file mode 100755 index 0000000..c37896c --- /dev/null +++ b/cmd/ponzu/vendor/github.com/gofrs/uuid/testdata/corpus/seed_invalid_14 @@ -0,0 +1 @@ +6ba7b810-9dad-11d18-0b4-00c04fd430c8 \ No newline at end of file diff --git a/cmd/ponzu/vendor/github.com/gofrs/uuid/testdata/corpus/seed_invalid_15 b/cmd/ponzu/vendor/github.com/gofrs/uuid/testdata/corpus/seed_invalid_15 new file mode 100755 index 0000000..bb279bd --- /dev/null +++ b/cmd/ponzu/vendor/github.com/gofrs/uuid/testdata/corpus/seed_invalid_15 @@ -0,0 +1 @@ +6ba7b810-9dad-11d1-80b40-0c04fd430c8 \ No newline at end of file diff --git a/cmd/ponzu/vendor/github.com/gofrs/uuid/testdata/corpus/seed_invalid_16 b/cmd/ponzu/vendor/github.com/gofrs/uuid/testdata/corpus/seed_invalid_16 new file mode 100755 index 0000000..2c8be7d --- /dev/null +++ b/cmd/ponzu/vendor/github.com/gofrs/uuid/testdata/corpus/seed_invalid_16 @@ -0,0 +1 @@ +6ba7b810+9dad+11d1+80b4+00c04fd430c8 \ No newline at end of file diff --git a/cmd/ponzu/vendor/github.com/gofrs/uuid/testdata/corpus/seed_invalid_17 b/cmd/ponzu/vendor/github.com/gofrs/uuid/testdata/corpus/seed_invalid_17 new file mode 100755 index 0000000..129f752 --- /dev/null +++ b/cmd/ponzu/vendor/github.com/gofrs/uuid/testdata/corpus/seed_invalid_17 @@ -0,0 +1 @@ +(6ba7b810-9dad-11d1-80b4-00c04fd430c8} \ No newline at end of file diff --git a/cmd/ponzu/vendor/github.com/gofrs/uuid/testdata/corpus/seed_invalid_18 b/cmd/ponzu/vendor/github.com/gofrs/uuid/testdata/corpus/seed_invalid_18 new file mode 100755 index 0000000..ed41a50 --- /dev/null +++ b/cmd/ponzu/vendor/github.com/gofrs/uuid/testdata/corpus/seed_invalid_18 @@ -0,0 +1 @@ +{6ba7b810-9dad-11d1-80b4-00c04fd430c8> \ No newline at end of file diff --git a/cmd/ponzu/vendor/github.com/gofrs/uuid/testdata/corpus/seed_invalid_19 b/cmd/ponzu/vendor/github.com/gofrs/uuid/testdata/corpus/seed_invalid_19 new file mode 100755 index 0000000..a296f9e --- /dev/null +++ b/cmd/ponzu/vendor/github.com/gofrs/uuid/testdata/corpus/seed_invalid_19 @@ -0,0 +1 @@ +zba7b810-9dad-11d1-80b4-00c04fd430c8 \ No newline at end of file diff --git a/cmd/ponzu/vendor/github.com/gofrs/uuid/testdata/corpus/seed_invalid_2 b/cmd/ponzu/vendor/github.com/gofrs/uuid/testdata/corpus/seed_invalid_2 new file mode 100755 index 0000000..e294615 --- /dev/null +++ b/cmd/ponzu/vendor/github.com/gofrs/uuid/testdata/corpus/seed_invalid_2 @@ -0,0 +1 @@ +6ba7b8109dad11d180b400c04fd430q8 \ No newline at end of file diff --git a/cmd/ponzu/vendor/github.com/gofrs/uuid/testdata/corpus/seed_invalid_20 b/cmd/ponzu/vendor/github.com/gofrs/uuid/testdata/corpus/seed_invalid_20 new file mode 100755 index 0000000..6e5d2d5 --- /dev/null +++ b/cmd/ponzu/vendor/github.com/gofrs/uuid/testdata/corpus/seed_invalid_20 @@ -0,0 +1 @@ +6ba7b810-9dad11d180b400c04fd430c8 \ No newline at end of file diff --git a/cmd/ponzu/vendor/github.com/gofrs/uuid/testdata/corpus/seed_invalid_21 b/cmd/ponzu/vendor/github.com/gofrs/uuid/testdata/corpus/seed_invalid_21 new file mode 100755 index 0000000..53ebad9 --- /dev/null +++ b/cmd/ponzu/vendor/github.com/gofrs/uuid/testdata/corpus/seed_invalid_21 @@ -0,0 +1 @@ +6ba7b8109dad-11d180b400c04fd430c8 \ No newline at end of file diff --git a/cmd/ponzu/vendor/github.com/gofrs/uuid/testdata/corpus/seed_invalid_22 b/cmd/ponzu/vendor/github.com/gofrs/uuid/testdata/corpus/seed_invalid_22 new file mode 100755 index 0000000..c08019c --- /dev/null +++ b/cmd/ponzu/vendor/github.com/gofrs/uuid/testdata/corpus/seed_invalid_22 @@ -0,0 +1 @@ +6ba7b8109dad11d1-80b400c04fd430c8 \ No newline at end of file diff --git a/cmd/ponzu/vendor/github.com/gofrs/uuid/testdata/corpus/seed_invalid_23 b/cmd/ponzu/vendor/github.com/gofrs/uuid/testdata/corpus/seed_invalid_23 new file mode 100755 index 0000000..8c32062 --- /dev/null +++ b/cmd/ponzu/vendor/github.com/gofrs/uuid/testdata/corpus/seed_invalid_23 @@ -0,0 +1 @@ +6ba7b8109dad11d180b4-00c04fd430c8 \ No newline at end of file diff --git a/cmd/ponzu/vendor/github.com/gofrs/uuid/testdata/corpus/seed_invalid_3 b/cmd/ponzu/vendor/github.com/gofrs/uuid/testdata/corpus/seed_invalid_3 new file mode 100755 index 0000000..2afa5c9 --- /dev/null +++ b/cmd/ponzu/vendor/github.com/gofrs/uuid/testdata/corpus/seed_invalid_3 @@ -0,0 +1 @@ +6ba7b810-9dad-11d1-80b4-00c04fd430c8= \ No newline at end of file diff --git a/cmd/ponzu/vendor/github.com/gofrs/uuid/testdata/corpus/seed_invalid_4 b/cmd/ponzu/vendor/github.com/gofrs/uuid/testdata/corpus/seed_invalid_4 new file mode 100755 index 0000000..a5f4d4e --- /dev/null +++ b/cmd/ponzu/vendor/github.com/gofrs/uuid/testdata/corpus/seed_invalid_4 @@ -0,0 +1 @@ +6ba7b810-9dad-11d1-80b4-00c04fd430c8} \ No newline at end of file diff --git a/cmd/ponzu/vendor/github.com/gofrs/uuid/testdata/corpus/seed_invalid_5 b/cmd/ponzu/vendor/github.com/gofrs/uuid/testdata/corpus/seed_invalid_5 new file mode 100755 index 0000000..a78e7ed --- /dev/null +++ b/cmd/ponzu/vendor/github.com/gofrs/uuid/testdata/corpus/seed_invalid_5 @@ -0,0 +1 @@ +{6ba7b810-9dad-11d1-80b4-00c04fd430c8}f \ No newline at end of file diff --git a/cmd/ponzu/vendor/github.com/gofrs/uuid/testdata/corpus/seed_invalid_6 b/cmd/ponzu/vendor/github.com/gofrs/uuid/testdata/corpus/seed_invalid_6 new file mode 100755 index 0000000..f14ded5 --- /dev/null +++ b/cmd/ponzu/vendor/github.com/gofrs/uuid/testdata/corpus/seed_invalid_6 @@ -0,0 +1 @@ +6ba7b810-9dad-11d1-80b4-00c04fd430c800c04fd430c8 \ No newline at end of file diff --git a/cmd/ponzu/vendor/github.com/gofrs/uuid/testdata/corpus/seed_invalid_7 b/cmd/ponzu/vendor/github.com/gofrs/uuid/testdata/corpus/seed_invalid_7 new file mode 100755 index 0000000..76e0980 --- /dev/null +++ b/cmd/ponzu/vendor/github.com/gofrs/uuid/testdata/corpus/seed_invalid_7 @@ -0,0 +1 @@ +ba7b8109dad11d180b400c04fd430c8} \ No newline at end of file diff --git a/cmd/ponzu/vendor/github.com/gofrs/uuid/testdata/corpus/seed_invalid_8 b/cmd/ponzu/vendor/github.com/gofrs/uuid/testdata/corpus/seed_invalid_8 new file mode 100755 index 0000000..f89e744 --- /dev/null +++ b/cmd/ponzu/vendor/github.com/gofrs/uuid/testdata/corpus/seed_invalid_8 @@ -0,0 +1 @@ +6ba7b8109dad11d180b400c04fd430c86ba7b8109dad11d180b400c04fd430c8 \ No newline at end of file diff --git a/cmd/ponzu/vendor/github.com/gofrs/uuid/testdata/corpus/seed_invalid_9 b/cmd/ponzu/vendor/github.com/gofrs/uuid/testdata/corpus/seed_invalid_9 new file mode 100755 index 0000000..80ad554 --- /dev/null +++ b/cmd/ponzu/vendor/github.com/gofrs/uuid/testdata/corpus/seed_invalid_9 @@ -0,0 +1 @@ +urn:uuid:{6ba7b810-9dad-11d1-80b4-00c04fd430c8} \ No newline at end of file diff --git a/cmd/ponzu/vendor/github.com/gofrs/uuid/testdata/corpus/seed_valid_BracedCanonical b/cmd/ponzu/vendor/github.com/gofrs/uuid/testdata/corpus/seed_valid_BracedCanonical new file mode 100755 index 0000000..23918e3 --- /dev/null +++ b/cmd/ponzu/vendor/github.com/gofrs/uuid/testdata/corpus/seed_valid_BracedCanonical @@ -0,0 +1 @@ +{6ba7b810-9dad-11d1-80b4-00c04fd430c8} \ No newline at end of file diff --git a/cmd/ponzu/vendor/github.com/gofrs/uuid/testdata/corpus/seed_valid_BracedHashlike b/cmd/ponzu/vendor/github.com/gofrs/uuid/testdata/corpus/seed_valid_BracedHashlike new file mode 100755 index 0000000..726e1df --- /dev/null +++ b/cmd/ponzu/vendor/github.com/gofrs/uuid/testdata/corpus/seed_valid_BracedHashlike @@ -0,0 +1 @@ +{6ba7b8109dad11d180b400c04fd430c8} \ No newline at end of file diff --git a/cmd/ponzu/vendor/github.com/gofrs/uuid/testdata/corpus/seed_valid_Canonical b/cmd/ponzu/vendor/github.com/gofrs/uuid/testdata/corpus/seed_valid_Canonical new file mode 100755 index 0000000..719471c --- /dev/null +++ b/cmd/ponzu/vendor/github.com/gofrs/uuid/testdata/corpus/seed_valid_Canonical @@ -0,0 +1 @@ +6ba7b810-9dad-11d1-80b4-00c04fd430c8 \ No newline at end of file diff --git a/cmd/ponzu/vendor/github.com/gofrs/uuid/testdata/corpus/seed_valid_Hashlike b/cmd/ponzu/vendor/github.com/gofrs/uuid/testdata/corpus/seed_valid_Hashlike new file mode 100755 index 0000000..327f806 --- /dev/null +++ b/cmd/ponzu/vendor/github.com/gofrs/uuid/testdata/corpus/seed_valid_Hashlike @@ -0,0 +1 @@ +6ba7b8109dad11d180b400c04fd430c8 \ No newline at end of file diff --git a/cmd/ponzu/vendor/github.com/gofrs/uuid/testdata/corpus/seed_valid_URNCanonical b/cmd/ponzu/vendor/github.com/gofrs/uuid/testdata/corpus/seed_valid_URNCanonical new file mode 100755 index 0000000..78981af --- /dev/null +++ b/cmd/ponzu/vendor/github.com/gofrs/uuid/testdata/corpus/seed_valid_URNCanonical @@ -0,0 +1 @@ +urn:uuid:6ba7b810-9dad-11d1-80b4-00c04fd430c8 \ No newline at end of file diff --git a/cmd/ponzu/vendor/github.com/gofrs/uuid/testdata/corpus/seed_valid_URNHashlike b/cmd/ponzu/vendor/github.com/gofrs/uuid/testdata/corpus/seed_valid_URNHashlike new file mode 100755 index 0000000..089ec0c --- /dev/null +++ b/cmd/ponzu/vendor/github.com/gofrs/uuid/testdata/corpus/seed_valid_URNHashlike @@ -0,0 +1 @@ +urn:uuid:6ba7b8109dad11d180b400c04fd430c8 \ No newline at end of file diff --git a/cmd/ponzu/vendor/github.com/gofrs/uuid/uuid.go b/cmd/ponzu/vendor/github.com/gofrs/uuid/uuid.go new file mode 100644 index 0000000..a2558b6 --- /dev/null +++ b/cmd/ponzu/vendor/github.com/gofrs/uuid/uuid.go @@ -0,0 +1,159 @@ +// Copyright (C) 2013-2018 by Maxim Bublis +// +// 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 implementations of the Universally Unique Identifier (UUID), as specified in RFC-4122 and DCE 1.1. +// +// RFC-4122[1] provides the specification for versions 1, 3, 4, and 5. +// +// DCE 1.1[2] provides the specification for version 2. +// +// [1] https://tools.ietf.org/html/rfc4122 +// [2] http://pubs.opengroup.org/onlinepubs/9696989899/chap5.htm#tagcjh_08_02_01_01 +package uuid + +import ( + "encoding/hex" +) + +// Size of a UUID in bytes. +const Size = 16 + +// UUID is an array type to represent the value of a UUID, as defined in RFC-4122. +type UUID [Size]byte + +// UUID versions. +const ( + _ byte = iota + V1 // Version 1 (date-time and MAC address) + V2 // Version 2 (date-time and MAC address, DCE security version) + V3 // Version 3 (namespace name-based) + V4 // Version 4 (random) + V5 // Version 5 (namespace name-based) +) + +// 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 the nil UUID, as specified in RFC-4122, that has 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")) +) + +// Version returns the algorithm version used to generate the UUID. +func (u UUID) Version() byte { + return u[6] >> 4 +} + +// Variant returns the 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 a byte slice representation of the UUID. +func (u UUID) Bytes() []byte { + return u[:] +} + +// String returns a canonical RFC-4122 string representation of the 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 the version bits. +func (u *UUID) SetVersion(v byte) { + u[6] = (u[6] & 0x0f) | (v << 4) +} + +// SetVariant sets the 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 +} diff --git a/cmd/ponzu/vendor/github.com/gofrs/uuid/uuid_test.go b/cmd/ponzu/vendor/github.com/gofrs/uuid/uuid_test.go new file mode 100644 index 0000000..a5b35d9 --- /dev/null +++ b/cmd/ponzu/vendor/github.com/gofrs/uuid/uuid_test.go @@ -0,0 +1,135 @@ +// Copyright (C) 2013-2018 by Maxim Bublis +// +// 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" + "fmt" + "testing" +) + +func TestUUID(t *testing.T) { + t.Run("Bytes", testUUIDBytes) + t.Run("String", testUUIDString) + t.Run("Version", testUUIDVersion) + t.Run("Variant", testUUIDVariant) + t.Run("SetVersion", testUUIDSetVersion) + t.Run("SetVariant", testUUIDSetVariant) +} + +func testUUIDBytes(t *testing.T) { + got := codecTestUUID.Bytes() + want := codecTestData + if !bytes.Equal(got, want) { + t.Errorf("%v.Bytes() = %x, want %x", codecTestUUID, got, want) + } +} + +func testUUIDString(t *testing.T) { + got := NamespaceDNS.String() + want := "6ba7b810-9dad-11d1-80b4-00c04fd430c8" + if got != want { + t.Errorf("%v.String() = %q, want %q", NamespaceDNS, got, want) + } +} + +func testUUIDVersion(t *testing.T) { + u := UUID{0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x10, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00} + if got, want := u.Version(), V1; got != want { + t.Errorf("%v.Version() == %d, want %d", u, got, want) + } +} + +func testUUIDVariant(t *testing.T) { + tests := []struct { + u UUID + want byte + }{ + { + u: UUID{0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00}, + want: VariantNCS, + }, + { + u: UUID{0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x80, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00}, + want: VariantRFC4122, + }, + { + u: UUID{0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0xc0, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00}, + want: VariantMicrosoft, + }, + { + u: UUID{0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0xe0, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00}, + want: VariantFuture, + }, + } + for _, tt := range tests { + if got := tt.u.Variant(); got != tt.want { + t.Errorf("%v.Variant() == %d, want %d", tt.u, got, tt.want) + } + } +} + +func testUUIDSetVersion(t *testing.T) { + u := UUID{} + want := V4 + u.SetVersion(want) + if got := u.Version(); got != want { + t.Errorf("%v.Version() == %d after SetVersion(%d)", u, got, want) + } +} + +func testUUIDSetVariant(t *testing.T) { + variants := []byte{ + VariantNCS, + VariantRFC4122, + VariantMicrosoft, + VariantFuture, + } + for _, want := range variants { + u := UUID{} + u.SetVariant(want) + if got := u.Variant(); got != want { + t.Errorf("%v.Variant() == %d after SetVariant(%d)", u, got, want) + } + } +} + +func TestMust(t *testing.T) { + sentinel := fmt.Errorf("uuid: sentinel error") + defer func() { + r := recover() + if r == nil { + t.Fatalf("did not panic, want %v", sentinel) + } + err, ok := r.(error) + if !ok { + t.Fatalf("panicked with %T, want error (%v)", r, sentinel) + } + if err != sentinel { + t.Fatalf("panicked with %v, want %v", err, sentinel) + } + }() + fn := func() (UUID, error) { + return Nil, sentinel + } + Must(fn()) +} diff --git a/cmd/ponzu/vendor/github.com/satori/go.uuid/.travis.yml b/cmd/ponzu/vendor/github.com/satori/go.uuid/.travis.yml deleted file mode 100644 index 20dd53b..0000000 --- a/cmd/ponzu/vendor/github.com/satori/go.uuid/.travis.yml +++ /dev/null @@ -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 diff --git a/cmd/ponzu/vendor/github.com/satori/go.uuid/LICENSE b/cmd/ponzu/vendor/github.com/satori/go.uuid/LICENSE deleted file mode 100644 index 926d549..0000000 --- a/cmd/ponzu/vendor/github.com/satori/go.uuid/LICENSE +++ /dev/null @@ -1,20 +0,0 @@ -Copyright (C) 2013-2018 by Maxim Bublis - -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. diff --git a/cmd/ponzu/vendor/github.com/satori/go.uuid/README.md b/cmd/ponzu/vendor/github.com/satori/go.uuid/README.md deleted file mode 100644 index 7702849..0000000 --- a/cmd/ponzu/vendor/github.com/satori/go.uuid/README.md +++ /dev/null @@ -1,74 +0,0 @@ -# UUID package for Go language - -[![Build Status](https://travis-ci.org/satori/go.uuid.svg?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.svg)](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 - // panic on error - u1 := uuid.Must(uuid.NewV4()) - fmt.Printf("UUIDv4: %s\n", u1) - - // or error handling - u2, err := uuid.NewV4() - if err != nil { - fmt.Printf("Something went wrong: %s", err) - return - } - fmt.Printf("UUIDv4: %s\n", u2) - - // Parsing UUID from string input - u2, err := uuid.FromString("6ba7b810-9dad-11d1-80b4-00c04fd430c8") - if err != nil { - fmt.Printf("Something went 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 . - -UUID package released under MIT License. -See [LICENSE](https://github.com/satori/go.uuid/blob/master/LICENSE) for details. diff --git a/cmd/ponzu/vendor/github.com/satori/go.uuid/codec.go b/cmd/ponzu/vendor/github.com/satori/go.uuid/codec.go deleted file mode 100644 index 656892c..0000000 --- a/cmd/ponzu/vendor/github.com/satori/go.uuid/codec.go +++ /dev/null @@ -1,206 +0,0 @@ -// Copyright (C) 2013-2018 by Maxim Bublis -// -// 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 -} diff --git a/cmd/ponzu/vendor/github.com/satori/go.uuid/codec_test.go b/cmd/ponzu/vendor/github.com/satori/go.uuid/codec_test.go deleted file mode 100644 index 7158c09..0000000 --- a/cmd/ponzu/vendor/github.com/satori/go.uuid/codec_test.go +++ /dev/null @@ -1,251 +0,0 @@ -// Copyright (C) 2013-2018 by Maxim Bublis -// -// 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" - - . "gopkg.in/check.v1" -) - -type codecTestSuite struct{} - -var _ = Suite(&codecTestSuite{}) - -func (s *codecTestSuite) TestFromBytes(c *C) { - u := UUID{0x6b, 0xa7, 0xb8, 0x10, 0x9d, 0xad, 0x11, 0xd1, 0x80, 0xb4, 0x00, 0xc0, 0x4f, 0xd4, 0x30, 0xc8} - b1 := []byte{0x6b, 0xa7, 0xb8, 0x10, 0x9d, 0xad, 0x11, 0xd1, 0x80, 0xb4, 0x00, 0xc0, 0x4f, 0xd4, 0x30, 0xc8} - - u1, err := FromBytes(b1) - c.Assert(err, IsNil) - c.Assert(u1, Equals, u) - - b2 := []byte{} - _, err = FromBytes(b2) - c.Assert(err, NotNil) -} - -func (s *codecTestSuite) BenchmarkFromBytes(c *C) { - bytes := []byte{0x6b, 0xa7, 0xb8, 0x10, 0x9d, 0xad, 0x11, 0xd1, 0x80, 0xb4, 0x00, 0xc0, 0x4f, 0xd4, 0x30, 0xc8} - for i := 0; i < c.N; i++ { - FromBytes(bytes) - } -} - -func (s *codecTestSuite) TestMarshalBinary(c *C) { - u := UUID{0x6b, 0xa7, 0xb8, 0x10, 0x9d, 0xad, 0x11, 0xd1, 0x80, 0xb4, 0x00, 0xc0, 0x4f, 0xd4, 0x30, 0xc8} - b1 := []byte{0x6b, 0xa7, 0xb8, 0x10, 0x9d, 0xad, 0x11, 0xd1, 0x80, 0xb4, 0x00, 0xc0, 0x4f, 0xd4, 0x30, 0xc8} - - b2, err := u.MarshalBinary() - c.Assert(err, IsNil) - c.Assert(bytes.Equal(b1, b2), Equals, true) -} - -func (s *codecTestSuite) BenchmarkMarshalBinary(c *C) { - u, err := NewV4() - c.Assert(err, IsNil) - for i := 0; i < c.N; i++ { - u.MarshalBinary() - } -} - -func (s *codecTestSuite) TestUnmarshalBinary(c *C) { - u := UUID{0x6b, 0xa7, 0xb8, 0x10, 0x9d, 0xad, 0x11, 0xd1, 0x80, 0xb4, 0x00, 0xc0, 0x4f, 0xd4, 0x30, 0xc8} - b1 := []byte{0x6b, 0xa7, 0xb8, 0x10, 0x9d, 0xad, 0x11, 0xd1, 0x80, 0xb4, 0x00, 0xc0, 0x4f, 0xd4, 0x30, 0xc8} - - u1 := UUID{} - err := u1.UnmarshalBinary(b1) - c.Assert(err, IsNil) - c.Assert(u1, Equals, u) - - b2 := []byte{} - u2 := UUID{} - err = u2.UnmarshalBinary(b2) - c.Assert(err, NotNil) -} - -func (s *codecTestSuite) TestFromString(c *C) { - u := UUID{0x6b, 0xa7, 0xb8, 0x10, 0x9d, 0xad, 0x11, 0xd1, 0x80, 0xb4, 0x00, 0xc0, 0x4f, 0xd4, 0x30, 0xc8} - - s1 := "6ba7b810-9dad-11d1-80b4-00c04fd430c8" - s2 := "{6ba7b810-9dad-11d1-80b4-00c04fd430c8}" - s3 := "urn:uuid:6ba7b810-9dad-11d1-80b4-00c04fd430c8" - s4 := "6ba7b8109dad11d180b400c04fd430c8" - s5 := "urn:uuid:6ba7b8109dad11d180b400c04fd430c8" - - _, err := FromString("") - c.Assert(err, NotNil) - - u1, err := FromString(s1) - c.Assert(err, IsNil) - c.Assert(u1, Equals, u) - - u2, err := FromString(s2) - c.Assert(err, IsNil) - c.Assert(u2, Equals, u) - - u3, err := FromString(s3) - c.Assert(err, IsNil) - c.Assert(u3, Equals, u) - - u4, err := FromString(s4) - c.Assert(err, IsNil) - c.Assert(u4, Equals, u) - - u5, err := FromString(s5) - c.Assert(err, IsNil) - c.Assert(u5, Equals, u) -} - -func (s *codecTestSuite) BenchmarkFromString(c *C) { - str := "6ba7b810-9dad-11d1-80b4-00c04fd430c8" - for i := 0; i < c.N; i++ { - FromString(str) - } -} - -func (s *codecTestSuite) BenchmarkFromStringUrn(c *C) { - str := "urn:uuid:6ba7b810-9dad-11d1-80b4-00c04fd430c8" - for i := 0; i < c.N; i++ { - FromString(str) - } -} - -func (s *codecTestSuite) BenchmarkFromStringWithBrackets(c *C) { - str := "{6ba7b810-9dad-11d1-80b4-00c04fd430c8}" - for i := 0; i < c.N; i++ { - FromString(str) - } -} - -func (s *codecTestSuite) TestFromStringShort(c *C) { - // Invalid 35-character UUID string - s1 := "6ba7b810-9dad-11d1-80b4-00c04fd430c" - - for i := len(s1); i >= 0; i-- { - _, err := FromString(s1[:i]) - c.Assert(err, NotNil) - } -} - -func (s *codecTestSuite) TestFromStringLong(c *C) { - // Invalid 37+ character UUID string - strings := []string{ - "6ba7b810-9dad-11d1-80b4-00c04fd430c8=", - "6ba7b810-9dad-11d1-80b4-00c04fd430c8}", - "{6ba7b810-9dad-11d1-80b4-00c04fd430c8}f", - "6ba7b810-9dad-11d1-80b4-00c04fd430c800c04fd430c8", - } - - for _, str := range strings { - _, err := FromString(str) - c.Assert(err, NotNil) - } -} - -func (s *codecTestSuite) TestFromStringInvalid(c *C) { - // Invalid UUID string formats - strings := []string{ - "6ba7b8109dad11d180b400c04fd430c86ba7b8109dad11d180b400c04fd430c8", - "urn:uuid:{6ba7b810-9dad-11d1-80b4-00c04fd430c8}", - "uuid:urn:6ba7b810-9dad-11d1-80b4-00c04fd430c8", - "uuid:urn:6ba7b8109dad11d180b400c04fd430c8", - "6ba7b8109-dad-11d1-80b4-00c04fd430c8", - "6ba7b810-9dad1-1d1-80b4-00c04fd430c8", - "6ba7b810-9dad-11d18-0b4-00c04fd430c8", - "6ba7b810-9dad-11d1-80b40-0c04fd430c8", - "6ba7b810+9dad+11d1+80b4+00c04fd430c8", - "(6ba7b810-9dad-11d1-80b4-00c04fd430c8}", - "{6ba7b810-9dad-11d1-80b4-00c04fd430c8>", - "zba7b810-9dad-11d1-80b4-00c04fd430c8", - "6ba7b810-9dad11d180b400c04fd430c8", - "6ba7b8109dad-11d180b400c04fd430c8", - "6ba7b8109dad11d1-80b400c04fd430c8", - "6ba7b8109dad11d180b4-00c04fd430c8", - } - - for _, str := range strings { - _, err := FromString(str) - c.Assert(err, NotNil) - } -} - -func (s *codecTestSuite) TestFromStringOrNil(c *C) { - u := FromStringOrNil("") - c.Assert(u, Equals, Nil) -} - -func (s *codecTestSuite) TestFromBytesOrNil(c *C) { - b := []byte{} - u := FromBytesOrNil(b) - c.Assert(u, Equals, Nil) -} - -func (s *codecTestSuite) TestMarshalText(c *C) { - u := UUID{0x6b, 0xa7, 0xb8, 0x10, 0x9d, 0xad, 0x11, 0xd1, 0x80, 0xb4, 0x00, 0xc0, 0x4f, 0xd4, 0x30, 0xc8} - b1 := []byte("6ba7b810-9dad-11d1-80b4-00c04fd430c8") - - b2, err := u.MarshalText() - c.Assert(err, IsNil) - c.Assert(bytes.Equal(b1, b2), Equals, true) -} - -func (s *codecTestSuite) BenchmarkMarshalText(c *C) { - u, err := NewV4() - c.Assert(err, IsNil) - for i := 0; i < c.N; i++ { - u.MarshalText() - } -} - -func (s *codecTestSuite) TestUnmarshalText(c *C) { - u := UUID{0x6b, 0xa7, 0xb8, 0x10, 0x9d, 0xad, 0x11, 0xd1, 0x80, 0xb4, 0x00, 0xc0, 0x4f, 0xd4, 0x30, 0xc8} - b1 := []byte("6ba7b810-9dad-11d1-80b4-00c04fd430c8") - - u1 := UUID{} - err := u1.UnmarshalText(b1) - c.Assert(err, IsNil) - c.Assert(u1, Equals, u) - - b2 := []byte("") - u2 := UUID{} - err = u2.UnmarshalText(b2) - c.Assert(err, NotNil) -} - -func (s *codecTestSuite) BenchmarkUnmarshalText(c *C) { - bytes := []byte("6ba7b810-9dad-11d1-80b4-00c04fd430c8") - u := UUID{} - for i := 0; i < c.N; i++ { - u.UnmarshalText(bytes) - } -} - -var sink string - -func (s *codecTestSuite) BenchmarkMarshalToString(c *C) { - u, err := NewV4() - c.Assert(err, IsNil) - for i := 0; i < c.N; i++ { - sink = u.String() - } -} diff --git a/cmd/ponzu/vendor/github.com/satori/go.uuid/generator.go b/cmd/ponzu/vendor/github.com/satori/go.uuid/generator.go deleted file mode 100644 index 499dc35..0000000 --- a/cmd/ponzu/vendor/github.com/satori/go.uuid/generator.go +++ /dev/null @@ -1,265 +0,0 @@ -// Copyright (C) 2013-2018 by Maxim Bublis -// -// 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" - "fmt" - "hash" - "io" - "net" - "os" - "sync" - "time" -) - -// Difference in 100-nanosecond intervals between -// UUID epoch (October 15, 1582) and Unix epoch (January 1, 1970). -const epochStart = 122192928000000000 - -type epochFunc func() time.Time -type hwAddrFunc func() (net.HardwareAddr, error) - -var ( - global = newRFC4122Generator() - - posixUID = uint32(os.Getuid()) - posixGID = uint32(os.Getgid()) -) - -// NewV1 returns UUID based on current timestamp and MAC address. -func NewV1() (UUID, error) { - return global.NewV1() -} - -// NewV2 returns DCE Security UUID based on POSIX UID/GID. -func NewV2(domain byte) (UUID, error) { - 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, error) { - 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, error) - NewV2(domain byte) (UUID, error) - NewV3(ns UUID, name string) UUID - NewV4() (UUID, error) - NewV5(ns UUID, name string) UUID -} - -// Default generator implementation. -type rfc4122Generator struct { - clockSequenceOnce sync.Once - hardwareAddrOnce sync.Once - storageMutex sync.Mutex - - rand io.Reader - - epochFunc epochFunc - hwAddrFunc hwAddrFunc - lastTime uint64 - clockSequence uint16 - hardwareAddr [6]byte -} - -func newRFC4122Generator() Generator { - return &rfc4122Generator{ - epochFunc: time.Now, - hwAddrFunc: defaultHWAddrFunc, - rand: rand.Reader, - } -} - -// NewV1 returns UUID based on current timestamp and MAC address. -func (g *rfc4122Generator) NewV1() (UUID, error) { - u := UUID{} - - timeNow, clockSeq, err := g.getClockSequence() - if err != nil { - return Nil, err - } - 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) - - hardwareAddr, err := g.getHardwareAddr() - if err != nil { - return Nil, err - } - copy(u[10:], hardwareAddr) - - u.SetVersion(V1) - u.SetVariant(VariantRFC4122) - - return u, nil -} - -// NewV2 returns DCE Security UUID based on POSIX UID/GID. -func (g *rfc4122Generator) NewV2(domain byte) (UUID, error) { - u, err := g.NewV1() - if err != nil { - return Nil, err - } - - switch domain { - case DomainPerson: - binary.BigEndian.PutUint32(u[:], posixUID) - case DomainGroup: - binary.BigEndian.PutUint32(u[:], posixGID) - } - - u[9] = domain - - u.SetVersion(V2) - u.SetVariant(VariantRFC4122) - - return u, nil -} - -// NewV3 returns UUID based on MD5 hash of namespace UUID and name. -func (g *rfc4122Generator) 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 *rfc4122Generator) NewV4() (UUID, error) { - u := UUID{} - if _, err := g.rand.Read(u[:]); err != nil { - return Nil, err - } - u.SetVersion(V4) - u.SetVariant(VariantRFC4122) - - return u, nil -} - -// NewV5 returns UUID based on SHA-1 hash of namespace UUID and name. -func (g *rfc4122Generator) NewV5(ns UUID, name string) UUID { - u := newFromHash(sha1.New(), ns, name) - u.SetVersion(V5) - u.SetVariant(VariantRFC4122) - - return u -} - -// Returns epoch and clock sequence. -func (g *rfc4122Generator) getClockSequence() (uint64, uint16, error) { - var err error - g.clockSequenceOnce.Do(func() { - buf := make([]byte, 2) - if _, err = g.rand.Read(buf); err != nil { - return - } - g.clockSequence = binary.BigEndian.Uint16(buf) - }) - if err != nil { - return 0, 0, err - } - - g.storageMutex.Lock() - defer g.storageMutex.Unlock() - - timeNow := g.getEpoch() - // Clock didn't change since last UUID generation. - // Should increase clock sequence. - if timeNow <= g.lastTime { - g.clockSequence++ - } - g.lastTime = timeNow - - return timeNow, g.clockSequence, nil -} - -// Returns hardware address. -func (g *rfc4122Generator) getHardwareAddr() ([]byte, error) { - var err error - g.hardwareAddrOnce.Do(func() { - if hwAddr, err := g.hwAddrFunc(); err == nil { - copy(g.hardwareAddr[:], hwAddr) - return - } - - // Initialize hardwareAddr randomly in case - // of real network interfaces absence. - if _, err = g.rand.Read(g.hardwareAddr[:]); err != nil { - return - } - // Set multicast bit as recommended by RFC 4122 - g.hardwareAddr[0] |= 0x01 - }) - if err != nil { - return []byte{}, err - } - return g.hardwareAddr[:], nil -} - -// Returns difference in 100-nanosecond intervals between -// UUID epoch (October 15, 1582) and current time. -func (g *rfc4122Generator) getEpoch() uint64 { - return epochStart + uint64(g.epochFunc().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 -} - -// Returns hardware address. -func defaultHWAddrFunc() (net.HardwareAddr, error) { - ifaces, err := net.Interfaces() - if err != nil { - return []byte{}, err - } - for _, iface := range ifaces { - if len(iface.HardwareAddr) >= 6 { - return iface.HardwareAddr, nil - } - } - return []byte{}, fmt.Errorf("uuid: no HW address found") -} diff --git a/cmd/ponzu/vendor/github.com/satori/go.uuid/generator_test.go b/cmd/ponzu/vendor/github.com/satori/go.uuid/generator_test.go deleted file mode 100644 index 82a236a..0000000 --- a/cmd/ponzu/vendor/github.com/satori/go.uuid/generator_test.go +++ /dev/null @@ -1,224 +0,0 @@ -// Copyright (C) 2013-2018 by Maxim Bublis -// -// 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/rand" - "fmt" - "net" - "time" - - . "gopkg.in/check.v1" -) - -type faultyReader struct { - callsNum int - readToFail int // Read call number to fail -} - -func (r *faultyReader) Read(dest []byte) (int, error) { - r.callsNum++ - if (r.callsNum - 1) == r.readToFail { - return 0, fmt.Errorf("io: reader is faulty") - } - return rand.Read(dest) -} - -type genTestSuite struct{} - -var _ = Suite(&genTestSuite{}) - -func (s *genTestSuite) TestNewV1(c *C) { - u1, err := NewV1() - c.Assert(err, IsNil) - c.Assert(u1.Version(), Equals, V1) - c.Assert(u1.Variant(), Equals, VariantRFC4122) - - u2, err := NewV1() - c.Assert(err, IsNil) - c.Assert(u1, Not(Equals), u2) -} - -func (s *genTestSuite) TestNewV1EpochStale(c *C) { - g := &rfc4122Generator{ - epochFunc: func() time.Time { - return time.Unix(0, 0) - }, - hwAddrFunc: defaultHWAddrFunc, - rand: rand.Reader, - } - u1, err := g.NewV1() - c.Assert(err, IsNil) - u2, err := g.NewV1() - c.Assert(err, IsNil) - c.Assert(u1, Not(Equals), u2) -} - -func (s *genTestSuite) TestNewV1FaultyRand(c *C) { - g := &rfc4122Generator{ - epochFunc: time.Now, - hwAddrFunc: defaultHWAddrFunc, - rand: &faultyReader{}, - } - u1, err := g.NewV1() - c.Assert(err, NotNil) - c.Assert(u1, Equals, Nil) -} - -func (s *genTestSuite) TestNewV1MissingNetworkInterfaces(c *C) { - g := &rfc4122Generator{ - epochFunc: time.Now, - hwAddrFunc: func() (net.HardwareAddr, error) { - return []byte{}, fmt.Errorf("uuid: no hw address found") - }, - rand: rand.Reader, - } - _, err := g.NewV1() - c.Assert(err, IsNil) -} - -func (s *genTestSuite) TestNewV1MissingNetInterfacesAndFaultyRand(c *C) { - g := &rfc4122Generator{ - epochFunc: time.Now, - hwAddrFunc: func() (net.HardwareAddr, error) { - return []byte{}, fmt.Errorf("uuid: no hw address found") - }, - rand: &faultyReader{ - readToFail: 1, - }, - } - u1, err := g.NewV1() - c.Assert(err, NotNil) - c.Assert(u1, Equals, Nil) -} - -func (s *genTestSuite) BenchmarkNewV1(c *C) { - for i := 0; i < c.N; i++ { - NewV1() - } -} - -func (s *genTestSuite) TestNewV2(c *C) { - u1, err := NewV2(DomainPerson) - c.Assert(err, IsNil) - c.Assert(u1.Version(), Equals, V2) - c.Assert(u1.Variant(), Equals, VariantRFC4122) - - u2, err := NewV2(DomainGroup) - c.Assert(err, IsNil) - c.Assert(u2.Version(), Equals, V2) - c.Assert(u2.Variant(), Equals, VariantRFC4122) - - u3, err := NewV2(DomainOrg) - c.Assert(err, IsNil) - c.Assert(u3.Version(), Equals, V2) - c.Assert(u3.Variant(), Equals, VariantRFC4122) -} - -func (s *genTestSuite) TestNewV2FaultyRand(c *C) { - g := &rfc4122Generator{ - epochFunc: time.Now, - hwAddrFunc: defaultHWAddrFunc, - rand: &faultyReader{}, - } - u1, err := g.NewV2(DomainPerson) - c.Assert(err, NotNil) - c.Assert(u1, Equals, Nil) -} - -func (s *genTestSuite) BenchmarkNewV2(c *C) { - for i := 0; i < c.N; i++ { - NewV2(DomainPerson) - } -} - -func (s *genTestSuite) TestNewV3(c *C) { - u1 := NewV3(NamespaceDNS, "www.example.com") - c.Assert(u1.Version(), Equals, V3) - c.Assert(u1.Variant(), Equals, VariantRFC4122) - c.Assert(u1.String(), Equals, "5df41881-3aed-3515-88a7-2f4a814cf09e") - - u2 := NewV3(NamespaceDNS, "example.com") - c.Assert(u2, Not(Equals), u1) - - u3 := NewV3(NamespaceDNS, "example.com") - c.Assert(u3, Equals, u2) - - u4 := NewV3(NamespaceURL, "example.com") - c.Assert(u4, Not(Equals), u3) -} - -func (s *genTestSuite) BenchmarkNewV3(c *C) { - for i := 0; i < c.N; i++ { - NewV3(NamespaceDNS, "www.example.com") - } -} - -func (s *genTestSuite) TestNewV4(c *C) { - u1, err := NewV4() - c.Assert(err, IsNil) - c.Assert(u1.Version(), Equals, V4) - c.Assert(u1.Variant(), Equals, VariantRFC4122) - - u2, err := NewV4() - c.Assert(err, IsNil) - c.Assert(u1, Not(Equals), u2) -} - -func (s *genTestSuite) TestNewV4FaultyRand(c *C) { - g := &rfc4122Generator{ - epochFunc: time.Now, - hwAddrFunc: defaultHWAddrFunc, - rand: &faultyReader{}, - } - u1, err := g.NewV4() - c.Assert(err, NotNil) - c.Assert(u1, Equals, Nil) -} - -func (s *genTestSuite) BenchmarkNewV4(c *C) { - for i := 0; i < c.N; i++ { - NewV4() - } -} - -func (s *genTestSuite) TestNewV5(c *C) { - u1 := NewV5(NamespaceDNS, "www.example.com") - c.Assert(u1.Version(), Equals, V5) - c.Assert(u1.Variant(), Equals, VariantRFC4122) - c.Assert(u1.String(), Equals, "2ed6657d-e927-568b-95e1-2665a8aea6a2") - - u2 := NewV5(NamespaceDNS, "example.com") - c.Assert(u2, Not(Equals), u1) - - u3 := NewV5(NamespaceDNS, "example.com") - c.Assert(u3, Equals, u2) - - u4 := NewV5(NamespaceURL, "example.com") - c.Assert(u4, Not(Equals), u3) -} - -func (s *genTestSuite) BenchmarkNewV5(c *C) { - for i := 0; i < c.N; i++ { - NewV5(NamespaceDNS, "www.example.com") - } -} diff --git a/cmd/ponzu/vendor/github.com/satori/go.uuid/sql.go b/cmd/ponzu/vendor/github.com/satori/go.uuid/sql.go deleted file mode 100644 index 56759d3..0000000 --- a/cmd/ponzu/vendor/github.com/satori/go.uuid/sql.go +++ /dev/null @@ -1,78 +0,0 @@ -// Copyright (C) 2013-2018 by Maxim Bublis -// -// 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) -} diff --git a/cmd/ponzu/vendor/github.com/satori/go.uuid/sql_test.go b/cmd/ponzu/vendor/github.com/satori/go.uuid/sql_test.go deleted file mode 100644 index 74255f5..0000000 --- a/cmd/ponzu/vendor/github.com/satori/go.uuid/sql_test.go +++ /dev/null @@ -1,136 +0,0 @@ -// Copyright (C) 2013-2018 by Maxim Bublis -// -// 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 ( - . "gopkg.in/check.v1" -) - -type sqlTestSuite struct{} - -var _ = Suite(&sqlTestSuite{}) - -func (s *sqlTestSuite) TestValue(c *C) { - u, err := FromString("6ba7b810-9dad-11d1-80b4-00c04fd430c8") - c.Assert(err, IsNil) - - val, err := u.Value() - c.Assert(err, IsNil) - c.Assert(val, Equals, u.String()) -} - -func (s *sqlTestSuite) TestValueNil(c *C) { - u := UUID{} - - val, err := u.Value() - c.Assert(err, IsNil) - c.Assert(val, Equals, Nil.String()) -} - -func (s *sqlTestSuite) TestNullUUIDValueNil(c *C) { - u := NullUUID{} - - val, err := u.Value() - c.Assert(err, IsNil) - c.Assert(val, IsNil) -} - -func (s *sqlTestSuite) TestScanBinary(c *C) { - u := UUID{0x6b, 0xa7, 0xb8, 0x10, 0x9d, 0xad, 0x11, 0xd1, 0x80, 0xb4, 0x00, 0xc0, 0x4f, 0xd4, 0x30, 0xc8} - b1 := []byte{0x6b, 0xa7, 0xb8, 0x10, 0x9d, 0xad, 0x11, 0xd1, 0x80, 0xb4, 0x00, 0xc0, 0x4f, 0xd4, 0x30, 0xc8} - - u1 := UUID{} - err := u1.Scan(b1) - c.Assert(err, IsNil) - c.Assert(u, Equals, u1) - - b2 := []byte{} - u2 := UUID{} - - err = u2.Scan(b2) - c.Assert(err, NotNil) -} - -func (s *sqlTestSuite) TestScanString(c *C) { - u := UUID{0x6b, 0xa7, 0xb8, 0x10, 0x9d, 0xad, 0x11, 0xd1, 0x80, 0xb4, 0x00, 0xc0, 0x4f, 0xd4, 0x30, 0xc8} - s1 := "6ba7b810-9dad-11d1-80b4-00c04fd430c8" - - u1 := UUID{} - err := u1.Scan(s1) - c.Assert(err, IsNil) - c.Assert(u, Equals, u1) - - s2 := "" - u2 := UUID{} - - err = u2.Scan(s2) - c.Assert(err, NotNil) -} - -func (s *sqlTestSuite) TestScanText(c *C) { - u := UUID{0x6b, 0xa7, 0xb8, 0x10, 0x9d, 0xad, 0x11, 0xd1, 0x80, 0xb4, 0x00, 0xc0, 0x4f, 0xd4, 0x30, 0xc8} - b1 := []byte("6ba7b810-9dad-11d1-80b4-00c04fd430c8") - - u1 := UUID{} - err := u1.Scan(b1) - c.Assert(err, IsNil) - c.Assert(u, Equals, u1) - - b2 := []byte("") - u2 := UUID{} - err = u2.Scan(b2) - c.Assert(err, NotNil) -} - -func (s *sqlTestSuite) TestScanUnsupported(c *C) { - u := UUID{} - - err := u.Scan(true) - c.Assert(err, NotNil) -} - -func (s *sqlTestSuite) TestScanNil(c *C) { - u := UUID{0x6b, 0xa7, 0xb8, 0x10, 0x9d, 0xad, 0x11, 0xd1, 0x80, 0xb4, 0x00, 0xc0, 0x4f, 0xd4, 0x30, 0xc8} - - err := u.Scan(nil) - c.Assert(err, NotNil) -} - -func (s *sqlTestSuite) TestNullUUIDScanValid(c *C) { - u := UUID{0x6b, 0xa7, 0xb8, 0x10, 0x9d, 0xad, 0x11, 0xd1, 0x80, 0xb4, 0x00, 0xc0, 0x4f, 0xd4, 0x30, 0xc8} - s1 := "6ba7b810-9dad-11d1-80b4-00c04fd430c8" - - u1 := NullUUID{} - err := u1.Scan(s1) - c.Assert(err, IsNil) - c.Assert(u1.Valid, Equals, true) - c.Assert(u1.UUID, Equals, u) -} - -func (s *sqlTestSuite) TestNullUUIDScanNil(c *C) { - u := NullUUID{UUID{0x6b, 0xa7, 0xb8, 0x10, 0x9d, 0xad, 0x11, 0xd1, 0x80, 0xb4, 0x00, 0xc0, 0x4f, 0xd4, 0x30, 0xc8}, true} - - err := u.Scan(nil) - c.Assert(err, IsNil) - c.Assert(u.Valid, Equals, false) - c.Assert(u.UUID, Equals, Nil) -} diff --git a/cmd/ponzu/vendor/github.com/satori/go.uuid/uuid.go b/cmd/ponzu/vendor/github.com/satori/go.uuid/uuid.go deleted file mode 100644 index a2b8e2c..0000000 --- a/cmd/ponzu/vendor/github.com/satori/go.uuid/uuid.go +++ /dev/null @@ -1,161 +0,0 @@ -// Copyright (C) 2013-2018 by Maxim Bublis -// -// 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 -} diff --git a/cmd/ponzu/vendor/github.com/satori/go.uuid/uuid_test.go b/cmd/ponzu/vendor/github.com/satori/go.uuid/uuid_test.go deleted file mode 100644 index fa40280..0000000 --- a/cmd/ponzu/vendor/github.com/satori/go.uuid/uuid_test.go +++ /dev/null @@ -1,100 +0,0 @@ -// Copyright (C) 2013-2018 by Maxim Bublis -// -// 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" - "fmt" - "testing" - - . "gopkg.in/check.v1" -) - -// Hook up gocheck into the "go test" runner. -func TestUUID(t *testing.T) { TestingT(t) } - -type testSuite struct{} - -var _ = Suite(&testSuite{}) - -func (s *testSuite) TestBytes(c *C) { - u := UUID{0x6b, 0xa7, 0xb8, 0x10, 0x9d, 0xad, 0x11, 0xd1, 0x80, 0xb4, 0x00, 0xc0, 0x4f, 0xd4, 0x30, 0xc8} - - bytes1 := []byte{0x6b, 0xa7, 0xb8, 0x10, 0x9d, 0xad, 0x11, 0xd1, 0x80, 0xb4, 0x00, 0xc0, 0x4f, 0xd4, 0x30, 0xc8} - - c.Assert(bytes.Equal(u.Bytes(), bytes1), Equals, true) -} - -func (s *testSuite) TestString(c *C) { - c.Assert(NamespaceDNS.String(), Equals, "6ba7b810-9dad-11d1-80b4-00c04fd430c8") -} - -func (s *testSuite) TestEqual(c *C) { - c.Assert(Equal(NamespaceDNS, NamespaceDNS), Equals, true) - c.Assert(Equal(NamespaceDNS, NamespaceURL), Equals, false) -} - -func (s *testSuite) TestVersion(c *C) { - u := UUID{0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x10, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00} - c.Assert(u.Version(), Equals, V1) -} - -func (s *testSuite) TestSetVersion(c *C) { - u := UUID{} - u.SetVersion(4) - c.Assert(u.Version(), Equals, V4) -} - -func (s *testSuite) TestVariant(c *C) { - u1 := UUID{0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00} - c.Assert(u1.Variant(), Equals, VariantNCS) - - u2 := UUID{0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x80, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00} - c.Assert(u2.Variant(), Equals, VariantRFC4122) - - u3 := UUID{0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0xc0, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00} - c.Assert(u3.Variant(), Equals, VariantMicrosoft) - - u4 := UUID{0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0xe0, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00} - c.Assert(u4.Variant(), Equals, VariantFuture) -} - -func (s *testSuite) TestSetVariant(c *C) { - u := UUID{} - u.SetVariant(VariantNCS) - c.Assert(u.Variant(), Equals, VariantNCS) - u.SetVariant(VariantRFC4122) - c.Assert(u.Variant(), Equals, VariantRFC4122) - u.SetVariant(VariantMicrosoft) - c.Assert(u.Variant(), Equals, VariantMicrosoft) - u.SetVariant(VariantFuture) - c.Assert(u.Variant(), Equals, VariantFuture) -} - -func (s *testSuite) TestMust(c *C) { - defer func() { - c.Assert(recover(), NotNil) - }() - Must(func() (UUID, error) { - return Nil, fmt.Errorf("uuid: expected error") - }()) -} diff --git a/management/editor/elements.go b/management/editor/elements.go index 2dfab40..b279fa9 100644 --- a/management/editor/elements.go +++ b/management/editor/elements.go @@ -261,12 +261,13 @@ func Richtext(fieldName string, p interface{}, attrs map[string]string) []byte { height: 250, placeholder: '` + attrs["placeholder"] + `', toolbar: [ - ['style', ['bold', 'italic', 'underline', 'clear']], - ['font', ['strikethrough', 'superscript', 'subscript']], + ['style', ['style']], + ['font', ['bold', 'italic', 'underline', 'clear', 'strikethrough', 'superscript', 'subscript']], ['fontsize', ['fontsize']], ['color', ['color']], ['insert', ['link', 'picture', 'video', 'hr']], ['para', ['ul', 'ol', 'paragraph']], + ['table', ['table']], ['height', ['height']], ['misc', ['codeview']] ], diff --git a/management/manager/manager.go b/management/manager/manager.go index 1389747..5783e16 100644 --- a/management/manager/manager.go +++ b/management/manager/manager.go @@ -10,7 +10,7 @@ import ( "github.com/ponzu-cms/ponzu/management/editor" "github.com/ponzu-cms/ponzu/system/item" - uuid "github.com/satori/go.uuid" + "github.com/gofrs/uuid" ) const managerHTML = ` diff --git a/system/db/content.go b/system/db/content.go index b96852e..43d6023 100644 --- a/system/db/content.go +++ b/system/db/content.go @@ -16,8 +16,8 @@ import ( "github.com/ponzu-cms/ponzu/system/search" "github.com/boltdb/bolt" + "github.com/gofrs/uuid" "github.com/gorilla/schema" - uuid "github.com/satori/go.uuid" ) // IsValidID checks that an ID from a DB target is valid. diff --git a/system/db/upload.go b/system/db/upload.go index b7171dd..2311ef0 100644 --- a/system/db/upload.go +++ b/system/db/upload.go @@ -14,8 +14,8 @@ import ( "github.com/ponzu-cms/ponzu/system/item" "github.com/boltdb/bolt" + "github.com/gofrs/uuid" "github.com/gorilla/schema" - uuid "github.com/satori/go.uuid" ) // SetUpload stores information about files uploaded to the system diff --git a/system/item/item.go b/system/item/item.go index beace09..32d38f7 100644 --- a/system/item/item.go +++ b/system/item/item.go @@ -12,7 +12,7 @@ import ( "github.com/blevesearch/bleve" "github.com/blevesearch/bleve/mapping" - uuid "github.com/satori/go.uuid" + "github.com/gofrs/uuid" "golang.org/x/text/transform" "golang.org/x/text/unicode/norm" ) -- cgit v1.2.3