Add generated file

This PR adds generated files under pkg/client and vendor folder.
This commit is contained in:
xing-yang
2018-07-12 10:55:15 -07:00
parent 36b1de0341
commit e213d1890d
17729 changed files with 5090889 additions and 0 deletions

156
vendor/golang.org/x/tools/godoc/vfs/mapfs/mapfs.go generated vendored Normal file
View File

@@ -0,0 +1,156 @@
// Copyright 2013 The Go Authors. All rights reserved.
// Use of this source code is governed by a BSD-style
// license that can be found in the LICENSE file.
// Package mapfs file provides an implementation of the FileSystem
// interface based on the contents of a map[string]string.
package mapfs // import "golang.org/x/tools/godoc/vfs/mapfs"
import (
"io"
"os"
pathpkg "path"
"sort"
"strings"
"time"
"golang.org/x/tools/godoc/vfs"
)
// New returns a new FileSystem from the provided map.
// Map keys should be forward slash-separated pathnames
// and not contain a leading slash.
func New(m map[string]string) vfs.FileSystem {
return mapFS(m)
}
// mapFS is the map based implementation of FileSystem
type mapFS map[string]string
func (fs mapFS) String() string { return "mapfs" }
func (fs mapFS) RootType(p string) vfs.RootType {
return ""
}
func (fs mapFS) Close() error { return nil }
func filename(p string) string {
return strings.TrimPrefix(p, "/")
}
func (fs mapFS) Open(p string) (vfs.ReadSeekCloser, error) {
b, ok := fs[filename(p)]
if !ok {
return nil, os.ErrNotExist
}
return nopCloser{strings.NewReader(b)}, nil
}
func fileInfo(name, contents string) os.FileInfo {
return mapFI{name: pathpkg.Base(name), size: len(contents)}
}
func dirInfo(name string) os.FileInfo {
return mapFI{name: pathpkg.Base(name), dir: true}
}
func (fs mapFS) Lstat(p string) (os.FileInfo, error) {
b, ok := fs[filename(p)]
if ok {
return fileInfo(p, b), nil
}
ents, _ := fs.ReadDir(p)
if len(ents) > 0 {
return dirInfo(p), nil
}
return nil, os.ErrNotExist
}
func (fs mapFS) Stat(p string) (os.FileInfo, error) {
return fs.Lstat(p)
}
// slashdir returns path.Dir(p), but special-cases paths not beginning
// with a slash to be in the root.
func slashdir(p string) string {
d := pathpkg.Dir(p)
if d == "." {
return "/"
}
if strings.HasPrefix(p, "/") {
return d
}
return "/" + d
}
func (fs mapFS) ReadDir(p string) ([]os.FileInfo, error) {
p = pathpkg.Clean(p)
var ents []string
fim := make(map[string]os.FileInfo) // base -> fi
for fn, b := range fs {
dir := slashdir(fn)
isFile := true
var lastBase string
for {
if dir == p {
base := lastBase
if isFile {
base = pathpkg.Base(fn)
}
if fim[base] == nil {
var fi os.FileInfo
if isFile {
fi = fileInfo(fn, b)
} else {
fi = dirInfo(base)
}
ents = append(ents, base)
fim[base] = fi
}
}
if dir == "/" {
break
} else {
isFile = false
lastBase = pathpkg.Base(dir)
dir = pathpkg.Dir(dir)
}
}
}
if len(ents) == 0 {
return nil, os.ErrNotExist
}
sort.Strings(ents)
var list []os.FileInfo
for _, dir := range ents {
list = append(list, fim[dir])
}
return list, nil
}
// mapFI is the map-based implementation of FileInfo.
type mapFI struct {
name string
size int
dir bool
}
func (fi mapFI) IsDir() bool { return fi.dir }
func (fi mapFI) ModTime() time.Time { return time.Time{} }
func (fi mapFI) Mode() os.FileMode {
if fi.IsDir() {
return 0755 | os.ModeDir
}
return 0444
}
func (fi mapFI) Name() string { return pathpkg.Base(fi.name) }
func (fi mapFI) Size() int64 { return int64(fi.size) }
func (fi mapFI) Sys() interface{} { return nil }
type nopCloser struct {
io.ReadSeeker
}
func (nc nopCloser) Close() error { return nil }

111
vendor/golang.org/x/tools/godoc/vfs/mapfs/mapfs_test.go generated vendored Normal file
View File

@@ -0,0 +1,111 @@
// Copyright 2013 The Go Authors. All rights reserved.
// Use of this source code is governed by a BSD-style
// license that can be found in the LICENSE file.
package mapfs
import (
"io/ioutil"
"os"
"reflect"
"testing"
)
func TestOpenRoot(t *testing.T) {
fs := New(map[string]string{
"foo/bar/three.txt": "a",
"foo/bar.txt": "b",
"top.txt": "c",
"other-top.txt": "d",
})
tests := []struct {
path string
want string
}{
{"/foo/bar/three.txt", "a"},
{"foo/bar/three.txt", "a"},
{"foo/bar.txt", "b"},
{"top.txt", "c"},
{"/top.txt", "c"},
{"other-top.txt", "d"},
{"/other-top.txt", "d"},
}
for _, tt := range tests {
rsc, err := fs.Open(tt.path)
if err != nil {
t.Errorf("Open(%q) = %v", tt.path, err)
continue
}
slurp, err := ioutil.ReadAll(rsc)
if err != nil {
t.Error(err)
}
if string(slurp) != tt.want {
t.Errorf("Read(%q) = %q; want %q", tt.path, tt.want, slurp)
}
rsc.Close()
}
_, err := fs.Open("/xxxx")
if !os.IsNotExist(err) {
t.Errorf("ReadDir /xxxx = %v; want os.IsNotExist error", err)
}
}
func TestReaddir(t *testing.T) {
fs := New(map[string]string{
"foo/bar/three.txt": "333",
"foo/bar.txt": "22",
"top.txt": "top.txt file",
"other-top.txt": "other-top.txt file",
})
tests := []struct {
dir string
want []os.FileInfo
}{
{
dir: "/",
want: []os.FileInfo{
mapFI{name: "foo", dir: true},
mapFI{name: "other-top.txt", size: len("other-top.txt file")},
mapFI{name: "top.txt", size: len("top.txt file")},
},
},
{
dir: "/foo",
want: []os.FileInfo{
mapFI{name: "bar", dir: true},
mapFI{name: "bar.txt", size: 2},
},
},
{
dir: "/foo/",
want: []os.FileInfo{
mapFI{name: "bar", dir: true},
mapFI{name: "bar.txt", size: 2},
},
},
{
dir: "/foo/bar",
want: []os.FileInfo{
mapFI{name: "three.txt", size: 3},
},
},
}
for _, tt := range tests {
fis, err := fs.ReadDir(tt.dir)
if err != nil {
t.Errorf("ReadDir(%q) = %v", tt.dir, err)
continue
}
if !reflect.DeepEqual(fis, tt.want) {
t.Errorf("ReadDir(%q) = %#v; want %#v", tt.dir, fis, tt.want)
continue
}
}
_, err := fs.ReadDir("/xxxx")
if !os.IsNotExist(err) {
t.Errorf("ReadDir /xxxx = %v; want os.IsNotExist error", err)
}
}