From 9bab1bfb21277fb0cfa8655c7c0b2a3bbc5e00e9 Mon Sep 17 00:00:00 2001 From: Sinuhe Tellez Date: Sat, 9 Mar 2019 20:58:13 -0500 Subject: [PATCH] start using go modules --- go.mod | 9 + go.sum | 6 + vendor/github.com/lann/builder/README.md | 68 ----- vendor/github.com/lann/builder/builder.go | 225 -------------- vendor/github.com/lann/builder/reflect.go | 24 -- vendor/github.com/lann/builder/registry.go | 49 --- vendor/github.com/lann/ps/LICENSE | 7 - vendor/github.com/lann/ps/README.md | 10 - vendor/github.com/lann/ps/list.go | 93 ------ vendor/github.com/lann/ps/map.go | 311 -------------------- vendor/github.com/lann/ps/profile.sh | 3 - vendor/golang.org/x/tools/LICENSE | 27 -- vendor/golang.org/x/tools/PATENTS | 22 -- vendor/golang.org/x/tools/blog/atom/atom.go | 61 ---- vendor/vendor.json | 25 -- 15 files changed, 15 insertions(+), 925 deletions(-) create mode 100644 go.mod create mode 100644 go.sum delete mode 100644 vendor/github.com/lann/builder/README.md delete mode 100644 vendor/github.com/lann/builder/builder.go delete mode 100644 vendor/github.com/lann/builder/reflect.go delete mode 100644 vendor/github.com/lann/builder/registry.go delete mode 100644 vendor/github.com/lann/ps/LICENSE delete mode 100644 vendor/github.com/lann/ps/README.md delete mode 100644 vendor/github.com/lann/ps/list.go delete mode 100644 vendor/github.com/lann/ps/map.go delete mode 100755 vendor/github.com/lann/ps/profile.sh delete mode 100644 vendor/golang.org/x/tools/LICENSE delete mode 100644 vendor/golang.org/x/tools/PATENTS delete mode 100644 vendor/golang.org/x/tools/blog/atom/atom.go delete mode 100644 vendor/vendor.json diff --git a/go.mod b/go.mod new file mode 100644 index 0000000..4c6cb14 --- /dev/null +++ b/go.mod @@ -0,0 +1,9 @@ +module github.com/dubyte/dir2opds + +go 1.12 + +require ( + github.com/lann/builder v0.0.0-20150808151131-f22ce00fd939 + github.com/lann/ps v0.0.0-20150810152359-62de8c46ede0 + golang.org/x/tools v0.0.0-20170217234718-8e779ee0a450 +) diff --git a/go.sum b/go.sum new file mode 100644 index 0000000..1a9fbcb --- /dev/null +++ b/go.sum @@ -0,0 +1,6 @@ +github.com/lann/builder v0.0.0-20150808151131-f22ce00fd939 h1:yZJImkCmVI6d1uJ9KRRf/96YbFLDQ/hhs6Xt9Z3OBXI= +github.com/lann/builder v0.0.0-20150808151131-f22ce00fd939/go.mod h1:dXGbAdH5GtBTC4WfIxhKZfyBF/HBFgRZSWwZ9g/He9o= +github.com/lann/ps v0.0.0-20150810152359-62de8c46ede0 h1:P6pPBnrTSX3DEVR4fDembhRWSsG5rVo6hYhAB/ADZrk= +github.com/lann/ps v0.0.0-20150810152359-62de8c46ede0/go.mod h1:vmVJ0l/dxyfGW6FmdpVm2joNMFikkuWg0EoCKLGUMNw= +golang.org/x/tools v0.0.0-20170217234718-8e779ee0a450 h1:qbbvkCEu5ZgZKpHV38z/uXcloRX6fn/EgiGMW/9eluc= +golang.org/x/tools v0.0.0-20170217234718-8e779ee0a450/go.mod h1:n7NCudcB/nEzxVGmLbDWY5pfWTLqBcC2KZ6jyYvM4mQ= diff --git a/vendor/github.com/lann/builder/README.md b/vendor/github.com/lann/builder/README.md deleted file mode 100644 index 3b18550..0000000 --- a/vendor/github.com/lann/builder/README.md +++ /dev/null @@ -1,68 +0,0 @@ -# Builder - fluent immutable builders for Go - -[![GoDoc](https://godoc.org/github.com/lann/builder?status.png)](https://godoc.org/github.com/lann/builder) -[![Build Status](https://travis-ci.org/lann/builder.png?branch=master)](https://travis-ci.org/lann/builder) - -Builder was originally written for -[Squirrel](https://github.com/lann/squirrel), a fluent SQL generator. It -is probably the best example of Builder in action. - -Builder helps you write **fluent** DSLs for your libraries with method chaining: - -```go -resp := ReqBuilder. - Url("http://golang.org"). - Header("User-Agent", "Builder"). - Get() -``` - -Builder uses **immutable** persistent data structures -([these](https://github.com/mndrix/ps), specifically) -so that each step in your method chain can be reused: - -```go -build := WordBuilder.AddLetters("Build") -builder := build.AddLetters("er") -building := build.AddLetters("ing") -``` - -Builder makes it easy to **build** structs using the **builder** pattern -(*surprise!*): - -```go -import "github.com/lann/builder" - -type Muppet struct { - Name string - Friends []string -} - -type muppetBuilder builder.Builder - -func (b muppetBuilder) Name(name string) muppetBuilder { - return builder.Set(b, "Name", name).(muppetBuilder) -} - -func (b muppetBuilder) AddFriend(friend string) muppetBuilder { - return builder.Append(b, "Friends", friend).(muppetBuilder) -} - -func (b muppetBuilder) Build() Muppet { - return builder.GetStruct(b).(Muppet) -} - -var MuppetBuilder = builder.Register(muppetBuilder{}, Muppet{}).(muppetBuilder) -``` -```go -MuppetBuilder. - Name("Beaker"). - AddFriend("Dr. Honeydew"). - Build() - -=> Muppet{Name:"Beaker", Friends:[]string{"Dr. Honeydew"}} -``` - -## License - -Builder is released under the -[MIT License](http://www.opensource.org/licenses/MIT). diff --git a/vendor/github.com/lann/builder/builder.go b/vendor/github.com/lann/builder/builder.go deleted file mode 100644 index ff62140..0000000 --- a/vendor/github.com/lann/builder/builder.go +++ /dev/null @@ -1,225 +0,0 @@ -// Package builder provides a method for writing fluent immutable builders. -package builder - -import ( - "github.com/lann/ps" - "go/ast" - "reflect" -) - -// Builder stores a set of named values. -// -// New types can be declared with underlying type Builder and used with the -// functions in this package. See example. -// -// Instances of Builder should be treated as immutable. It is up to the -// implementor to ensure mutable values set on a Builder are not mutated while -// the Builder is in use. -type Builder struct { - builderMap ps.Map -} - -var ( - EmptyBuilder = Builder{ps.NewMap()} - emptyBuilderValue = reflect.ValueOf(EmptyBuilder) -) - -func getBuilderMap(builder interface{}) ps.Map { - b := convert(builder, Builder{}).(Builder) - - if b.builderMap == nil { - return ps.NewMap() - } - - return b.builderMap -} - -// Set returns a copy of the given builder with a new value set for the given -// name. -// -// Set (and all other functions taking a builder in this package) will panic if -// the given builder's underlying type is not Builder. -func Set(builder interface{}, name string, v interface{}) interface{} { - b := Builder{getBuilderMap(builder).Set(name, v)} - return convert(b, builder) -} - -// Delete returns a copy of the given builder with the given named value unset. -func Delete(builder interface{}, name string) interface{} { - b := Builder{getBuilderMap(builder).Delete(name)} - return convert(b, builder) -} - -// Append returns a copy of the given builder with new value(s) appended to the -// named list. If the value was previously unset or set with Set (even to a e.g. -// slice values), the new value(s) will be appended to an empty list. -func Append(builder interface{}, name string, vs ...interface{}) interface{} { - return Extend(builder, name, vs) -} - -// Extend behaves like Append, except it takes a single slice or array value -// which will be concatenated to the named list. -// -// Unlike a variadic call to Append - which requires a []interface{} value - -// Extend accepts slices or arrays of any type. -// -// Extend will panic if the given value is not a slice, array, or nil. -func Extend(builder interface{}, name string, vs interface{}) interface{} { - if vs == nil { - return builder - } - - maybeList, ok := getBuilderMap(builder).Lookup(name) - - var list ps.List - if ok { - list, ok = maybeList.(ps.List) - } - if !ok { - list = ps.NewList() - } - - forEach(vs, func(v interface{}) { - list = list.Cons(v) - }) - - return Set(builder, name, list) -} - -func listToSlice(list ps.List, arrayType reflect.Type) reflect.Value { - size := list.Size() - slice := reflect.MakeSlice(arrayType, size, size) - for i := size - 1; i >= 0; i-- { - val := reflect.ValueOf(list.Head()) - slice.Index(i).Set(val) - list = list.Tail() - } - return slice -} - -var anyArrayType = reflect.TypeOf([]interface{}{}) - -// Get retrieves a single named value from the given builder. -// If the value has not been set, it returns (nil, false). Otherwise, it will -// return (value, true). -// -// If the named value was last set with Append or Extend, the returned value -// will be a slice. If the given Builder has been registered with Register or -// RegisterType and the given name is an exported field of the registered -// struct, the returned slice will have the same type as that field. Otherwise -// the slice will have type []interface{}. It will panic if the given name is a -// registered struct's exported field and the value set on the Builder is not -// assignable to the field. -func Get(builder interface{}, name string) (interface{}, bool) { - val, ok := getBuilderMap(builder).Lookup(name) - if !ok { - return nil, false - } - - list, isList := val.(ps.List) - if isList { - arrayType := anyArrayType - - if ast.IsExported(name) { - structType := getBuilderStructType(reflect.TypeOf(builder)) - if structType != nil { - field, ok := (*structType).FieldByName(name) - if ok { - arrayType = field.Type - } - } - } - - val = listToSlice(list, arrayType).Interface() - } - - return val, true -} - -// GetMap returns a map[string]interface{} of the values set in the given -// builder. -// -// See notes on Get regarding returned slices. -func GetMap(builder interface{}) map[string]interface{} { - m := getBuilderMap(builder) - structType := getBuilderStructType(reflect.TypeOf(builder)) - - ret := make(map[string]interface{}, m.Size()) - - m.ForEach(func(name string, val ps.Any) { - list, isList := val.(ps.List) - if isList { - arrayType := anyArrayType - - if structType != nil { - field, ok := (*structType).FieldByName(name) - if ok { - arrayType = field.Type - } - } - - val = listToSlice(list, arrayType).Interface() - } - - ret[name] = val - }) - - return ret -} - -// GetStruct builds a new struct from the given registered builder. -// It will return nil if the given builder's type has not been registered with -// Register or RegisterValue. -// -// All values set on the builder with names that start with an uppercase letter -// (i.e. which would be exported if they were identifiers) are assigned to the -// corresponding exported fields of the struct. -// -// GetStruct will panic if any of these "exported" values are not assignable to -// their corresponding struct fields. -func GetStruct(builder interface{}) interface{} { - structVal := newBuilderStruct(reflect.TypeOf(builder)) - if structVal == nil { - return nil - } - return scanStruct(builder, structVal) -} - -// GetStructLike builds a new struct from the given builder with the same type -// as the given struct. -// -// All values set on the builder with names that start with an uppercase letter -// (i.e. which would be exported if they were identifiers) are assigned to the -// corresponding exported fields of the struct. -// -// ScanStruct will panic if any of these "exported" values are not assignable to -// their corresponding struct fields. -func GetStructLike(builder interface{}, strct interface{}) interface{} { - structVal := reflect.New(reflect.TypeOf(strct)).Elem() - return scanStruct(builder, &structVal) -} - -func scanStruct(builder interface{}, structVal *reflect.Value) interface{} { - getBuilderMap(builder).ForEach(func(name string, val ps.Any) { - if ast.IsExported(name) { - field := structVal.FieldByName(name) - - var value reflect.Value - switch v := val.(type) { - case nil: - switch field.Kind() { - case reflect.Chan, reflect.Func, reflect.Interface, reflect.Map, reflect.Ptr, reflect.Slice: - value = reflect.Zero(field.Type()) - } - // nil is not valid for this Type; Set will panic - case ps.List: - value = listToSlice(v, field.Type()) - default: - value = reflect.ValueOf(val) - } - field.Set(value) - } - }) - - return structVal.Interface() -} diff --git a/vendor/github.com/lann/builder/reflect.go b/vendor/github.com/lann/builder/reflect.go deleted file mode 100644 index 3b236e7..0000000 --- a/vendor/github.com/lann/builder/reflect.go +++ /dev/null @@ -1,24 +0,0 @@ -package builder - -import "reflect" - -func convert(from interface{}, to interface{}) interface{} { - return reflect. - ValueOf(from). - Convert(reflect.TypeOf(to)). - Interface() -} - -func forEach(s interface{}, f func(interface{})) { - val := reflect.ValueOf(s) - - kind := val.Kind() - if kind != reflect.Slice && kind != reflect.Array { - panic(&reflect.ValueError{Method: "builder.forEach", Kind: kind}) - } - - l := val.Len() - for i := 0; i < l; i++ { - f(val.Index(i).Interface()) - } -} diff --git a/vendor/github.com/lann/builder/registry.go b/vendor/github.com/lann/builder/registry.go deleted file mode 100644 index 182e69f..0000000 --- a/vendor/github.com/lann/builder/registry.go +++ /dev/null @@ -1,49 +0,0 @@ -package builder - -import "reflect" - -var registry = make(map[reflect.Type]reflect.Type) - -// RegisterType maps the given builderType to a structType. -// This mapping affects the type of slices returned by Get and is required for -// GetStruct to work. -// -// Returns a Value containing an empty instance of the registered builderType. -// -// RegisterType will panic if builderType's underlying type is not Builder or -// if structType's Kind is not Struct. -func RegisterType(builderType reflect.Type, structType reflect.Type) *reflect.Value { - structType.NumField() // Panic if structType is not a struct - registry[builderType] = structType - emptyValue := emptyBuilderValue.Convert(builderType) - return &emptyValue -} - -// Register wraps RegisterType, taking instances instead of Types. -// -// Returns an empty instance of the registered builder type which can be used -// as the initial value for builder expressions. See example. -func Register(builderProto interface{}, structProto interface{}) interface{} { - empty := RegisterType( - reflect.TypeOf(builderProto), - reflect.TypeOf(structProto), - ).Interface() - return empty -} - -func getBuilderStructType(builderType reflect.Type) *reflect.Type { - structType, ok := registry[builderType] - if !ok { - return nil - } - return &structType -} - -func newBuilderStruct(builderType reflect.Type) *reflect.Value { - structType := getBuilderStructType(builderType) - if structType == nil { - return nil - } - newStruct := reflect.New(*structType).Elem() - return &newStruct -} diff --git a/vendor/github.com/lann/ps/LICENSE b/vendor/github.com/lann/ps/LICENSE deleted file mode 100644 index 69f9ae8..0000000 --- a/vendor/github.com/lann/ps/LICENSE +++ /dev/null @@ -1,7 +0,0 @@ -Copyright (c) 2013 Michael Hendricks - -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/vendor/github.com/lann/ps/README.md b/vendor/github.com/lann/ps/README.md deleted file mode 100644 index 325a5b3..0000000 --- a/vendor/github.com/lann/ps/README.md +++ /dev/null @@ -1,10 +0,0 @@ -**This is a stable fork of https://github.com/mndrix/ps; it will not introduce breaking changes.** - -ps -== - -Persistent data structures for Go. See the [full package documentation](http://godoc.org/github.com/lann/ps) - -Install with - - go get github.com/lann/ps diff --git a/vendor/github.com/lann/ps/list.go b/vendor/github.com/lann/ps/list.go deleted file mode 100644 index 48a1ceb..0000000 --- a/vendor/github.com/lann/ps/list.go +++ /dev/null @@ -1,93 +0,0 @@ -package ps - -// List is a persistent list of possibly heterogenous values. -type List interface { - // IsNil returns true if the list is empty - IsNil() bool - - // Cons returns a new list with val as the head - Cons(val Any) List - - // Head returns the first element of the list; - // panics if the list is empty - Head() Any - - // Tail returns a list with all elements except the head; - // panics if the list is empty - Tail() List - - // Size returns the list's length. This takes O(1) time. - Size() int - - // ForEach executes a callback for each value in the list. - ForEach(f func(Any)) - - // Reverse returns a list whose elements are in the opposite order as - // the original list. - Reverse() List -} - -// Immutable (i.e. persistent) list -type list struct { - depth int // the number of nodes after, and including, this one - value Any - tail *list -} - -// An empty list shared by all lists -var nilList = &list{} - -// NewList returns a new, empty list. The result is a singly linked -// list implementation. All lists share an empty tail, so allocating -// empty lists is efficient in time and memory. -func NewList() List { - return nilList -} - -func (self *list) IsNil() bool { - return self == nilList -} - -func (self *list) Size() int { - return self.depth -} - -func (tail *list) Cons(val Any) List { - var xs list - xs.depth = tail.depth + 1 - xs.value = val - xs.tail = tail - return &xs -} - -func (self *list) Head() Any { - if self.IsNil() { - panic("Called Head() on an empty list") - } - - return self.value -} - -func (self *list) Tail() List { - if self.IsNil() { - panic("Called Tail() on an empty list") - } - - return self.tail -} - -// ForEach executes a callback for each value in the list -func (self *list) ForEach(f func(Any)) { - if self.IsNil() { - return - } - f(self.Head()) - self.Tail().ForEach(f) -} - -// Reverse returns a list with elements in opposite order as this list -func (self *list) Reverse() List { - reversed := NewList() - self.ForEach(func(v Any) { reversed = reversed.Cons(v) }) - return reversed -} diff --git a/vendor/github.com/lann/ps/map.go b/vendor/github.com/lann/ps/map.go deleted file mode 100644 index 192daec..0000000 --- a/vendor/github.com/lann/ps/map.go +++ /dev/null @@ -1,311 +0,0 @@ -// Fully persistent data structures. A persistent data structure is a data -// structure that always preserves the previous version of itself when -// it is modified. Such data structures are effectively immutable, -// as their operations do not update the structure in-place, but instead -// always yield a new structure. -// -// Persistent -// data structures typically share structure among themselves. This allows -// operations to avoid copying the entire data structure. -package ps - -import ( - "bytes" - "fmt" -) - -// Any is a shorthand for Go's verbose interface{} type. -type Any interface{} - -// A Map associates unique keys (type string) with values (type Any). -type Map interface { - // IsNil returns true if the Map is empty - IsNil() bool - - // Set returns a new map in which key and value are associated. - // If the key didn't exist before, it's created; otherwise, the - // associated value is changed. - // This operation is O(log N) in the number of keys. - Set(key string, value Any) Map - - // Delete returns a new map with the association for key, if any, removed. - // This operation is O(log N) in the number of keys. - Delete(key string) Map - - // Lookup returns the value associated with a key, if any. If the key - // exists, the second return value is true; otherwise, false. - // This operation is O(log N) in the number of keys. - Lookup(key string) (Any, bool) - - // Size returns the number of key value pairs in the map. - // This takes O(1) time. - Size() int - - // ForEach executes a callback on each key value pair in the map. - ForEach(f func(key string, val Any)) - - // Keys returns a slice with all keys in this map. - // This operation is O(N) in the number of keys. - Keys() []string - - String() string -} - -// Immutable (i.e. persistent) associative array -const childCount = 8 -const shiftSize = 3 - -type tree struct { - count int - hash uint64 // hash of the key (used for tree balancing) - key string - value Any - children [childCount]*tree -} - -var nilMap = &tree{} - -// Recursively set nilMap's subtrees to point at itself. -// This eliminates all nil pointers in the map structure. -// All map nodes are created by cloning this structure so -// they avoid the problem too. -func init() { - for i := range nilMap.children { - nilMap.children[i] = nilMap - } -} - -// NewMap allocates a new, persistent map from strings to values of -// any type. -// This is currently implemented as a path-copying binary tree. -func NewMap() Map { - return nilMap -} - -func (self *tree) IsNil() bool { - return self == nilMap -} - -// clone returns an exact duplicate of a tree node -func (self *tree) clone() *tree { - var m tree - m = *self - return &m -} - -// constants for FNV-1a hash algorithm -const ( - offset64 uint64 = 14695981039346656037 - prime64 uint64 = 1099511628211 -) - -// hashKey returns a hash code for a given string -func hashKey(key string) uint64 { - hash := offset64 - for _, codepoint := range key { - hash ^= uint64(codepoint) - hash *= prime64 - } - return hash -} - -// Set returns a new map similar to this one but with key and value -// associated. If the key didn't exist, it's created; otherwise, the -// associated value is changed. -func (self *tree) Set(key string, value Any) Map { - hash := hashKey(key) - return setLowLevel(self, hash, hash, key, value) -} - -func setLowLevel(self *tree, partialHash, hash uint64, key string, value Any) *tree { - if self.IsNil() { // an empty tree is easy - m := self.clone() - m.count = 1 - m.hash = hash - m.key = key - m.value = value - return m - } - - if hash != self.hash { - m := self.clone() - i := partialHash % childCount - m.children[i] = setLowLevel(self.children[i], partialHash>>shiftSize, hash, key, value) - recalculateCount(m) - return m - } - - // replacing a key's previous value - m := self.clone() - m.value = value - return m -} - -// modifies a map by recalculating its key count based on the counts -// of its subtrees -func recalculateCount(m *tree) { - count := 0 - for _, t := range m.children { - count += t.Size() - } - m.count = count + 1 // add one to count ourself -} - -func (m *tree) Delete(key string) Map { - hash := hashKey(key) - newMap, _ := deleteLowLevel(m, hash, hash) - return newMap -} - -func deleteLowLevel(self *tree, partialHash, hash uint64) (*tree, bool) { - // empty trees are easy - if self.IsNil() { - return self, false - } - - if hash != self.hash { - i := partialHash % childCount - child, found := deleteLowLevel(self.children[i], partialHash>>shiftSize, hash) - if !found { - return self, false - } - newMap := self.clone() - newMap.children[i] = child - recalculateCount(newMap) - return newMap, true // ? this wasn't in the original code - } - - // we must delete our own node - if self.isLeaf() { // we have no children - return nilMap, true - } - /* - if self.subtreeCount() == 1 { // only one subtree - for _, t := range self.children { - if t != nilMap { - return t, true - } - } - panic("Tree with 1 subtree actually had no subtrees") - } - */ - - // find a node to replace us - i := -1 - size := -1 - for j, t := range self.children { - if t.Size() > size { - i = j - size = t.Size() - } - } - - // make chosen leaf smaller - replacement, child := self.children[i].deleteLeftmost() - newMap := replacement.clone() - for j := range self.children { - if j == i { - newMap.children[j] = child - } else { - newMap.children[j] = self.children[j] - } - } - recalculateCount(newMap) - return newMap, true -} - -// delete the leftmost node in a tree returning the node that -// was deleted and the tree left over after its deletion -func (m *tree) deleteLeftmost() (*tree, *tree) { - if m.isLeaf() { - return m, nilMap - } - - for i, t := range m.children { - if t != nilMap { - deleted, child := t.deleteLeftmost() - newMap := m.clone() - newMap.children[i] = child - recalculateCount(newMap) - return deleted, newMap - } - } - panic("Tree isn't a leaf but also had no children. How does that happen?") -} - -// isLeaf returns true if this is a leaf node -func (m *tree) isLeaf() bool { - return m.Size() == 1 -} - -// returns the number of child subtrees we have -func (m *tree) subtreeCount() int { - count := 0 - for _, t := range m.children { - if t != nilMap { - count++ - } - } - return count -} - -func (m *tree) Lookup(key string) (Any, bool) { - hash := hashKey(key) - return lookupLowLevel(m, hash, hash) -} - -func lookupLowLevel(self *tree, partialHash, hash uint64) (Any, bool) { - if self.IsNil() { // an empty tree is easy - return nil, false - } - - if hash != self.hash { - i := partialHash % childCount - return lookupLowLevel(self.children[i], partialHash>>shiftSize, hash) - } - - // we found it - return self.value, true -} - -func (m *tree) Size() int { - return m.count -} - -func (m *tree) ForEach(f func(key string, val Any)) { - if m.IsNil() { - return - } - - // ourself - f(m.key, m.value) - - // children - for _, t := range m.children { - if t != nilMap { - t.ForEach(f) - } - } -} - -func (m *tree) Keys() []string { - keys := make([]string, m.Size()) - i := 0 - m.ForEach(func(k string, v Any) { - keys[i] = k - i++ - }) - return keys -} - -// make it easier to display maps for debugging -func (m *tree) String() string { - keys := m.Keys() - buf := bytes.NewBufferString("{") - for _, key := range keys { - val, _ := m.Lookup(key) - fmt.Fprintf(buf, "%s: %s, ", key, val) - } - fmt.Fprintf(buf, "}\n") - return buf.String() -} diff --git a/vendor/github.com/lann/ps/profile.sh b/vendor/github.com/lann/ps/profile.sh deleted file mode 100755 index f03df05..0000000 --- a/vendor/github.com/lann/ps/profile.sh +++ /dev/null @@ -1,3 +0,0 @@ -#!/bin/sh -go test -c -./ps.test -test.run=none -test.bench=$2 -test.$1profile=$1.profile diff --git a/vendor/golang.org/x/tools/LICENSE b/vendor/golang.org/x/tools/LICENSE deleted file mode 100644 index 6a66aea..0000000 --- a/vendor/golang.org/x/tools/LICENSE +++ /dev/null @@ -1,27 +0,0 @@ -Copyright (c) 2009 The Go Authors. All rights reserved. - -Redistribution and use in source and binary forms, with or without -modification, are permitted provided that the following conditions are -met: - - * Redistributions of source code must retain the above copyright -notice, this list of conditions and the following disclaimer. - * Redistributions in binary form must reproduce the above -copyright notice, this list of conditions and the following disclaimer -in the documentation and/or other materials provided with the -distribution. - * Neither the name of Google Inc. nor the names of its -contributors may be used to endorse or promote products derived from -this software without specific prior written permission. - -THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS -"AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT -LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR -A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT -OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, -SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT -LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, -DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY -THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT -(INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE -OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. diff --git a/vendor/golang.org/x/tools/PATENTS b/vendor/golang.org/x/tools/PATENTS deleted file mode 100644 index 7330990..0000000 --- a/vendor/golang.org/x/tools/PATENTS +++ /dev/null @@ -1,22 +0,0 @@ -Additional IP Rights Grant (Patents) - -"This implementation" means the copyrightable works distributed by -Google as part of the Go project. - -Google hereby grants to You a perpetual, worldwide, non-exclusive, -no-charge, royalty-free, irrevocable (except as stated in this section) -patent license to make, have made, use, offer to sell, sell, import, -transfer and otherwise run, modify and propagate the contents of this -implementation of Go, where such license applies only to those patent -claims, both currently owned or controlled by Google and acquired in -the future, licensable by Google that are necessarily infringed by this -implementation of Go. This grant does not include claims that would be -infringed only as a consequence of further modification of this -implementation. If you or your agent or exclusive licensee institute or -order or agree to the institution of patent litigation against any -entity (including a cross-claim or counterclaim in a lawsuit) alleging -that this implementation of Go or any code incorporated within this -implementation of Go constitutes direct or contributory patent -infringement, or inducement of patent infringement, then any patent -rights granted to you under this License for this implementation of Go -shall terminate as of the date such litigation is filed. diff --git a/vendor/golang.org/x/tools/blog/atom/atom.go b/vendor/golang.org/x/tools/blog/atom/atom.go deleted file mode 100644 index 542c50e..0000000 --- a/vendor/golang.org/x/tools/blog/atom/atom.go +++ /dev/null @@ -1,61 +0,0 @@ -// Copyright 2009 The Go Authors. All rights reserved. -// Use of this source code is governed by a BSD-style -// license that can be found in the LICENSE file. - -// Adapted from encoding/xml/read_test.go. - -// Package atom defines XML data structures for an Atom feed. -package atom // import "golang.org/x/tools/blog/atom" - -import ( - "encoding/xml" - "time" -) - -type Feed struct { - XMLName xml.Name `xml:"http://www.w3.org/2005/Atom feed"` - Title string `xml:"title"` - ID string `xml:"id"` - Link []Link `xml:"link"` - Updated TimeStr `xml:"updated"` - Author *Person `xml:"author"` - Entry []*Entry `xml:"entry"` -} - -type Entry struct { - Title string `xml:"title"` - ID string `xml:"id"` - Link []Link `xml:"link"` - Published TimeStr `xml:"published"` - Updated TimeStr `xml:"updated"` - Author *Person `xml:"author"` - Summary *Text `xml:"summary"` - Content *Text `xml:"content"` -} - -type Link struct { - Rel string `xml:"rel,attr,omitempty"` - Href string `xml:"href,attr"` - Type string `xml:"type,attr,omitempty"` - HrefLang string `xml:"hreflang,attr,omitempty"` - Title string `xml:"title,attr,omitempty"` - Length uint `xml:"length,attr,omitempty"` -} - -type Person struct { - Name string `xml:"name"` - URI string `xml:"uri,omitempty"` - Email string `xml:"email,omitempty"` - InnerXML string `xml:",innerxml"` -} - -type Text struct { - Type string `xml:"type,attr"` - Body string `xml:",chardata"` -} - -type TimeStr string - -func Time(t time.Time) TimeStr { - return TimeStr(t.Format("2006-01-02T15:04:05-07:00")) -} diff --git a/vendor/vendor.json b/vendor/vendor.json deleted file mode 100644 index 514b4a8..0000000 --- a/vendor/vendor.json +++ /dev/null @@ -1,25 +0,0 @@ -{ - "comment": "", - "ignore": "test", - "package": [ - { - "checksumSHA1": "3dA3PsgYXZXzfsOOdDDvyp8zO0w=", - "path": "github.com/lann/builder", - "revision": "f22ce00fd9394014049dad11c244859432bd6820", - "revisionTime": "2015-08-08T15:11:31Z" - }, - { - "checksumSHA1": "nR871nUQ6KxGoDR+TdgQhGUqcHI=", - "path": "github.com/lann/ps", - "revision": "62de8c46ede02a7675c4c79c84883eb164cb71e3", - "revisionTime": "2015-08-10T15:23:59Z" - }, - { - "checksumSHA1": "LGXeoFu5U86xjYFW3YCY3rOIa+o=", - "path": "golang.org/x/tools/blog/atom", - "revision": "8e779ee0a4509783f6940db32d1a4e8df910cc8b", - "revisionTime": "2017-02-14T15:12:52Z" - } - ], - "rootPath": "github.com/dubyte/dir2opds" -}