Преглед на файлове

Merge branch 'dev3.4.1' of http://192.168.3.207:10080/qmx/jy-data-extract into dev3.4.1

maxiaoshan преди 4 години
родител
ревизия
8c34f539c6
променени са 100 файла, в които са добавени 3636 реда и са изтрити 15968 реда
  1. 20 0
      data_monitoring/listen_lan/src/config.json
  2. 43 0
      data_monitoring/listen_lan/src/errmail.go
  3. 142 0
      data_monitoring/listen_lan/src/main.go
  4. 329 0
      data_monitoring/listen_lan/src/mgo.go
  5. 48 0
      data_monitoring/listen_lan/src/sitelisten.go
  6. 39 0
      data_monitoring/listen_online/src/config.json
  7. 63 0
      data_monitoring/listen_online/src/errmail.go
  8. 145 0
      data_monitoring/listen_online/src/main.go
  9. 329 0
      data_monitoring/listen_online/src/mgo.go
  10. 81 0
      data_monitoring/listen_online/src/priselisten.go
  11. 198 0
      data_monitoring/listen_online/src/sitelisten.go
  12. 40 0
      data_monitoring/listen_task/src/config.json
  13. 48 0
      data_monitoring/listen_task/src/dataTaskJP.go
  14. 58 0
      data_monitoring/listen_task/src/dataTaskQY.go
  15. 166 0
      data_monitoring/listen_task/src/dataTaskST.go
  16. 215 0
      data_monitoring/listen_task/src/main.go
  17. 40 0
      data_monitoring/listen_task/src/mark
  18. 329 0
      data_monitoring/listen_task/src/mgo.go
  19. 43 0
      data_monitoring/listen_task/src/sendmail.go
  20. 9 0
      data_monitoring/vps_client/src/config.json
  21. 140 0
      data_monitoring/vps_client/src/main.go
  22. 26 0
      data_monitoring/vps_server/src/config.json
  23. 202 0
      data_monitoring/vps_server/src/main.go
  24. 49 0
      data_monitoring/vps_server/src/mark
  25. 328 0
      data_monitoring/vps_server/src/mgo.go
  26. 62 0
      data_monitoring/vps_server/src/sendmail.go
  27. 13 0
      data_quality/src/mgo.go
  28. 13 5
      fullproject/src_v1/config.json
  29. 22 1
      fullproject/src_v1/init.go
  30. 44 2
      fullproject/src_v1/load_data.go
  31. 13 6
      fullproject/src_v1/main.go
  32. 29 0
      fullproject/src_v1/mgotool.go
  33. 44 18
      fullproject/src_v1/project.go
  34. 37 39
      fullproject/src_v1/task.go
  35. 5 6
      fullproject/src_v1/update.go
  36. 27 0
      monitor/README.MD
  37. 25 0
      monitor/config.json
  38. 56 0
      monitor/main.go
  39. 105 0
      monitor/task.go
  40. 0 29
      projectforecast/config.json
  41. 0 76
      projectforecast/main.go
  42. 0 191
      projectforecast/task.go
  43. 4 2
      qyxy/src/config.json
  44. 7 6
      qyxy/src/main.go
  45. 0 16
      qyxy/src/mgoutil/go.mongodb.org/mongo-driver/.errcheck-excludes
  46. 0 911
      qyxy/src/mgoutil/go.mongodb.org/mongo-driver/.evergreen/config.yml
  47. 0 8
      qyxy/src/mgoutil/go.mongodb.org/mongo-driver/.evergreen/krb5.config
  48. 0 12
      qyxy/src/mgoutil/go.mongodb.org/mongo-driver/.gitignore
  49. 0 3
      qyxy/src/mgoutil/go.mongodb.org/mongo-driver/.gitmodules
  50. 0 64
      qyxy/src/mgoutil/go.mongodb.org/mongo-driver/.lint-whitelist
  51. 0 37
      qyxy/src/mgoutil/go.mongodb.org/mongo-driver/CONTRIBUTING.md
  52. 0 367
      qyxy/src/mgoutil/go.mongodb.org/mongo-driver/Gopkg.lock
  53. 0 58
      qyxy/src/mgoutil/go.mongodb.org/mongo-driver/Gopkg.toml
  54. 0 201
      qyxy/src/mgoutil/go.mongodb.org/mongo-driver/LICENSE
  55. 0 147
      qyxy/src/mgoutil/go.mongodb.org/mongo-driver/Makefile
  56. 0 193
      qyxy/src/mgoutil/go.mongodb.org/mongo-driver/README.md
  57. 0 1336
      qyxy/src/mgoutil/go.mongodb.org/mongo-driver/THIRD-PARTY-NOTICES
  58. 0 75
      qyxy/src/mgoutil/go.mongodb.org/mongo-driver/benchmark/bson.go
  59. 0 123
      qyxy/src/mgoutil/go.mongodb.org/mongo-driver/benchmark/bson_document.go
  60. 0 88
      qyxy/src/mgoutil/go.mongodb.org/mongo-driver/benchmark/bson_map.go
  61. 0 103
      qyxy/src/mgoutil/go.mongodb.org/mongo-driver/benchmark/bson_struct.go
  62. 0 35
      qyxy/src/mgoutil/go.mongodb.org/mongo-driver/benchmark/bson_test.go
  63. 0 306
      qyxy/src/mgoutil/go.mongodb.org/mongo-driver/benchmark/bson_types.go
  64. 0 29
      qyxy/src/mgoutil/go.mongodb.org/mongo-driver/benchmark/canary.go
  65. 0 12
      qyxy/src/mgoutil/go.mongodb.org/mongo-driver/benchmark/canary_test.go
  66. 0 226
      qyxy/src/mgoutil/go.mongodb.org/mongo-driver/benchmark/harness.go
  67. 0 154
      qyxy/src/mgoutil/go.mongodb.org/mongo-driver/benchmark/harness_case.go
  68. 0 69
      qyxy/src/mgoutil/go.mongodb.org/mongo-driver/benchmark/harness_main.go
  69. 0 140
      qyxy/src/mgoutil/go.mongodb.org/mongo-driver/benchmark/harness_results.go
  70. 0 142
      qyxy/src/mgoutil/go.mongodb.org/mongo-driver/benchmark/multi.go
  71. 0 13
      qyxy/src/mgoutil/go.mongodb.org/mongo-driver/benchmark/multi_test.go
  72. 0 174
      qyxy/src/mgoutil/go.mongodb.org/mongo-driver/benchmark/single.go
  73. 0 14
      qyxy/src/mgoutil/go.mongodb.org/mongo-driver/benchmark/single_test.go
  74. 0 134
      qyxy/src/mgoutil/go.mongodb.org/mongo-driver/bson/benchmark_test.go
  75. 0 60
      qyxy/src/mgoutil/go.mongodb.org/mongo-driver/bson/bson.go
  76. 0 91
      qyxy/src/mgoutil/go.mongodb.org/mongo-driver/bson/bson_1_8.go
  77. 0 371
      qyxy/src/mgoutil/go.mongodb.org/mongo-driver/bson/bson_corpus_spec_test.go
  78. 0 113
      qyxy/src/mgoutil/go.mongodb.org/mongo-driver/bson/bson_test.go
  79. 0 163
      qyxy/src/mgoutil/go.mongodb.org/mongo-driver/bson/bsoncodec/bsoncodec.go
  80. 0 145
      qyxy/src/mgoutil/go.mongodb.org/mongo-driver/bson/bsoncodec/bsoncodec_test.go
  81. 0 1014
      qyxy/src/mgoutil/go.mongodb.org/mongo-driver/bson/bsoncodec/default_value_decoders.go
  82. 0 2870
      qyxy/src/mgoutil/go.mongodb.org/mongo-driver/bson/bsoncodec/default_value_decoders_test.go
  83. 0 648
      qyxy/src/mgoutil/go.mongodb.org/mongo-driver/bson/bsoncodec/default_value_encoders.go
  84. 0 1436
      qyxy/src/mgoutil/go.mongodb.org/mongo-driver/bson/bsoncodec/default_value_encoders_test.go
  85. 0 61
      qyxy/src/mgoutil/go.mongodb.org/mongo-driver/bson/bsoncodec/doc.go
  86. 0 65
      qyxy/src/mgoutil/go.mongodb.org/mongo-driver/bson/bsoncodec/mode.go
  87. 0 110
      qyxy/src/mgoutil/go.mongodb.org/mongo-driver/bson/bsoncodec/pointer_codec.go
  88. 0 14
      qyxy/src/mgoutil/go.mongodb.org/mongo-driver/bson/bsoncodec/proxy.go
  89. 0 384
      qyxy/src/mgoutil/go.mongodb.org/mongo-driver/bson/bsoncodec/registry.go
  90. 0 359
      qyxy/src/mgoutil/go.mongodb.org/mongo-driver/bson/bsoncodec/registry_test.go
  91. 0 367
      qyxy/src/mgoutil/go.mongodb.org/mongo-driver/bson/bsoncodec/struct_codec.go
  92. 0 47
      qyxy/src/mgoutil/go.mongodb.org/mongo-driver/bson/bsoncodec/struct_codec_test.go
  93. 0 119
      qyxy/src/mgoutil/go.mongodb.org/mongo-driver/bson/bsoncodec/struct_tag_parser.go
  94. 0 73
      qyxy/src/mgoutil/go.mongodb.org/mongo-driver/bson/bsoncodec/struct_tag_parser_test.go
  95. 0 80
      qyxy/src/mgoutil/go.mongodb.org/mongo-driver/bson/bsoncodec/types.go
  96. 0 33
      qyxy/src/mgoutil/go.mongodb.org/mongo-driver/bson/bsonrw/bsonrw_test.go
  97. 0 847
      qyxy/src/mgoutil/go.mongodb.org/mongo-driver/bson/bsonrw/bsonrwtest/bsonrwtest.go
  98. 0 389
      qyxy/src/mgoutil/go.mongodb.org/mongo-driver/bson/bsonrw/copier.go
  99. 0 529
      qyxy/src/mgoutil/go.mongodb.org/mongo-driver/bson/bsonrw/copier_test.go
  100. 0 9
      qyxy/src/mgoutil/go.mongodb.org/mongo-driver/bson/bsonrw/doc.go

+ 20 - 0
data_monitoring/listen_lan/src/config.json

@@ -0,0 +1,20 @@
+{
+  "data_mgodb": {
+    "addr": "baibai.ink:28082",
+    "db": "spider_data",
+    "coll": "data_bak",
+    "pool": 5
+  },
+  "save_other_name": "monitor_other",
+  "dynamic_coll_name": "z_site_spider",
+  "smtpMail": {
+    "from": "zhengkun@topnet.net.cn",
+    "to": "zhengkun@topnet.net.cn",
+    "cc": "zhengkun@topnet.net.cn",
+    "smtpHost": "smtp.qq.com",
+    "smtpPort": "465",
+    "user":     "920032221@qq.com",
+    "pwd":      "xomkphsjsamybdbj"
+  },
+  "xlsx_name" : "统计.xlsx"
+}

+ 43 - 0
data_monitoring/listen_lan/src/errmail.go

@@ -0,0 +1,43 @@
+package main
+
+import (
+	"fmt"
+	"io/ioutil"
+	"os"
+	qu "qfw/util"
+	"qfw/util/mail"
+)
+
+var from,to,cc, smtpHost,user,pwd string
+var smtpPort int
+
+
+func sendErrMailSmtp(title,body string) {
+
+
+	smtpMail, _ := sysconfig["smtpMail"].(map[string]interface{})
+
+	if smtpMail != nil {
+		from, _ = smtpMail["from"].(string)
+		to, _ = smtpMail["to"].(string)
+		cc, _ = smtpMail["cc"].(string)
+		smtpHost, _ = smtpMail["smtpHost"].(string)
+		smtpPort= qu.IntAll(smtpMail["smtpPort"])
+		user, _ = smtpMail["user"].(string)
+		pwd, _ = smtpMail["pwd"].(string)
+	}
+	f, _ := os.Open(xlsx_name)
+	b, err := ioutil.ReadAll(f)
+	if err != nil {
+		fmt.Println("err:",err)
+		return
+	}
+
+	ok := mail.GSendMail_B(user, from, cc, from, title, body, f.Name(), b, &mail.GmailAuth{
+		SmtpHost: smtpHost,
+		SmtpPort: smtpPort,
+		User:     user,
+		Pwd:      pwd,
+	})
+	fmt.Println(ok)
+}

+ 142 - 0
data_monitoring/listen_lan/src/main.go

@@ -0,0 +1,142 @@
+package main
+
+import (
+	"fmt"
+	"github.com/cron"
+	"github.com/tealeg/xlsx"
+	"log"
+	"os"
+	qu "qfw/util"
+	"time"
+)
+
+
+var (
+	sysconfig    							map[string]interface{} //配置文件
+	data_mgo						      	*MongodbSim     //mongodb操作对象
+	save_other_name,data_coll_name			string
+	xlsx_name,dynamic_coll_name				string
+	infoSiteArr								[]string
+)
+
+func initMgo()  {
+
+	dconf := sysconfig["data_mgodb"].(map[string]interface{})
+	data_coll_name = qu.ObjToString(dconf["coll"])
+	data_mgo = &MongodbSim{
+		MongodbAddr: dconf["addr"].(string),
+		DbName:      dconf["db"].(string),
+		Size:        qu.IntAllDef(dconf["pool"], 5),
+	}
+	data_mgo.InitPool()
+
+
+
+	//属性赋值
+	save_other_name = qu.ObjToString(sysconfig["save_other_name"])
+	dynamic_coll_name = qu.ObjToString(sysconfig["dynamic_coll_name"])
+	xlsx_name = qu.ObjToString(sysconfig["xlsx_name"])
+}
+
+func init() {
+	//加载配置文件
+	qu.ReadConfig(&sysconfig)
+	initMgo()
+}
+
+func main() {
+	go taskTime()
+	time.Sleep(99999 * time.Hour)
+
+}
+
+func taskTime()  {
+
+	log.Println("部署定时任务")
+	c := cron.New()
+	//企业变更-站点-mongo
+	c.AddFunc("0 0 9 ? * *", func() { dealWithOtherData() })
+
+	c.Start()
+
+}
+
+func dealWithOtherData()  {
+
+	log.Println("开始统计相关数据...")
+
+	//先获取-待统计-动态站点
+	tmp ,tmp_err := data_mgo.Find(dynamic_coll_name, map[string]interface{}{},nil,nil)
+	if tmp_err==nil && tmp!=nil && len(tmp)>0 {
+		infoSiteArr = make([]string,0)
+		for _,v :=range tmp {
+			infoSiteArr = append(infoSiteArr,qu.ObjToString(v["site"]))
+		}
+		log.Println("目标站点:",len(infoSiteArr))
+	}
+	start := int(time.Now().Unix())
+	spider_data :=dealWithSiteSpiderData()//站点数据
+	comeintime :=qu.Int64All(time.Now().Unix())
+
+	data_mgo.Save(save_other_name, map[string]interface{}{
+		"name":"站点",
+		"num":qu.IntAll(spider_data["num"]),
+		"comeintime":comeintime,
+		"date":qu.ObjToString(spider_data["date"]),
+		"data":spider_data["data"],
+	})
+
+	//获取前两天数据
+	now:=time.Now() //当前天
+	cur_time:= time.Date(now.Year(), now.Month(), now.Day(), 0, 0, 0, 0, time.Local).Unix()
+	before_time := cur_time-86400*2
+	before_date :=qu.FormatDateByInt64(&before_time, qu.DATEFORMAT)
+
+
+	//站点数据
+	before_st_data :=data_mgo.FindOne(save_other_name, map[string]interface{}{
+		"name":"站点",
+		"date":before_date,
+	})
+
+
+	os.Remove("统计.xlsx")	//写excle
+	f :=xlsx.NewFile()
+	sheet, _ := f.AddSheet("统计")
+
+	//企业数据
+	row := sheet.AddRow()
+	row.AddCell().Value = "站点分类/日期"
+	row.AddCell().SetString(qu.ObjToString(spider_data["date"]))
+	if len(before_st_data)>0 {
+		row.AddCell().SetString(qu.ObjToString(before_st_data["date"]))
+	}
+
+	data_1 := *qu.ObjToMap(spider_data["data"])
+	data_2 := *qu.ObjToMap(before_st_data["data"])
+
+	for _,key := range infoSiteArr {
+		row = sheet.AddRow()
+		row.AddCell().SetString(key)
+		row.AddCell().SetString(fmt.Sprintf("%d",qu.Int64All(data_1[key])))
+		if len(before_st_data)>0 {
+			row.AddCell().SetString(fmt.Sprintf("%d",qu.Int64All(data_2[key])))
+		}
+	}
+	row = sheet.AddRow()
+	row.AddCell().Value = "总计"
+	row.AddCell().SetString(fmt.Sprintf("%d",qu.Int64All(spider_data["num"])))
+	if len(before_st_data)>0 {
+		row.AddCell().SetString(fmt.Sprintf("%d", qu.Int64All(before_st_data["num"])))
+	}
+	err := f.Save(xlsx_name)
+	if err != nil {
+		log.Println("保存xlsx失败:", err)
+	}else {
+		log.Println("保存xlsx成功:", err)
+	}
+
+	sendErrMailSmtp("统计-站点","附件")
+
+	log.Println("定时处理完毕...",int(time.Now().Unix())-start,"秒")
+}

+ 329 - 0
data_monitoring/listen_lan/src/mgo.go

@@ -0,0 +1,329 @@
+package main
+
+import (
+	"context"
+	"log"
+	"time"
+
+	"go.mongodb.org/mongo-driver/bson"
+	"go.mongodb.org/mongo-driver/bson/primitive"
+	"go.mongodb.org/mongo-driver/mongo"
+	"go.mongodb.org/mongo-driver/mongo/options"
+)
+
+type MgoSess struct {
+	Db     string
+	Coll   string
+	Query  interface{}
+	Sorts  []string
+	fields interface{}
+	limit  int64
+	skip   int64
+	M      *MongodbSim
+}
+
+type MgoIter struct {
+	Cursor *mongo.Cursor
+}
+
+func (mt *MgoIter) Next(result interface{}) bool {
+	if mt.Cursor != nil {
+		if mt.Cursor.Next(nil) {
+			err := mt.Cursor.Decode(result)
+			if err != nil {
+				log.Println("mgo cur err", err.Error())
+				mt.Cursor.Close(nil)
+				return false
+			}
+			return true
+		} else {
+			mt.Cursor.Close(nil)
+			return false
+		}
+	} else {
+		return false
+	}
+
+}
+
+func (ms *MgoSess) DB(name string) *MgoSess {
+	ms.Db = name
+	return ms
+}
+
+func (ms *MgoSess) C(name string) *MgoSess {
+	ms.Coll = name
+	return ms
+}
+
+func (ms *MgoSess) Find(q interface{}) *MgoSess {
+	ms.Query = q
+	return ms
+}
+
+func (ms *MgoSess) Select(fields interface{}) *MgoSess {
+	ms.fields = fields
+	return ms
+}
+
+func (ms *MgoSess) Limit(limit int64) *MgoSess {
+	ms.limit = limit
+	return ms
+}
+func (ms *MgoSess) Skip(skip int64) *MgoSess {
+	ms.skip = skip
+	return ms
+}
+
+func (ms *MgoSess) Sort(sorts ...string) *MgoSess {
+	ms.Sorts = sorts
+	return ms
+}
+
+func (ms *MgoSess) Iter() *MgoIter {
+	it := &MgoIter{}
+	find := options.Find()
+	if ms.skip > 0 {
+		find.SetSkip(ms.skip)
+	}
+	if ms.limit > 0 {
+		find.SetLimit(ms.limit)
+	}
+	find.SetBatchSize(100)
+	if len(ms.Sorts) > 0 {
+		sort := bson.M{}
+		for _, k := range ms.Sorts {
+			switch k[:1] {
+			case "-":
+				sort[k[1:]] = -1
+			case "+":
+				sort[k[1:]] = 1
+			default:
+				sort[k] = 1
+			}
+		}
+		find.SetSort(sort)
+	}
+	if ms.fields != nil {
+		find.SetProjection(ms.fields)
+	}
+	cur, err := ms.M.C.Database(ms.Db).Collection(ms.Coll).Find(ms.M.Ctx, ms.Query, find)
+	if err != nil {
+		log.Println("mgo find err", err.Error())
+	} else {
+		it.Cursor = cur
+	}
+	return it
+}
+
+type MongodbSim struct {
+	MongodbAddr string
+	Size        int
+	//	MinSize     int
+	DbName   string
+	C        *mongo.Client
+	Ctx      context.Context
+	ShortCtx context.Context
+	pool     chan bool
+	UserName string
+	Password string
+}
+
+func (m *MongodbSim) GetMgoConn() *MgoSess {
+	//m.Open()
+	ms := &MgoSess{}
+	ms.M = m
+	return ms
+}
+
+func (m *MongodbSim) DestoryMongoConn(ms *MgoSess) {
+	//m.Close()
+	ms.M = nil
+	ms = nil
+}
+
+func (m *MongodbSim) InitPool() {
+	opts := options.Client()
+	opts.SetConnectTimeout(3 * time.Second)
+	opts.ApplyURI("mongodb://" + m.MongodbAddr)
+	opts.SetMaxPoolSize(uint64(m.Size))
+	m.pool = make(chan bool, m.Size)
+
+	if m.UserName !="" && m.Password !="" {
+		cre := options.Credential{
+			Username:m.UserName,
+			Password:m.Password,
+		}
+		opts.SetAuth(cre)
+	}
+
+
+
+	opts.SetMaxConnIdleTime(2 * time.Hour)
+	m.Ctx, _ = context.WithTimeout(context.Background(), 99999*time.Hour)
+	m.ShortCtx, _ = context.WithTimeout(context.Background(), 1*time.Minute)
+	client, err := mongo.Connect(m.ShortCtx, opts)
+	if err != nil {
+		log.Println("mgo init error:", err.Error())
+	} else {
+		m.C = client
+		log.Println("init success")
+	}
+}
+
+func (m *MongodbSim) Open() {
+	m.pool <- true
+}
+func (m *MongodbSim) Close() {
+	<-m.pool
+}
+
+//批量插入
+func (m *MongodbSim) UpSertBulk(c string, doc ...[]map[string]interface{}) (map[int64]interface{}, bool) {
+	m.Open()
+	defer m.Close()
+	coll := m.C.Database(m.DbName).Collection(c)
+	var writes []mongo.WriteModel
+	for _, d := range doc {
+		write := mongo.NewUpdateOneModel()
+		write.SetFilter(d[0])
+		write.SetUpdate(d[1])
+		write.SetUpsert(true)
+		writes = append(writes, write)
+	}
+	r, e := coll.BulkWrite(m.Ctx, writes)
+	if e != nil {
+		log.Println("mgo upsert error:", e.Error())
+		return nil, false
+	}
+	//	else {
+	//		if r.UpsertedCount != int64(len(doc)) {
+	//			log.Println("mgo upsert uncomplete:uc/dc", r.UpsertedCount, len(doc))
+	//		}
+	//		return true
+	//	}
+	return r.UpsertedIDs, true
+}
+
+//批量插入
+func (m *MongodbSim) SaveBulk(c string, doc ...map[string]interface{}) bool {
+	m.Open()
+	defer m.Close()
+	coll := m.C.Database(m.DbName).Collection(c)
+	var writes []mongo.WriteModel
+	for _, d := range doc {
+		write := mongo.NewInsertOneModel()
+		write.SetDocument(d)
+		writes = append(writes, write)
+	}
+	_, e := coll.BulkWrite(m.Ctx, writes)
+	if e != nil {
+		log.Println("mgo savebulk error:", e.Error())
+		return false
+	}
+	return true
+}
+
+//保存
+func (m *MongodbSim) Save(c string, doc map[string]interface{}) interface{} {
+	m.Open()
+	defer m.Close()
+	coll := m.C.Database(m.DbName).Collection(c)
+	r, err := coll.InsertOne(m.Ctx, doc)
+	if err != nil {
+		return nil
+	}
+	return r.InsertedID
+}
+
+//更新by Id
+func (m *MongodbSim) UpdateById(c, id string, doc map[string]interface{}) bool {
+	m.Open()
+	defer m.Close()
+	coll := m.C.Database(m.DbName).Collection(c)
+	_, err := coll.UpdateOne(m.Ctx, map[string]interface{}{"_id": StringTOBsonId(id)}, doc)
+	if err != nil {
+		return false
+	}
+	return true
+}
+
+//删除by id
+func (m *MongodbSim) DeleteById(c, id string) int64 {
+	m.Open()
+	defer m.Close()
+	coll := m.C.Database(m.DbName).Collection(c)
+	r, err := coll.DeleteOne(m.Ctx, map[string]interface{}{"_id": StringTOBsonId(id)})
+	if err != nil {
+		return 0
+	}
+	return r.DeletedCount
+}
+
+//通过条件删除
+func (m *MongodbSim) Delete(c string, query map[string]interface{}) int64 {
+	m.Open()
+	defer m.Close()
+	coll := m.C.Database(m.DbName).Collection(c)
+	r, err := coll.DeleteMany(m.Ctx, query)
+	if err != nil {
+		return 0
+	}
+	return r.DeletedCount
+}
+
+//findbyid
+func (m *MongodbSim) FindById(c, id string) map[string]interface{} {
+	m.Open()
+	defer m.Close()
+	coll := m.C.Database(m.DbName).Collection(c)
+	r := coll.FindOne(m.Ctx, map[string]interface{}{"_id": StringTOBsonId(id)})
+	v := map[string]interface{}{}
+	r.Decode(&v)
+	return v
+}
+
+//findone
+func (m *MongodbSim) FindOne(c string, query map[string]interface{}) map[string]interface{} {
+	m.Open()
+	defer m.Close()
+	coll := m.C.Database(m.DbName).Collection(c)
+	r := coll.FindOne(m.Ctx, query)
+	v := map[string]interface{}{}
+	r.Decode(&v)
+	return v
+}
+
+//find
+func (m *MongodbSim) Find(c string, query map[string]interface{}, sort, fields interface{}) ([]map[string]interface{}, error) {
+	m.Open()
+	defer m.Close()
+	coll := m.C.Database(m.DbName).Collection(c)
+	op := options.Find()
+	r, err := coll.Find(m.Ctx, query, op.SetSort(sort), op.SetProjection(fields))
+	if err != nil {
+		log.Fatal(err)
+		return nil, err
+	}
+
+	var results []map[string]interface{}
+	if err = r.All(m.Ctx, &results); err != nil {
+		log.Fatal(err)
+		return nil, err
+	}
+	return results, nil
+}
+
+//创建_id
+func NewObjectId() primitive.ObjectID {
+	return primitive.NewObjectID()
+}
+
+func StringTOBsonId(id string) primitive.ObjectID {
+	objectId, _ := primitive.ObjectIDFromHex(id)
+	return objectId
+}
+
+func BsonTOStringId(id interface{}) string {
+	return id.(primitive.ObjectID).Hex()
+}

+ 48 - 0
data_monitoring/listen_lan/src/sitelisten.go

@@ -0,0 +1,48 @@
+package main
+
+import (
+	qu "qfw/util"
+	"time"
+)
+
+
+func dealWithSiteSpiderData()(map[string]interface{}) {
+
+	defer qu.Catch()
+	now:=time.Now() //当前天
+	lt_time:= time.Date(now.Year(), now.Month(), now.Day(), 0, 0, 0, 0, time.Local).Unix()
+	gte_time := lt_time-86400
+
+	q := map[string]interface{}{
+		"comeintime": map[string]interface{}{
+			"$gte":  gte_time,
+			"$lt": lt_time,
+		},
+	}
+	sess := data_mgo.GetMgoConn()
+	defer data_mgo.DestoryMongoConn(sess)
+	//细节才需要遍历
+	it := sess.DB(data_mgo.DbName).C(data_coll_name).Find(&q).Select(map[string]interface{}{
+		"site":1,
+	}).Iter()
+	total,dict:=0,make(map[string]interface{},0)
+	for tmp := make(map[string]interface{}); it.Next(&tmp); total++ {
+		site := qu.ObjToString(tmp["site"])
+		if dict[site] == nil {
+			dict[site] = 1
+		}else {
+			num := qu.IntAll(dict[site])+1
+			dict[site] = num
+		}
+		tmp = make(map[string]interface{})
+	}
+
+
+
+	return map[string]interface{}{
+		"num":total,
+		"data":dict,
+		"date":qu.FormatDateByInt64(&gte_time, qu.DATEFORMAT),
+	}
+}
+

+ 39 - 0
data_monitoring/listen_online/src/config.json

@@ -0,0 +1,39 @@
+{
+  "save_mgodb": {
+    "addr": "192.168.3.207:27092",
+    "db": "zhengkun",
+    "coll": "monitor_other",
+    "pool": 5
+  },
+  "qy_mgodb": {
+    "addr": "192.168.3.207:27092",
+    "db": "zhengkun",
+    "coll": "baidu_enterprise",
+    "pool": 5
+  },
+  "st_mgodb": {
+    "addr": "192.168.3.207:27092",
+    "db": "zhengkun",
+    "coll": "result_20210109",
+    "pool": 5
+  },
+  "es_index_st": "bidding",
+  "es_type_st": "bidding",
+  "save_other_name": "monitor_other",
+  "save_site_name" : "monitor_site",
+  "unique_site_name": "z_site_unique",
+  "jkmail": {
+    "to": "zhengkun@topnet.net.cn",
+    "api": "http://172.17.145.179:19281/_send/_mail"
+  },
+  "smtpMail": {
+    "from": "zhengkun@topnet.net.cn",
+    "to": "zhengkun@topnet.net.cn,zhaoyujian@topnet.net.cn",
+    "cc": "zhengkun@topnet.net.cn",
+    "smtpHost": "smtp.qq.com",
+    "smtpPort": "465",
+    "user":     "920032221@qq.com",
+    "pwd":      "xomkphsjsamybdbj"
+  },
+  "xlsx_name" : "site_qy.xlsx"
+}

+ 63 - 0
data_monitoring/listen_online/src/errmail.go

@@ -0,0 +1,63 @@
+package main
+
+import (
+	"fmt"
+	"io/ioutil"
+	"log"
+	"net/http"
+	"qfw/util/mail"
+	"os"
+	qu "qfw/util"
+)
+var tomail string
+var api string
+var from,to,cc, smtpHost,user,pwd string
+var smtpPort int
+//api模式 二选一皆可
+func sendErrMailApi(title,body string)  {
+	jkmail, _ := sysconfig["jkmail"].(map[string]interface{})
+	if jkmail != nil {
+		tomail, _ = jkmail["to"].(string)
+		api, _ = jkmail["api"].(string)
+	}
+	log.Println(tomail,api)
+	res, err := http.Get(fmt.Sprintf("%s?to=%s&title=%s&body=%s", api, tomail, title, body))
+	if err == nil {
+		defer res.Body.Close()
+		read, err := ioutil.ReadAll(res.Body)
+		log.Println("邮件发送成功:", string(read), err)
+	}else {
+		log.Println("邮件发送失败:", err)
+	}
+}
+
+func sendErrMailSmtp(title,body string) {
+
+
+	smtpMail, _ := sysconfig["smtpMail"].(map[string]interface{})
+
+	if smtpMail != nil {
+		from, _ = smtpMail["from"].(string)
+		to, _ = smtpMail["to"].(string)
+		cc, _ = smtpMail["cc"].(string)
+		smtpHost, _ = smtpMail["smtpHost"].(string)
+		smtpPort= qu.IntAll(smtpMail["smtpPort"])
+		user, _ = smtpMail["user"].(string)
+		pwd, _ = smtpMail["pwd"].(string)
+	}
+	f, _ := os.Open(xlsx_name)
+	b, err := ioutil.ReadAll(f)
+	if err != nil {
+		fmt.Println("err:",err)
+		return
+	}
+
+
+	ok := mail.GSendMail_Bq(from, to, cc, cc, title, body, f.Name(), b, &mail.GmailAuth{
+		SmtpHost: smtpHost,
+		SmtpPort: smtpPort,
+		User:     user,
+		Pwd:      pwd,
+	})
+	fmt.Println(ok)
+}

+ 145 - 0
data_monitoring/listen_online/src/main.go

@@ -0,0 +1,145 @@
+package main
+
+import (
+	"fmt"
+	"github.com/cron"
+	"github.com/tealeg/xlsx"
+	"log"
+	"os"
+	qu "qfw/util"
+	"time"
+)
+
+
+var (
+	sysconfig    							map[string]interface{} //配置文件
+	save_mgo,qy_mgo,st_mgo        			*MongodbSim            //mongodb操作对象
+	qy_c_name,st_c_name						string
+	es_index_st,es_type_st					string
+	save_other_name,save_site_name			string
+	xlsx_name,unique_site_name				string
+)
+
+func initMgo()  {
+
+	saveconf := sysconfig["save_mgodb"].(map[string]interface{})
+	qy_c_name = qu.ObjToString(saveconf["coll"])
+	save_mgo = &MongodbSim{
+		MongodbAddr: saveconf["addr"].(string),
+		DbName:      saveconf["db"].(string),
+		Size:        qu.IntAllDef(saveconf["pool"], 5),
+	}
+	save_mgo.InitPool()
+
+	qconf := sysconfig["qy_mgodb"].(map[string]interface{})
+	qy_c_name = qu.ObjToString(qconf["coll"])
+	qy_mgo = &MongodbSim{
+		MongodbAddr: qconf["addr"].(string),
+		DbName:      qconf["db"].(string),
+		Size:        qu.IntAllDef(qconf["pool"], 5),
+	}
+	qy_mgo.InitPool()
+
+	sconf := sysconfig["st_mgodb"].(map[string]interface{})
+	st_c_name = qu.ObjToString(sconf["coll"])
+	st_mgo = &MongodbSim{
+		MongodbAddr: sconf["addr"].(string),
+		DbName:      sconf["db"].(string),
+		Size:        qu.IntAllDef(sconf["pool"], 5),
+	}
+	st_mgo.InitPool()
+
+
+	//属性赋值
+	es_index_st = qu.ObjToString(sysconfig["es_index_st"])
+	es_type_st = qu.ObjToString(sysconfig["es_type_st"])
+	save_other_name = qu.ObjToString(sysconfig["save_other_name"])
+	save_site_name = qu.ObjToString(sysconfig["save_site_name"])
+	unique_site_name = qu.ObjToString(sysconfig["unique_site_name"])
+	xlsx_name = qu.ObjToString(sysconfig["xlsx_name"])
+
+}
+
+func init() {
+	//加载配置文件
+	qu.ReadConfig(&sysconfig)
+	initMgo()
+}
+
+func main() {
+	log.Println("等待执行")
+	go taskTime()
+	time.Sleep(99999 * time.Hour)
+}
+
+func taskTime()  {
+
+	log.Println("部署定时任务")
+	c := cron.New()
+	//企业变更-mongo-site-es
+	c.AddFunc("0 50 8 ? * *", func() { dealWithUniqueData() })
+	c.Start()
+}
+
+func dealWithUniqueData()  {
+
+	log.Println("开始统计相关数据...")
+
+	qy_data := dealWithQYData()
+	st_data :=dealWithSTData()
+
+	log.Println("处理数据...发送邮件...")
+
+	os.Remove(xlsx_name)
+	f :=xlsx.NewFile()
+	sheet, _ := f.AddSheet("统计")
+	//企业数据
+	row := sheet.AddRow()
+	row.AddCell().Value = "企业变更/日期"
+	row.AddCell().Value = "数量"
+	for k,v :=range qy_data {
+		row = sheet.AddRow()
+		row.AddCell().SetString(k)
+		row.AddCell().SetString(fmt.Sprintf("%d",qu.IntAll(v)))
+	}
+	row = sheet.AddRow()
+	row = sheet.AddRow()
+
+
+	if len(st_data)>0 { //有数据
+		row = sheet.AddRow()
+		row.AddCell().Value = "主要站点/日期"
+		row.AddCell().Value = "名称"
+		row.AddCell().Value = "数量"
+		row.AddCell().Value = "总计"
+
+
+		mgodata := *qu.ObjToMap(st_data["mgodata"])
+		date := qu.ObjToString(st_data["date"])
+		total := qu.IntAll(st_data["mgonum"])
+		isT := false
+		for key,_ := range uniqueData {
+			row = sheet.AddRow()
+			if !isT {
+				row.AddCell().SetString(date)
+				row.AddCell().SetString(key)
+				row.AddCell().SetString(fmt.Sprintf("%d",qu.IntAll(mgodata[key])))
+				row.AddCell().SetString(fmt.Sprintf("%d",qu.IntAll(total)))
+				isT = true
+			}else {
+				row.AddCell().Value = ""
+				row.AddCell().SetString(key)
+				row.AddCell().SetString(fmt.Sprintf("%d",qu.IntAll(mgodata[key])))
+				row.AddCell().Value = ""
+			}
+		}
+	}
+	err := f.Save(xlsx_name)
+	if err != nil {
+		log.Println("保存xlsx失败:", err)
+	}else {
+		log.Println("保存xlsx成功:", err)
+	}
+
+	sendErrMailSmtp("主要站点以及企业相关统计","附件")
+}

+ 329 - 0
data_monitoring/listen_online/src/mgo.go

@@ -0,0 +1,329 @@
+package main
+
+import (
+	"context"
+	"log"
+	"time"
+
+	"go.mongodb.org/mongo-driver/bson"
+	"go.mongodb.org/mongo-driver/bson/primitive"
+	"go.mongodb.org/mongo-driver/mongo"
+	"go.mongodb.org/mongo-driver/mongo/options"
+)
+
+type MgoSess struct {
+	Db     string
+	Coll   string
+	Query  interface{}
+	Sorts  []string
+	fields interface{}
+	limit  int64
+	skip   int64
+	M      *MongodbSim
+}
+
+type MgoIter struct {
+	Cursor *mongo.Cursor
+}
+
+func (mt *MgoIter) Next(result interface{}) bool {
+	if mt.Cursor != nil {
+		if mt.Cursor.Next(nil) {
+			err := mt.Cursor.Decode(result)
+			if err != nil {
+				log.Println("mgo cur err", err.Error())
+				mt.Cursor.Close(nil)
+				return false
+			}
+			return true
+		} else {
+			mt.Cursor.Close(nil)
+			return false
+		}
+	} else {
+		return false
+	}
+
+}
+
+func (ms *MgoSess) DB(name string) *MgoSess {
+	ms.Db = name
+	return ms
+}
+
+func (ms *MgoSess) C(name string) *MgoSess {
+	ms.Coll = name
+	return ms
+}
+
+func (ms *MgoSess) Find(q interface{}) *MgoSess {
+	ms.Query = q
+	return ms
+}
+
+func (ms *MgoSess) Select(fields interface{}) *MgoSess {
+	ms.fields = fields
+	return ms
+}
+
+func (ms *MgoSess) Limit(limit int64) *MgoSess {
+	ms.limit = limit
+	return ms
+}
+func (ms *MgoSess) Skip(skip int64) *MgoSess {
+	ms.skip = skip
+	return ms
+}
+
+func (ms *MgoSess) Sort(sorts ...string) *MgoSess {
+	ms.Sorts = sorts
+	return ms
+}
+
+func (ms *MgoSess) Iter() *MgoIter {
+	it := &MgoIter{}
+	find := options.Find()
+	if ms.skip > 0 {
+		find.SetSkip(ms.skip)
+	}
+	if ms.limit > 0 {
+		find.SetLimit(ms.limit)
+	}
+	find.SetBatchSize(100)
+	if len(ms.Sorts) > 0 {
+		sort := bson.M{}
+		for _, k := range ms.Sorts {
+			switch k[:1] {
+			case "-":
+				sort[k[1:]] = -1
+			case "+":
+				sort[k[1:]] = 1
+			default:
+				sort[k] = 1
+			}
+		}
+		find.SetSort(sort)
+	}
+	if ms.fields != nil {
+		find.SetProjection(ms.fields)
+	}
+	cur, err := ms.M.C.Database(ms.Db).Collection(ms.Coll).Find(ms.M.Ctx, ms.Query, find)
+	if err != nil {
+		log.Println("mgo find err", err.Error())
+	} else {
+		it.Cursor = cur
+	}
+	return it
+}
+
+type MongodbSim struct {
+	MongodbAddr string
+	Size        int
+	//	MinSize     int
+	DbName   string
+	C        *mongo.Client
+	Ctx      context.Context
+	ShortCtx context.Context
+	pool     chan bool
+	UserName string
+	Password string
+}
+
+func (m *MongodbSim) GetMgoConn() *MgoSess {
+	//m.Open()
+	ms := &MgoSess{}
+	ms.M = m
+	return ms
+}
+
+func (m *MongodbSim) DestoryMongoConn(ms *MgoSess) {
+	//m.Close()
+	ms.M = nil
+	ms = nil
+}
+
+func (m *MongodbSim) InitPool() {
+	opts := options.Client()
+	opts.SetConnectTimeout(3 * time.Second)
+	opts.ApplyURI("mongodb://" + m.MongodbAddr)
+	opts.SetMaxPoolSize(uint64(m.Size))
+	m.pool = make(chan bool, m.Size)
+
+	if m.UserName !="" && m.Password !="" {
+		cre := options.Credential{
+			Username:m.UserName,
+			Password:m.Password,
+		}
+		opts.SetAuth(cre)
+	}
+
+
+
+	opts.SetMaxConnIdleTime(2 * time.Hour)
+	m.Ctx, _ = context.WithTimeout(context.Background(), 99999*time.Hour)
+	m.ShortCtx, _ = context.WithTimeout(context.Background(), 1*time.Minute)
+	client, err := mongo.Connect(m.ShortCtx, opts)
+	if err != nil {
+		log.Println("mgo init error:", err.Error())
+	} else {
+		m.C = client
+		log.Println("init success")
+	}
+}
+
+func (m *MongodbSim) Open() {
+	m.pool <- true
+}
+func (m *MongodbSim) Close() {
+	<-m.pool
+}
+
+//批量插入
+func (m *MongodbSim) UpSertBulk(c string, doc ...[]map[string]interface{}) (map[int64]interface{}, bool) {
+	m.Open()
+	defer m.Close()
+	coll := m.C.Database(m.DbName).Collection(c)
+	var writes []mongo.WriteModel
+	for _, d := range doc {
+		write := mongo.NewUpdateOneModel()
+		write.SetFilter(d[0])
+		write.SetUpdate(d[1])
+		write.SetUpsert(true)
+		writes = append(writes, write)
+	}
+	r, e := coll.BulkWrite(m.Ctx, writes)
+	if e != nil {
+		log.Println("mgo upsert error:", e.Error())
+		return nil, false
+	}
+	//	else {
+	//		if r.UpsertedCount != int64(len(doc)) {
+	//			log.Println("mgo upsert uncomplete:uc/dc", r.UpsertedCount, len(doc))
+	//		}
+	//		return true
+	//	}
+	return r.UpsertedIDs, true
+}
+
+//批量插入
+func (m *MongodbSim) SaveBulk(c string, doc ...map[string]interface{}) bool {
+	m.Open()
+	defer m.Close()
+	coll := m.C.Database(m.DbName).Collection(c)
+	var writes []mongo.WriteModel
+	for _, d := range doc {
+		write := mongo.NewInsertOneModel()
+		write.SetDocument(d)
+		writes = append(writes, write)
+	}
+	_, e := coll.BulkWrite(m.Ctx, writes)
+	if e != nil {
+		log.Println("mgo savebulk error:", e.Error())
+		return false
+	}
+	return true
+}
+
+//保存
+func (m *MongodbSim) Save(c string, doc map[string]interface{}) interface{} {
+	m.Open()
+	defer m.Close()
+	coll := m.C.Database(m.DbName).Collection(c)
+	r, err := coll.InsertOne(m.Ctx, doc)
+	if err != nil {
+		return nil
+	}
+	return r.InsertedID
+}
+
+//更新by Id
+func (m *MongodbSim) UpdateById(c, id string, doc map[string]interface{}) bool {
+	m.Open()
+	defer m.Close()
+	coll := m.C.Database(m.DbName).Collection(c)
+	_, err := coll.UpdateOne(m.Ctx, map[string]interface{}{"_id": StringTOBsonId(id)}, doc)
+	if err != nil {
+		return false
+	}
+	return true
+}
+
+//删除by id
+func (m *MongodbSim) DeleteById(c, id string) int64 {
+	m.Open()
+	defer m.Close()
+	coll := m.C.Database(m.DbName).Collection(c)
+	r, err := coll.DeleteOne(m.Ctx, map[string]interface{}{"_id": StringTOBsonId(id)})
+	if err != nil {
+		return 0
+	}
+	return r.DeletedCount
+}
+
+//通过条件删除
+func (m *MongodbSim) Delete(c string, query map[string]interface{}) int64 {
+	m.Open()
+	defer m.Close()
+	coll := m.C.Database(m.DbName).Collection(c)
+	r, err := coll.DeleteMany(m.Ctx, query)
+	if err != nil {
+		return 0
+	}
+	return r.DeletedCount
+}
+
+//findbyid
+func (m *MongodbSim) FindById(c, id string) map[string]interface{} {
+	m.Open()
+	defer m.Close()
+	coll := m.C.Database(m.DbName).Collection(c)
+	r := coll.FindOne(m.Ctx, map[string]interface{}{"_id": StringTOBsonId(id)})
+	v := map[string]interface{}{}
+	r.Decode(&v)
+	return v
+}
+
+//findone
+func (m *MongodbSim) FindOne(c string, query map[string]interface{}) map[string]interface{} {
+	m.Open()
+	defer m.Close()
+	coll := m.C.Database(m.DbName).Collection(c)
+	r := coll.FindOne(m.Ctx, query)
+	v := map[string]interface{}{}
+	r.Decode(&v)
+	return v
+}
+
+//find
+func (m *MongodbSim) Find(c string, query map[string]interface{}, sort, fields interface{}) ([]map[string]interface{}, error) {
+	m.Open()
+	defer m.Close()
+	coll := m.C.Database(m.DbName).Collection(c)
+	op := options.Find()
+	r, err := coll.Find(m.Ctx, query, op.SetSort(sort), op.SetProjection(fields))
+	if err != nil {
+		log.Fatal(err)
+		return nil, err
+	}
+
+	var results []map[string]interface{}
+	if err = r.All(m.Ctx, &results); err != nil {
+		log.Fatal(err)
+		return nil, err
+	}
+	return results, nil
+}
+
+//创建_id
+func NewObjectId() primitive.ObjectID {
+	return primitive.NewObjectID()
+}
+
+func StringTOBsonId(id string) primitive.ObjectID {
+	objectId, _ := primitive.ObjectIDFromHex(id)
+	return objectId
+}
+
+func BsonTOStringId(id interface{}) string {
+	return id.(primitive.ObjectID).Hex()
+}

+ 81 - 0
data_monitoring/listen_online/src/priselisten.go

@@ -0,0 +1,81 @@
+package main
+
+import (
+	"log"
+	qu "qfw/util"
+	"time"
+)
+
+
+func dealWithQYData()map[string]interface{} {
+
+
+	defer qu.Catch()
+	start := int(time.Now().Unix())
+	now:=time.Now() //当前天
+	lt_time:= time.Date(now.Year(), now.Month(), now.Day(), 0, 0, 0, 0, time.Local).Unix()
+	gte_time := lt_time-86400
+	q := map[string]interface{}{
+		"down_time": map[string]interface{}{
+			"$gte":  gte_time,
+			"$lt": lt_time,
+		},
+	}
+	sess := qy_mgo.GetMgoConn()
+	defer qy_mgo.DestoryMongoConn(sess)
+
+	data := make(map[string]interface{},0)
+	//细节才需要遍历
+	it := sess.DB(qy_mgo.DbName).C(qy_c_name).Find(&q).Select(map[string]interface{}{
+		"site":1,
+	}).Iter()
+	total:=0
+	for tmp := make(map[string]interface{}); it.Next(&tmp); total++ {
+		tmp = make(map[string]interface{})
+	}
+
+	qy_date := qu.FormatDateByInt64(&gte_time, qu.DATEFORMAT)
+	data[qy_date] = total
+	comeintime :=qu.Int64All(time.Now().Unix())
+	save_mgo.Save(save_other_name, map[string]interface{}{
+		"name":"企业",
+		"num":qu.IntAll(total),
+		"comeintime":comeintime,
+		"date":qy_date,
+	})
+
+	//获取前两天数据
+	before_time := lt_time-86400*2
+	before_date :=qu.FormatDateByInt64(&before_time, qu.DATEFORMAT)
+	//企业数据
+	before_qy_data :=save_mgo.FindOne(save_other_name, map[string]interface{}{
+		"name":"企业",
+		"date":before_date,
+	})
+	if len(before_qy_data)>1 {
+		data[before_date] =qu.IntAll(before_qy_data["num"])
+	}
+	log.Println("企业变更处理完毕...",int(time.Now().Unix())-start,"秒")
+
+	return data
+}
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+

+ 198 - 0
data_monitoring/listen_online/src/sitelisten.go

@@ -0,0 +1,198 @@
+package main
+
+import (
+	"encoding/json"
+	"fmt"
+	"log"
+	qu "qfw/util"
+	"qfw/util/elastic"
+	"time"
+	es_elastic "qfw/common/src/gopkg.in/olivere/elastic.v1"
+)
+
+var uniqueData  map[string]interface{}   //指定站点
+
+func initUniqueSite()  {
+
+	uniqueData = make(map[string]interface{})
+
+	query := map[string]interface{}{}
+	sess := save_mgo.GetMgoConn()
+	defer save_mgo.DestoryMongoConn(sess)
+	it := sess.DB(save_mgo.DbName).C(unique_site_name).Find(&query).Iter()
+	total:=0
+	for tmp := make(map[string]interface{}); it.Next(&tmp); total++ {
+		site:=qu.ObjToString(tmp["site"])
+		uniqueData[site] = 1
+		tmp = make(map[string]interface{})
+	}
+
+	log.Println("is unique_site over",len(uniqueData))
+
+}
+
+func dealWithSTData() map[string]interface{} {
+
+	log.Println("开始统计全量站点数据...")
+	defer qu.Catch()
+
+
+
+	initUniqueSite() //准备独特站点
+
+	if len(uniqueData)<1 {
+		log.Println("独特站点-准备异常")
+		sendErrMailApi("独特站点-线上-准备异常","")
+		return map[string]interface{}{}
+	}
+
+	start := int(time.Now().Unix())
+	now:=time.Now() //当前天
+	lt_time:= time.Date(now.Year(), now.Month(), now.Day(), 0, 0, 0, 0, time.Local).Unix()
+	gte_time := lt_time-86400
+
+	mgodata := toCalculateMgoData(gte_time,lt_time)
+	esdata := toCalculateEsData(fmt.Sprintf("%d",gte_time),fmt.Sprintf("%d",lt_time))
+	mgonum,esnum:= qu.IntAll(mgodata["totalnum"]),qu.IntAll(esdata["totalnum"])
+
+	comeintime:=qu.Int64All(time.Now().Unix())
+	date := qu.FormatDateByInt64(&gte_time, qu.DATEFORMAT)
+	save_data :=  map[string]interface{}{
+		"comeintime":comeintime,
+		"date":date,
+		"name":"全量主要站点",
+		"mgonum":mgonum,
+		"esnum":esnum,
+		"mgodata":mgodata["detail"],
+		"esdata":esdata["detail"],
+	}
+	save_mgo.Save(save_site_name, save_data)
+
+	log.Println("站点-定时处理完毕...","用时:",int(time.Now().Unix())-start,"秒")
+
+	return save_data
+
+}
+
+
+
+
+
+//es数据统计
+func toCalculateEsData(gte_time string,lt_time string) map[string]interface{} {
+
+	if gte_time == "" || lt_time == "" {
+		return map[string]interface{}{
+			"totalnum" : 0,
+			"detail": map[string]interface{}{},
+		}
+	}
+
+	dict:= make(map[string]interface{},0)
+	total :=0
+
+	elastic.InitElasticSize("http://172.17.145.170:9800", 10,)
+	//elastic.InitElasticSize("http://127.0.0.1:12003", 10,)
+	esclient := elastic.GetEsConn()
+	defer elastic.DestoryEsConn(esclient)
+	if esclient == nil {
+		log.Println("连接池异常")
+	}
+	query :=es_elastic.NewRangeQuery("comeintime").Gte(gte_time).Lt(lt_time)
+	cursor, err := esclient.Scan(es_index_st).Query(es_elastic.NewBoolQuery().Must(query)).
+		Size(200).Do()
+	if err != nil {
+		log.Println("cursor",err)
+	}
+	if cursor.Results == nil {
+		log.Println("results != nil; got nil")
+	}
+	if cursor.Results.Hits == nil {
+		log.Println("expected results.Hits != nil; got nil")
+	}
+	log.Println("es total :",cursor.TotalHits(),"处理分析中......")
+	for {
+		searchResult, err := cursor.Next()
+		if err != nil {
+			if err.Error() == "EOS" {
+				break
+			}else {
+				log.Println("cursor searchResult",err)
+			}
+		}
+		for _, hit := range searchResult.Hits.Hits {
+			tmp := make(map[string]interface{})
+			err := json.Unmarshal(*hit.Source, &tmp)
+			if err != nil {
+				log.Println("json Unmarshal error")
+				continue
+			}
+
+			site := qu.ObjToString(tmp["site"])	//统计站点
+			if uniqueData[site]!=nil { //统计有效站点
+				total++
+				if dict[site] == nil {
+					dict[site] = 1
+				}else {
+					num := qu.IntAll(dict[site])+1
+					dict[site] = num
+				}
+			}
+		}
+	}
+
+
+	return map[string]interface{}{
+		"totalnum" : total,
+		"detail": dict,
+	}
+}
+
+
+
+
+//mongo数据统计
+func toCalculateMgoData(gte_time int64,lt_time int64) map[string]interface{} {
+
+	if gte_time == 0 || lt_time == 0 {
+		return map[string]interface{}{
+			"totalnum" : 0,
+			"detail": map[string]interface{}{},
+		}
+	}
+
+	query := map[string]interface{}{
+		"comeintime": map[string]interface{}{
+			"$gte":  gte_time,
+			"$lt": lt_time,
+		},
+	}
+
+	sess := st_mgo.GetMgoConn()
+	defer st_mgo.DestoryMongoConn(sess)
+
+	dict:= make(map[string]interface{},0)
+	//细节才需要遍历
+	it := sess.DB(st_mgo.DbName).C(st_c_name).Find(&query).Select(map[string]interface{}{
+		"site":1,
+	}).Iter()
+	total:=0
+	for tmp := make(map[string]interface{}); it.Next(&tmp);  {
+		//统计站点
+		site := qu.ObjToString(tmp["site"])
+		if uniqueData[site]!=nil { //统计有效站点
+			total++
+			if dict[site] == nil {
+				dict[site] = 1
+			}else {
+				num := qu.IntAll(dict[site])+1
+				dict[site] = num
+			}
+		}
+		tmp = make(map[string]interface{})
+	}
+	return map[string]interface{}{
+		"totalnum" : total,
+		"detail": dict,
+	}
+}

+ 40 - 0
data_monitoring/listen_task/src/config.json

@@ -0,0 +1,40 @@
+{
+  "save_mgodb": {
+    "addr": "192.168.3.207:27092",
+    "db": "zhengkun",
+    "coll": "monitor_other",
+    "pool": 5
+  },
+  "qy_mgodb": {
+    "addr": "192.168.3.207:27092",
+    "db": "zhengkun",
+    "coll": "baidu_enterprise_test",
+    "pool": 5
+  },
+  "jp_mgodb": {
+    "addr": "baibai.ink:28082",
+    "db": "spider_data",
+    "coll": "data_bak",
+    "pool": 5
+  },
+  "st_mgodb": {
+    "addr": "192.168.3.207:27092",
+    "db": "zhengkun",
+    "coll": "result_20210109",
+    "pool": 5
+  },
+  "es_index_st": "bidding",
+  "es_type_st": "bidding",
+  "save_other_name": "monitor_other",
+  "save_site_name" : "monitor_site",
+  "smtpMail": {
+    "from": "zhengkun@topnet.net.cn",
+    "to": "zhengkun@topnet.net.cn",
+    "cc": "zhengkun@topnet.net.cn",
+    "smtpHost": "smtp.qq.com",
+    "smtpPort": "465",
+    "user":     "920032221@qq.com",
+    "pwd":      "xomkphsjsamybdbj"
+  },
+  "xlsx_name" : "统计.xlsx"
+}

+ 48 - 0
data_monitoring/listen_task/src/dataTaskJP.go

@@ -0,0 +1,48 @@
+package main
+
+import (
+	qu "qfw/util"
+	"time"
+)
+
+
+func dealWithJPData()(map[string]interface{}) {
+
+	defer qu.Catch()
+	now:=time.Now() //当前天
+	lt_time:= time.Date(now.Year(), now.Month(), now.Day(), 0, 0, 0, 0, time.Local).Unix()
+	gte_time := lt_time-86400
+
+	q := map[string]interface{}{
+		"comeintime": map[string]interface{}{
+			"$gte":  gte_time,
+			"$lt": lt_time,
+		},
+	}
+	sess := jp_mgo.GetMgoConn()
+	defer jp_mgo.DestoryMongoConn(sess)
+	//细节才需要遍历
+	it := sess.DB(jp_mgo.DbName).C(jp_c_name).Find(&q).Select(map[string]interface{}{
+		"site":1,
+	}).Iter()
+	total,dict:=0,make(map[string]interface{},0)
+	for tmp := make(map[string]interface{}); it.Next(&tmp); total++ {
+		site := qu.ObjToString(tmp["site"])
+		if dict[site] == nil {
+			dict[site] = 1
+		}else {
+			num := qu.IntAll(dict[site])+1
+			dict[site] = num
+		}
+		tmp = make(map[string]interface{})
+	}
+
+
+
+	return map[string]interface{}{
+		"num":total,
+		"data":dict,
+		"date":qu.FormatDateByInt64(&gte_time, qu.DATEFORMAT),
+	}
+}
+

+ 58 - 0
data_monitoring/listen_task/src/dataTaskQY.go

@@ -0,0 +1,58 @@
+package main
+
+import (
+	"fmt"
+	qu "qfw/util"
+	"time"
+)
+
+
+func dealWithQYData()(string,string)  {
+
+
+	defer qu.Catch()
+
+	now:=time.Now() //当前天
+	lt_time:= time.Date(now.Year(), now.Month(), now.Day(), 0, 0, 0, 0, time.Local).Unix()
+	gte_time := lt_time-86400
+
+	q := map[string]interface{}{
+		"down_time": map[string]interface{}{
+			"$gte":  gte_time,
+			"$lt": lt_time,
+		},
+	}
+
+	sess := qy_mgo.GetMgoConn()
+	defer qy_mgo.DestoryMongoConn(sess)
+
+	//细节才需要遍历
+	it := sess.DB(qy_mgo.DbName).C(qy_c_name).Find(&q).Select(map[string]interface{}{
+		"site":1,
+	}).Iter()
+	total:=0
+	for tmp := make(map[string]interface{}); it.Next(&tmp); total++ {
+		tmp = make(map[string]interface{})
+	}
+	return qu.FormatDateByInt64(&gte_time, qu.DATEFORMAT),fmt.Sprintf("%d",total)
+}
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+

+ 166 - 0
data_monitoring/listen_task/src/dataTaskST.go

@@ -0,0 +1,166 @@
+package main
+
+import (
+	"encoding/json"
+	"fmt"
+	"log"
+	qu "qfw/util"
+	"qfw/util/elastic"
+	"time"
+	es_elastic "qfw/common/src/gopkg.in/olivere/elastic.v1"
+)
+
+
+func dealWithSTData()  {
+
+	log.Println("开始统计全量站点数据...")
+	defer qu.Catch()
+
+	start := int(time.Now().Unix())
+	now:=time.Now() //当前天
+	lt_time:= time.Date(now.Year(), now.Month(), now.Day(), 0, 0, 0, 0, time.Local).Unix()
+	gte_time := lt_time-86400
+
+	mgodata := toCalculateMgoData(gte_time,lt_time)
+	esdata := toCalculateEsData(fmt.Sprintf("%d",gte_time),fmt.Sprintf("%d",lt_time))
+	mgonum,esnum:= qu.IntAll(mgodata["totalnum"]),qu.IntAll(esdata["totalnum"])
+
+	comeintime:=qu.Int64All(time.Now().Unix())
+	date := qu.FormatDateByInt64(&gte_time, qu.DATEFORMAT)
+	save_mgo.Save("monitor_site", map[string]interface{}{
+		"comeintime":comeintime,
+		"date":date,
+		"name":"全量站点",
+		"mgonum":mgonum,
+		"esnum":esnum,
+		"mgodata":mgodata["detail"],
+		"esdata":esdata["detail"],
+	})
+
+	log.Println("站点-定时处理完毕...","用时:",int(time.Now().Unix())-start,"秒")
+}
+
+
+
+
+
+
+
+
+
+
+
+
+//es数据统计
+func toCalculateEsData(gte_time string,lt_time string) map[string]interface{} {
+
+	if gte_time == "" || lt_time == "" {
+		return map[string]interface{}{
+			"totalnum" : 0,
+			"detail": map[string]interface{}{},
+		}
+	}
+
+	dict:= make(map[string]interface{},0)
+	total :=0
+
+	elastic.InitElasticSize("http://172.17.145.170:9800", 10,)
+	//elastic.InitElasticSize("http://127.0.0.1:12003", 10,)
+	esclient := elastic.GetEsConn()
+	defer elastic.DestoryEsConn(esclient)
+	if esclient == nil {
+		log.Println("连接池异常")
+	}
+	query :=es_elastic.NewRangeQuery("comeintime").Gte(gte_time).Lt(lt_time)
+	cursor, err := esclient.Scan(es_index_st).Query(es_elastic.NewBoolQuery().Must(query)).
+		Size(200).Do()
+	if err != nil {
+		log.Println("cursor",err)
+	}
+	if cursor.Results == nil {
+		log.Println("results != nil; got nil")
+	}
+	if cursor.Results.Hits == nil {
+		log.Println("expected results.Hits != nil; got nil")
+	}
+	//log.Println("es total :",cursor.TotalHits(),"处理分析中......")
+	for {
+		searchResult, err := cursor.Next()
+		if err != nil {
+			if err.Error() == "EOS" {
+				break
+			}else {
+				log.Println("cursor searchResult",err)
+			}
+		}
+		for _, hit := range searchResult.Hits.Hits {
+			tmp := make(map[string]interface{})
+			err := json.Unmarshal(*hit.Source, &tmp)
+			if err != nil {
+				log.Println("json Unmarshal error")
+				continue
+			}
+			total++
+			site := qu.ObjToString(tmp["site"])	//统计站点
+			if dict[site] == nil {
+				dict[site] = 1
+			}else {
+				num := qu.IntAll(dict[site])+1
+				dict[site] = num
+			}
+		}
+	}
+
+
+	return map[string]interface{}{
+		"totalnum" : total,
+		"detail": dict,
+	}
+}
+
+
+
+
+//mongo数据统计
+func toCalculateMgoData(gte_time int64,lt_time int64) map[string]interface{} {
+
+	if gte_time == 0 || lt_time == 0 {
+		return map[string]interface{}{
+			"totalnum" : 0,
+			"detail": map[string]interface{}{},
+		}
+	}
+
+	query := map[string]interface{}{
+		"comeintime": map[string]interface{}{
+			"$gte":  gte_time,
+			"$lt": lt_time,
+		},
+	}
+
+	sess := st_mgo.GetMgoConn()
+	defer st_mgo.DestoryMongoConn(sess)
+
+	dict:= make(map[string]interface{},0)
+	//细节才需要遍历
+	it := sess.DB(st_mgo.DbName).C(st_c_name).Find(&query).Select(map[string]interface{}{
+		"site":1,
+	}).Iter()
+	total:=0
+	for tmp := make(map[string]interface{}); it.Next(&tmp); total++ {
+		//统计站点
+		site := qu.ObjToString(tmp["site"])
+		if dict[site] == nil {
+			dict[site] = 1
+		}else {
+			num := qu.IntAll(dict[site])+1
+			dict[site] = num
+		}
+
+		tmp = make(map[string]interface{})
+	}
+	return map[string]interface{}{
+		"totalnum" : total,
+		"detail": dict,
+	}
+}

+ 215 - 0
data_monitoring/listen_task/src/main.go

@@ -0,0 +1,215 @@
+package main
+
+import (
+	"fmt"
+	"github.com/cron"
+	"github.com/tealeg/xlsx"
+	"log"
+	"os"
+	qu "qfw/util"
+	"time"
+)
+
+
+var (
+	sysconfig    							map[string]interface{} //配置文件
+	save_mgo,qy_mgo,jp_mgo,st_mgo        	*MongodbSim            //mongodb操作对象
+	qy_c_name,jp_c_name,st_c_name			string
+	es_index_st,es_type_st					string
+	save_other_name,save_site_name			string
+	xlsx_name								string
+	infoSiteArr								[]string
+)
+
+func initMgo()  {
+
+	saveconf := sysconfig["save_mgodb"].(map[string]interface{})
+	qy_c_name = qu.ObjToString(saveconf["coll"])
+	save_mgo = &MongodbSim{
+		MongodbAddr: saveconf["addr"].(string),
+		DbName:      saveconf["db"].(string),
+		Size:        qu.IntAllDef(saveconf["pool"], 5),
+	}
+	save_mgo.InitPool()
+
+	qconf := sysconfig["qy_mgodb"].(map[string]interface{})
+	qy_c_name = qu.ObjToString(qconf["coll"])
+	qy_mgo = &MongodbSim{
+		MongodbAddr: qconf["addr"].(string),
+		DbName:      qconf["db"].(string),
+		Size:        qu.IntAllDef(qconf["pool"], 5),
+	}
+	qy_mgo.InitPool()
+
+	jconf := sysconfig["jp_mgodb"].(map[string]interface{})
+	jp_c_name = qu.ObjToString(jconf["coll"])
+	jp_mgo = &MongodbSim{
+		MongodbAddr: jconf["addr"].(string),
+		DbName:      jconf["db"].(string),
+		Size:        qu.IntAllDef(jconf["pool"], 5),
+	}
+	jp_mgo.InitPool()
+
+	sconf := sysconfig["st_mgodb"].(map[string]interface{})
+	st_c_name = qu.ObjToString(sconf["coll"])
+	st_mgo = &MongodbSim{
+		MongodbAddr: sconf["addr"].(string),
+		DbName:      sconf["db"].(string),
+		Size:        qu.IntAllDef(sconf["pool"], 5),
+	}
+	st_mgo.InitPool()
+
+
+	//属性赋值
+	es_index_st = qu.ObjToString(sysconfig["es_index_st"])
+	es_type_st = qu.ObjToString(sysconfig["es_type_st"])
+	save_other_name = qu.ObjToString(sysconfig["save_other_name"])
+	save_site_name = qu.ObjToString(sysconfig["save_site_name"])
+
+
+	xlsx_name = qu.ObjToString(sysconfig["xlsx_name"])
+}
+
+func init() {
+	//加载配置文件
+	qu.ReadConfig(&sysconfig)
+	initMgo()
+}
+
+func main() {
+	go taskTime()
+
+	time.Sleep(99999 * time.Hour)
+
+}
+
+func taskTime()  {
+
+	log.Println("部署定时任务")
+	c := cron.New()
+
+	//站点相关全量-es-mongo
+	c.AddFunc("0 30 8 ? * *", func() { dealWithSTData() })
+
+
+	//企业变更-站点-mongo
+	c.AddFunc("0 0 9 ? * *", func() { dealWithOtherData() })
+
+	c.Start()
+
+}
+
+func dealWithOtherData()  {
+
+	log.Println("开始统计相关数据...")
+
+	//先获取-待统计-动态站点
+	tmp ,tmp_err := save_mgo.Find("z_site_spider", map[string]interface{}{},nil,nil)
+	if tmp_err==nil && tmp!=nil && len(tmp)>0 {
+		infoSiteArr = make([]string,0)
+		for _,v :=range tmp {
+			infoSiteArr = append(infoSiteArr,qu.ObjToString(v["site"]))
+		}
+		log.Println("目标站点:",len(infoSiteArr))
+	}
+
+	start := int(time.Now().Unix())
+	st_data :=dealWithJPData()//站点数据
+	qy_date,qy_num := dealWithQYData()//企业数据
+	comeintime :=qu.Int64All(time.Now().Unix())
+	save_mgo.Save(save_other_name, map[string]interface{}{
+		"name":"企业",
+		"num":qu.IntAll(qy_num),
+		"comeintime":comeintime,
+		"date":qy_date,
+	})
+
+	save_mgo.Save(save_other_name, map[string]interface{}{
+		"name":"站点",
+		"num":qu.IntAll(st_data["num"]),
+		"comeintime":comeintime,
+		"date":qu.ObjToString(st_data["date"]),
+		"data":st_data["data"],
+	})
+
+
+
+	//获取前两天数据
+	qy_arr := make([]map[string]string,0)
+	now:=time.Now() //当前天
+	cur_time:= time.Date(now.Year(), now.Month(), now.Day(), 0, 0, 0, 0, time.Local).Unix()
+	before_time := cur_time-86400*2
+	before_date :=qu.FormatDateByInt64(&before_time, qu.DATEFORMAT)
+	//企业数据
+	before_qy_data :=save_mgo.FindOne(save_other_name, map[string]interface{}{
+		"name":"企业",
+		"date":before_date,
+	})
+	qy_arr = append(qy_arr, map[string]string{
+		"date":qy_date,
+		"num":qy_num,
+	})
+	if before_qy_data!=nil && len(before_qy_data)>2 {
+		qy_arr = append(qy_arr, map[string]string{
+			"date":qu.ObjToString(before_qy_data["date"]),
+			"num":fmt.Sprintf("%d",before_qy_data["num"]),
+		})
+	}
+
+
+	//站点数据
+	before_st_data :=save_mgo.FindOne(save_other_name, map[string]interface{}{
+		"name":"站点",
+		"date":before_date,
+	})
+
+
+	os.Remove("统计.xlsx")	//写excle
+	f :=xlsx.NewFile()
+	sheet, _ := f.AddSheet("统计")
+
+	//企业数据
+	row := sheet.AddRow()
+	row.AddCell().Value = "企业分类/日期"
+	row.AddCell().Value = "数量"
+	for _,tmp := range qy_arr {
+		row = sheet.AddRow()
+		row.AddCell().SetString(tmp["date"])
+		row.AddCell().SetString(tmp["num"])
+	}
+
+
+	//站点相关数据
+	sheet.AddRow()
+	row = sheet.AddRow()
+	row.AddCell().Value = "站点分类/日期"
+	row.AddCell().SetString(qu.ObjToString(st_data["date"]))
+	row.AddCell().SetString(qu.ObjToString(before_st_data["date"]))
+
+
+	data_1 := *qu.ObjToMap(st_data["data"])
+	data_2 := *qu.ObjToMap(before_st_data["data"])
+
+	for _,key := range infoSiteArr {
+		row = sheet.AddRow()
+		row.AddCell().SetString(key)
+		row.AddCell().SetString(fmt.Sprintf("%d",qu.Int64All(data_1[key])))
+		row.AddCell().SetString(fmt.Sprintf("%d",qu.Int64All(data_2[key])))
+	}
+	row = sheet.AddRow()
+	row.AddCell().Value = "总计"
+	row.AddCell().SetString(fmt.Sprintf("%d",qu.Int64All(st_data["num"])))
+	row.AddCell().SetString(fmt.Sprintf("%d",qu.Int64All(before_st_data["num"])))
+
+	err := f.Save(xlsx_name)
+	if err != nil {
+		log.Println("保存xlsx失败:", err)
+	}else {
+		log.Println("保存xlsx成功:", err)
+	}
+
+
+	sendErrMailSmtp("统计-站点-企业","附件")
+
+	log.Println("定时处理完毕...",int(time.Now().Unix())-start,"秒")
+}

+ 40 - 0
data_monitoring/listen_task/src/mark

@@ -0,0 +1,40 @@
+{
+  "save_mgodb": {
+    "addr": "172.17.4.87:27080",
+    "db": "editor",
+    "coll": "monitor_other",
+    "pool": 5
+  },
+  "qy_mgodb": {
+    "addr": "172.17.4.87:27080",
+    "db": "spider",
+    "coll": "baidu_enterprise",
+    "pool": 5
+  },
+  "jp_mgodb": {
+    "addr": "172.17.145.179:28082",
+    "db": "spider_data",
+    "coll": "data_bak",
+    "pool": 5
+  },
+  "st_mgodb": {
+    "addr": "172.17.4.85:27080",
+    "db": "qfw",
+    "coll": "result_20210109",
+    "pool": 5
+  },
+  "es_index_st": "bidding",
+  "es_type_st": "bidding",
+  "save_other_name": "monitor_other",
+  "save_site_name" : "monitor_site",
+  "smtpMail": {
+    "from": "zhengkun@topnet.net.cn",
+    "to": "zhengkun@topnet.net.cn",
+    "cc": "zhengkun@topnet.net.cn",
+    "smtpHost": "smtp.qq.com",
+    "smtpPort": "465",
+    "user":     "920032221@qq.com",
+    "pwd":      "xomkphsjsamybdbj"
+  },
+  "xlsx_name" : "统计.xlsx"
+}

+ 329 - 0
data_monitoring/listen_task/src/mgo.go

@@ -0,0 +1,329 @@
+package main
+
+import (
+	"context"
+	"log"
+	"time"
+
+	"go.mongodb.org/mongo-driver/bson"
+	"go.mongodb.org/mongo-driver/bson/primitive"
+	"go.mongodb.org/mongo-driver/mongo"
+	"go.mongodb.org/mongo-driver/mongo/options"
+)
+
+type MgoSess struct {
+	Db     string
+	Coll   string
+	Query  interface{}
+	Sorts  []string
+	fields interface{}
+	limit  int64
+	skip   int64
+	M      *MongodbSim
+}
+
+type MgoIter struct {
+	Cursor *mongo.Cursor
+}
+
+func (mt *MgoIter) Next(result interface{}) bool {
+	if mt.Cursor != nil {
+		if mt.Cursor.Next(nil) {
+			err := mt.Cursor.Decode(result)
+			if err != nil {
+				log.Println("mgo cur err", err.Error())
+				mt.Cursor.Close(nil)
+				return false
+			}
+			return true
+		} else {
+			mt.Cursor.Close(nil)
+			return false
+		}
+	} else {
+		return false
+	}
+
+}
+
+func (ms *MgoSess) DB(name string) *MgoSess {
+	ms.Db = name
+	return ms
+}
+
+func (ms *MgoSess) C(name string) *MgoSess {
+	ms.Coll = name
+	return ms
+}
+
+func (ms *MgoSess) Find(q interface{}) *MgoSess {
+	ms.Query = q
+	return ms
+}
+
+func (ms *MgoSess) Select(fields interface{}) *MgoSess {
+	ms.fields = fields
+	return ms
+}
+
+func (ms *MgoSess) Limit(limit int64) *MgoSess {
+	ms.limit = limit
+	return ms
+}
+func (ms *MgoSess) Skip(skip int64) *MgoSess {
+	ms.skip = skip
+	return ms
+}
+
+func (ms *MgoSess) Sort(sorts ...string) *MgoSess {
+	ms.Sorts = sorts
+	return ms
+}
+
+func (ms *MgoSess) Iter() *MgoIter {
+	it := &MgoIter{}
+	find := options.Find()
+	if ms.skip > 0 {
+		find.SetSkip(ms.skip)
+	}
+	if ms.limit > 0 {
+		find.SetLimit(ms.limit)
+	}
+	find.SetBatchSize(100)
+	if len(ms.Sorts) > 0 {
+		sort := bson.M{}
+		for _, k := range ms.Sorts {
+			switch k[:1] {
+			case "-":
+				sort[k[1:]] = -1
+			case "+":
+				sort[k[1:]] = 1
+			default:
+				sort[k] = 1
+			}
+		}
+		find.SetSort(sort)
+	}
+	if ms.fields != nil {
+		find.SetProjection(ms.fields)
+	}
+	cur, err := ms.M.C.Database(ms.Db).Collection(ms.Coll).Find(ms.M.Ctx, ms.Query, find)
+	if err != nil {
+		log.Println("mgo find err", err.Error())
+	} else {
+		it.Cursor = cur
+	}
+	return it
+}
+
+type MongodbSim struct {
+	MongodbAddr string
+	Size        int
+	//	MinSize     int
+	DbName   string
+	C        *mongo.Client
+	Ctx      context.Context
+	ShortCtx context.Context
+	pool     chan bool
+	UserName string
+	Password string
+}
+
+func (m *MongodbSim) GetMgoConn() *MgoSess {
+	//m.Open()
+	ms := &MgoSess{}
+	ms.M = m
+	return ms
+}
+
+func (m *MongodbSim) DestoryMongoConn(ms *MgoSess) {
+	//m.Close()
+	ms.M = nil
+	ms = nil
+}
+
+func (m *MongodbSim) InitPool() {
+	opts := options.Client()
+	opts.SetConnectTimeout(3 * time.Second)
+	opts.ApplyURI("mongodb://" + m.MongodbAddr)
+	opts.SetMaxPoolSize(uint64(m.Size))
+	m.pool = make(chan bool, m.Size)
+
+	if m.UserName !="" && m.Password !="" {
+		cre := options.Credential{
+			Username:m.UserName,
+			Password:m.Password,
+		}
+		opts.SetAuth(cre)
+	}
+
+
+
+	opts.SetMaxConnIdleTime(2 * time.Hour)
+	m.Ctx, _ = context.WithTimeout(context.Background(), 99999*time.Hour)
+	m.ShortCtx, _ = context.WithTimeout(context.Background(), 1*time.Minute)
+	client, err := mongo.Connect(m.ShortCtx, opts)
+	if err != nil {
+		log.Println("mgo init error:", err.Error())
+	} else {
+		m.C = client
+		log.Println("init success")
+	}
+}
+
+func (m *MongodbSim) Open() {
+	m.pool <- true
+}
+func (m *MongodbSim) Close() {
+	<-m.pool
+}
+
+//批量插入
+func (m *MongodbSim) UpSertBulk(c string, doc ...[]map[string]interface{}) (map[int64]interface{}, bool) {
+	m.Open()
+	defer m.Close()
+	coll := m.C.Database(m.DbName).Collection(c)
+	var writes []mongo.WriteModel
+	for _, d := range doc {
+		write := mongo.NewUpdateOneModel()
+		write.SetFilter(d[0])
+		write.SetUpdate(d[1])
+		write.SetUpsert(true)
+		writes = append(writes, write)
+	}
+	r, e := coll.BulkWrite(m.Ctx, writes)
+	if e != nil {
+		log.Println("mgo upsert error:", e.Error())
+		return nil, false
+	}
+	//	else {
+	//		if r.UpsertedCount != int64(len(doc)) {
+	//			log.Println("mgo upsert uncomplete:uc/dc", r.UpsertedCount, len(doc))
+	//		}
+	//		return true
+	//	}
+	return r.UpsertedIDs, true
+}
+
+//批量插入
+func (m *MongodbSim) SaveBulk(c string, doc ...map[string]interface{}) bool {
+	m.Open()
+	defer m.Close()
+	coll := m.C.Database(m.DbName).Collection(c)
+	var writes []mongo.WriteModel
+	for _, d := range doc {
+		write := mongo.NewInsertOneModel()
+		write.SetDocument(d)
+		writes = append(writes, write)
+	}
+	_, e := coll.BulkWrite(m.Ctx, writes)
+	if e != nil {
+		log.Println("mgo savebulk error:", e.Error())
+		return false
+	}
+	return true
+}
+
+//保存
+func (m *MongodbSim) Save(c string, doc map[string]interface{}) interface{} {
+	m.Open()
+	defer m.Close()
+	coll := m.C.Database(m.DbName).Collection(c)
+	r, err := coll.InsertOne(m.Ctx, doc)
+	if err != nil {
+		return nil
+	}
+	return r.InsertedID
+}
+
+//更新by Id
+func (m *MongodbSim) UpdateById(c, id string, doc map[string]interface{}) bool {
+	m.Open()
+	defer m.Close()
+	coll := m.C.Database(m.DbName).Collection(c)
+	_, err := coll.UpdateOne(m.Ctx, map[string]interface{}{"_id": StringTOBsonId(id)}, doc)
+	if err != nil {
+		return false
+	}
+	return true
+}
+
+//删除by id
+func (m *MongodbSim) DeleteById(c, id string) int64 {
+	m.Open()
+	defer m.Close()
+	coll := m.C.Database(m.DbName).Collection(c)
+	r, err := coll.DeleteOne(m.Ctx, map[string]interface{}{"_id": StringTOBsonId(id)})
+	if err != nil {
+		return 0
+	}
+	return r.DeletedCount
+}
+
+//通过条件删除
+func (m *MongodbSim) Delete(c string, query map[string]interface{}) int64 {
+	m.Open()
+	defer m.Close()
+	coll := m.C.Database(m.DbName).Collection(c)
+	r, err := coll.DeleteMany(m.Ctx, query)
+	if err != nil {
+		return 0
+	}
+	return r.DeletedCount
+}
+
+//findbyid
+func (m *MongodbSim) FindById(c, id string) map[string]interface{} {
+	m.Open()
+	defer m.Close()
+	coll := m.C.Database(m.DbName).Collection(c)
+	r := coll.FindOne(m.Ctx, map[string]interface{}{"_id": StringTOBsonId(id)})
+	v := map[string]interface{}{}
+	r.Decode(&v)
+	return v
+}
+
+//findone
+func (m *MongodbSim) FindOne(c string, query map[string]interface{}) map[string]interface{} {
+	m.Open()
+	defer m.Close()
+	coll := m.C.Database(m.DbName).Collection(c)
+	r := coll.FindOne(m.Ctx, query)
+	v := map[string]interface{}{}
+	r.Decode(&v)
+	return v
+}
+
+//find
+func (m *MongodbSim) Find(c string, query map[string]interface{}, sort, fields interface{}) ([]map[string]interface{}, error) {
+	m.Open()
+	defer m.Close()
+	coll := m.C.Database(m.DbName).Collection(c)
+	op := options.Find()
+	r, err := coll.Find(m.Ctx, query, op.SetSort(sort), op.SetProjection(fields))
+	if err != nil {
+		log.Fatal(err)
+		return nil, err
+	}
+
+	var results []map[string]interface{}
+	if err = r.All(m.Ctx, &results); err != nil {
+		log.Fatal(err)
+		return nil, err
+	}
+	return results, nil
+}
+
+//创建_id
+func NewObjectId() primitive.ObjectID {
+	return primitive.NewObjectID()
+}
+
+func StringTOBsonId(id string) primitive.ObjectID {
+	objectId, _ := primitive.ObjectIDFromHex(id)
+	return objectId
+}
+
+func BsonTOStringId(id interface{}) string {
+	return id.(primitive.ObjectID).Hex()
+}

+ 43 - 0
data_monitoring/listen_task/src/sendmail.go

@@ -0,0 +1,43 @@
+package main
+
+import (
+	"fmt"
+	"io/ioutil"
+	"os"
+	qu "qfw/util"
+	"qfw/util/mail"
+)
+
+var from,to,cc, smtpHost,user,pwd string
+var smtpPort int
+
+
+func sendErrMailSmtp(title,body string) {
+
+
+	smtpMail, _ := sysconfig["smtpMail"].(map[string]interface{})
+
+	if smtpMail != nil {
+		from, _ = smtpMail["from"].(string)
+		to, _ = smtpMail["to"].(string)
+		cc, _ = smtpMail["cc"].(string)
+		smtpHost, _ = smtpMail["smtpHost"].(string)
+		smtpPort= qu.IntAll(smtpMail["smtpPort"])
+		user, _ = smtpMail["user"].(string)
+		pwd, _ = smtpMail["pwd"].(string)
+	}
+	f, _ := os.Open(xlsx_name)
+	b, err := ioutil.ReadAll(f)
+	if err != nil {
+		fmt.Println("err:",err)
+		return
+	}
+
+	ok := mail.GSendMail_B(user, from, cc, from, title, body, f.Name(), b, &mail.GmailAuth{
+		SmtpHost: smtpHost,
+		SmtpPort: smtpPort,
+		User:     user,
+		Pwd:      pwd,
+	})
+	fmt.Println(ok)
+}

+ 9 - 0
data_monitoring/vps_client/src/config.json

@@ -0,0 +1,9 @@
+{
+  "vpsID": "专用-常州",
+  "processArr": [
+    "d1.exe",
+    "d2.exe",
+    "d3.exe"
+  ],
+  "during":"10"
+}

+ 140 - 0
data_monitoring/vps_client/src/main.go

@@ -0,0 +1,140 @@
+package main
+
+import (
+	"fmt"
+	"github.com/cron"
+	"log"
+	"net/http"
+	"net/url"
+	"os"
+	"os/exec"
+	qu "qfw/util"
+	"runtime"
+	"strconv"
+	"strings"
+	"time"
+)
+
+var (
+	sysconfig			map[string]interface{} //配置文件
+	vpsID,during		string			//机器唯一标识
+	processArr 			[]string		//机器相关下载器
+
+)
+
+func init()  {
+	qu.ReadConfig(&sysconfig)
+	vpsID = qu.ObjToString(sysconfig["vpsID"])
+	during = qu.ObjToString(sysconfig["during"])
+	processArr = qu.ObjArrToStringArr(sysconfig["processArr"].([]interface{}))
+}
+
+
+func main() {
+
+	if vpsID == "" || len(processArr) < 1 {
+		log.Println("配置文件异常,请检查......")
+		os.Exit(1)
+	}
+
+	//定时器
+	c := cron.New()
+	spec := fmt.Sprintf("0 */%s * * * ?",during)	//分
+	//spec =fmt.Sprintf("*/%s * * * * ?",during)		//秒
+	c.AddFunc(spec, func() { task() })
+	c.Start()
+	time.Sleep(99999 * time.Hour)
+}
+
+func task()  {
+	log.Println("执行...检测...")
+	//先检测下载器
+	process := "0" //正常 - windows模式
+	for _,v:=range processArr {
+		if runtime.GOOS == "windows" {
+			b,_,_ := isProcessExist(v)
+			if !b {
+				process = "1"
+				break
+			}
+		}else { //linux测试使用
+			b,_:=checkProRunning(v)
+			if !b {
+				process = "1"
+				break
+			}
+		}
+	}
+	//log.Println("当前下载器:",process)
+	//u, _ := url.Parse("http://127.0.0.1:7811") //本地测试
+	u, _ := url.Parse("http://monitor.spdata.jianyu360.com") //线上
+	q := u.Query()
+	q.Set("id", vpsID)
+	q.Set("process", process)
+	u.RawQuery = q.Encode()
+
+	//log.Println(vpsID,process)
+
+	_, err := http.Get(u.String());
+	if err != nil {
+		log.Println("异常",err)
+	}
+
+}
+
+
+
+
+
+
+/****************分割线******************/
+/****************分割线******************/
+/****************分割线******************/
+
+
+
+//根据进程名判断进程是否运行
+func checkProRunning(serverName string) (bool, error) {
+	cmd := `ps ux | awk '/` + serverName + `/ && !/awk/ {print $2}'`
+	pid, err := runInLinux(cmd)
+	if err != nil {
+		return false, err
+	}
+	return pid != "", nil
+}
+//根据进程名称获取进程ID
+func getPid(serverName string) (string, error) {
+	cmd := `ps ux | awk '/` + serverName + `/ && !/awk/ {print $2}'`
+	pid, err := runInLinux(cmd)
+	return pid , err
+}
+//
+func runInLinux(cmd string) (string, error) {
+	result, err := exec.Command("/bin/sh", "-c", cmd).Output()
+	if err != nil {
+		return "", err
+	}
+	return strings.TrimSpace(string(result)), err
+}
+
+func isProcessExist(appName string) (bool, string, int) {
+	appary := make(map[string]int)
+	cmd := exec.Command("cmd", "/C", "tasklist")
+	output, _ := cmd.Output()
+	//fmt.Printf("fields: %v\n", output)
+	n := strings.Index(string(output), "System")
+	if n == -1 {
+		//log.Println("no find")
+		//os.Exit(1)
+	}
+	data := string(output)[n:]
+	fields := strings.Fields(data)
+	for k, v := range fields {
+		if v == appName {
+			appary[appName], _ = strconv.Atoi(fields[k+1])
+
+			return true, appName, appary[appName]
+		}
+	}
+	return false, appName, -1
+}

+ 26 - 0
data_monitoring/vps_server/src/config.json

@@ -0,0 +1,26 @@
+{
+  "port": "7811",
+  "save_mgodb": {
+    "addr": "192.168.3.207:27092",
+    "db": "zhengkun",
+    "coll": "monitor_other",
+    "pool": 5
+  },
+  "vpsIDs" : [
+    "专用-常州"
+  ],
+  "during": 10,
+  "isErr" : 3,
+  "smtpMail": {
+    "from": "zhengkun@topnet.net.cn",
+    "to": "zhengkun@topnet.net.cn",
+    "smtpHost": "smtp.qq.com",
+    "smtpPort": "465",
+    "user":     "920032221@qq.com",
+    "pwd":      "xomkphsjsamybdbj"
+  },
+  "jkmail": {
+    "to": "zhaoyujian@topnet.net.cn",
+    "api": "http://172.17.145.179:19281/_send/_mail"
+  }
+}

+ 202 - 0
data_monitoring/vps_server/src/main.go

@@ -0,0 +1,202 @@
+package main
+
+import (
+	"fmt"
+	"github.com/cron"
+	"log"
+	"net/http"
+	qu "qfw/util"
+	"strings"
+	"sync"
+	"time"
+)
+var (
+	sysconfig			map[string]interface{} //配置文件
+	port				string
+	save_mgo        	*MongodbSim
+	idsArr				[]string
+	dataTmp				map[string]map[string]interface{}
+	during,isErr		int64
+	test				map[string]interface{}
+	updatelock 			sync.Mutex
+	save_coll_name		string
+)
+func init()  {
+	//加载配置文件
+	log.Println("加载...")
+	qu.ReadConfig(&sysconfig)
+	port = sysconfig["port"].(string)
+	arr := sysconfig["vpsIDs"].([]interface{})
+	idsArr = qu.ObjArrToStringArr(arr)
+	dataTmp = make(map[string]map[string]interface{},0)
+	for _,v := range idsArr{
+		id := qu.ObjToString(v)
+		dataTmp[id] = map[string]interface{}{
+			"isHeart":0,
+			"isErrNum":0,
+			"isProcess" : 0,
+			"isVpsMail":0,
+			"isProMail":0,
+		}
+	}
+
+	during = qu.Int64All(sysconfig["during"])
+	isErr = qu.Int64All(sysconfig["isErr"])
+
+	saveconf := sysconfig["save_mgodb"].(map[string]interface{})
+	save_coll_name = qu.ObjToString(saveconf["coll"])
+	save_mgo = &MongodbSim{
+		MongodbAddr: saveconf["addr"].(string),
+		DbName:      saveconf["db"].(string),
+		Size:        qu.IntAllDef(saveconf["pool"], 5),
+	}
+	save_mgo.InitPool()
+
+
+	log.Println("准备完毕...")
+}
+
+
+
+func main() {
+
+	//http://monitor.spdata.jianyu360.com/,程序端口7811
+	addr := ":"+port
+	http.HandleFunc("/", handler)
+	go http.ListenAndServe(addr, nil)
+
+	//每隔1分钟执行一次:0 */1 * * * ?   每隔5秒执行一次:*/5 * * * * ?
+
+	spec :=fmt.Sprintf("30 */%d * * * ?",during)
+	//spec =fmt.Sprintf("*/%d * * * * ?",during)
+	c := cron.New()
+	c.AddFunc(spec, func() { taskFinishing()})
+	c.Start()
+	time.Sleep(99999 * time.Hour)
+}
+
+func handler(w http.ResponseWriter, r *http.Request) {
+	updatelock.Lock()
+	r.ParseForm() //解析参数,默认是不会解析的
+	if r.Method == "GET" {
+		vpsid ,process,isProMail:= "",int64(0),int64(0)
+		for k, v := range r.Form {
+			if k=="id" {
+				vpsid = strings.Join(v, "")
+				isProMail = qu.Int64All(dataTmp[vpsid]["isProMail"])
+			}else if k=="process" {
+				process = qu.Int64All(strings.Join(v, ""))
+				if process==0 {
+					isProMail = 0
+				}
+
+			}else {
+
+			}
+		}
+		if vpsid!="" { //改变-旧状态
+			dataTmp[vpsid] = map[string]interface{}{
+				"isHeart":1,
+				"isErrNum":0,
+				"isVpsMail":0,   //收到心跳-vps邮件重置为0,可以发
+				"isProcess":process,
+				"isProMail":isProMail,
+			}
+		}
+
+		//log.Println("接收Get请求:",dataTmp[vpsid])
+
+	} else if r.Method == "POST" {
+
+	} else {
+
+	}
+
+	updatelock.Unlock()
+}
+
+//不断监听处理
+func taskFinishing()  {
+	//加锁
+	updatelock.Lock()
+	log.Println("...处理一次...")
+
+	isVpsMailContent,isProMailContent:= "",""
+	for _ , vpsid := range idsArr {
+		//此标识-是否正常
+		//log.Println("原:",dataTmp[vpsid])
+		isHeart,isProcess:= qu.Int64All(dataTmp[vpsid]["isHeart"]),qu.Int64All(dataTmp[vpsid]["isProcess"])
+		isErrNum := int64(0)
+		isVpsMail,isProMail := qu.Int64All(dataTmp[vpsid]["isVpsMail"]),qu.Int64All(dataTmp[vpsid]["isProMail"])
+		if isVpsMail == 1 { //送过邮件了
+			//log.Println("发过vps邮件","心跳:",isHeart,"次数:",isErrNum,"下载器:",isProcess,"vps邮件:",isVpsMail,"pro邮件:",isProMail)
+			continue
+		}
+		if isHeart == 0 { //未接收心跳反应,错误+1
+			isErrNum = qu.Int64All(dataTmp[vpsid]["isErrNum"])
+			isErrNum ++
+		}
+		if isErrNum > isErr { //错误超过一定次数,发邮件vps异常
+			isErrNum = 0
+			if isVpsMailContent == ""{
+				isVpsMailContent = vpsid
+			}else {
+				isVpsMailContent = isVpsMailContent+","+vpsid
+			}
+			isVpsMail = 1
+		}
+
+		if isProcess == 1  && isProMail==0 {//下载器异常-未发送过下载器异常情况
+			if isProMailContent == ""{
+				isProMailContent = vpsid
+			}else {
+				isProMailContent = isProMailContent+","+vpsid
+			}
+			isProMail = 1
+			isProcess = 0
+		}
+
+		//log.Println("处理后:","心跳:",0,"次数:",isErrNum,"下载器:",isProcess,"vps邮件:",isVpsMail,"pro邮件:",isProMail)
+
+
+		dataTmp[vpsid] = map[string]interface{}{
+			"isHeart":0,
+			"isErrNum":isErrNum,
+			"isProcess":isProcess,
+			"isVpsMail":isVpsMail,
+			"isProMail" : isProMail,
+		}
+
+	}
+
+	//log.Println("处理后",isProMailContent)
+
+	if isVpsMailContent!=""{
+		log.Println("发邮件:vps异常...",isVpsMailContent)
+		comeintime :=qu.Int64All(time.Now().Unix())//日志记录
+		save_mgo.Save(save_coll_name, map[string]interface{}{
+			"name":"vps",
+			"comeintime":comeintime,
+			"date":qu.FormatDateByInt64(&comeintime, qu.DATEFORMAT),
+			"detail" : isVpsMailContent,
+		})
+
+		sendErrMailApi("vps",isVpsMailContent)
+	}else {
+		if isProMailContent !="" {
+			log.Println("发邮件:下载器异常...",isProMailContent)
+			comeintime :=qu.Int64All(time.Now().Unix())//日志记录
+			save_mgo.Save(save_coll_name, map[string]interface{}{
+				"name":"下载器",
+				"comeintime":comeintime,
+				"date":qu.FormatDateByInt64(&comeintime, qu.DATEFORMAT),
+				"detail" : isProMailContent,
+			})
+
+			sendErrMailApi("下载器异常",isProMailContent)
+		}
+	}
+
+	updatelock.Unlock()
+
+}

+ 49 - 0
data_monitoring/vps_server/src/mark

@@ -0,0 +1,49 @@
+"vpsIDs" : [
+    "专用-常州",
+    "专用-杭州",
+    "专用-合肥",
+    "专用-莱芜",
+    "专用-南通",
+    "专用-秦皇岛",
+    "专用-威海",
+    "专用-驻马店",
+    "专用-池州",
+    "专用-菏泽",
+    "专用-淮南",
+    "专用-嘉兴",
+    "专用-宣城",
+    "数据-桂林",
+    "数据-黄山",
+    "数据-荆州",
+    "数据-聊城",
+    "数据-洛阳",
+    "数据-宁德",
+    "数据-衢州",
+    "数据-三亚",
+    "数据-厦门",
+    "数据-汕头",
+    "数据-信阳",
+    "数据-宿迁",
+    "数据-盐城",
+    "数据-中山",
+    "数据-镇江",
+    "数据-珠海",
+    "数据-成都",
+    "数据-莆田",
+    "数据-湖州",
+    "数据-苏州",
+    "数据-台州",
+    "数据-舟山",
+    "附件-亳州",
+    "附件-葫芦岛",
+    "附件-马鞍山",
+    "附件-濮阳",
+    "附件-绍兴",
+    "附件-石家庄",
+    "附件-云浮",
+    "代理-北京",
+    "代理-杭州",
+    "代理-济南",
+    "代理-开封",
+    "代理-扬州"
+  ],

+ 328 - 0
data_monitoring/vps_server/src/mgo.go

@@ -0,0 +1,328 @@
+package main
+
+import (
+	"context"
+	"log"
+	"time"
+
+	"go.mongodb.org/mongo-driver/bson"
+	"go.mongodb.org/mongo-driver/bson/primitive"
+	"go.mongodb.org/mongo-driver/mongo"
+	"go.mongodb.org/mongo-driver/mongo/options"
+)
+
+type MgoSess struct {
+	Db     string
+	Coll   string
+	Query  interface{}
+	Sorts  []string
+	fields interface{}
+	limit  int64
+	skip   int64
+	M      *MongodbSim
+}
+
+type MgoIter struct {
+	Cursor *mongo.Cursor
+}
+
+func (mt *MgoIter) Next(result interface{}) bool {
+	if mt.Cursor != nil {
+		if mt.Cursor.Next(nil) {
+			err := mt.Cursor.Decode(result)
+			if err != nil {
+				log.Println("mgo cur err", err.Error())
+				mt.Cursor.Close(nil)
+				return false
+			}
+			return true
+		} else {
+			mt.Cursor.Close(nil)
+			return false
+		}
+	} else {
+		return false
+	}
+
+}
+
+func (ms *MgoSess) DB(name string) *MgoSess {
+	ms.Db = name
+	return ms
+}
+
+func (ms *MgoSess) C(name string) *MgoSess {
+	ms.Coll = name
+	return ms
+}
+
+func (ms *MgoSess) Find(q interface{}) *MgoSess {
+	ms.Query = q
+	return ms
+}
+
+func (ms *MgoSess) Select(fields interface{}) *MgoSess {
+	ms.fields = fields
+	return ms
+}
+
+func (ms *MgoSess) Limit(limit int64) *MgoSess {
+	ms.limit = limit
+	return ms
+}
+func (ms *MgoSess) Skip(skip int64) *MgoSess {
+	ms.skip = skip
+	return ms
+}
+
+func (ms *MgoSess) Sort(sorts ...string) *MgoSess {
+	ms.Sorts = sorts
+	return ms
+}
+
+func (ms *MgoSess) Iter() *MgoIter {
+	it := &MgoIter{}
+	find := options.Find()
+	if ms.skip > 0 {
+		find.SetSkip(ms.skip)
+	}
+	if ms.limit > 0 {
+		find.SetLimit(ms.limit)
+	}
+	find.SetBatchSize(100)
+	if len(ms.Sorts) > 0 {
+		sort := bson.M{}
+		for _, k := range ms.Sorts {
+			switch k[:1] {
+			case "-":
+				sort[k[1:]] = -1
+			case "+":
+				sort[k[1:]] = 1
+			default:
+				sort[k] = 1
+			}
+		}
+		find.SetSort(sort)
+	}
+	if ms.fields != nil {
+		find.SetProjection(ms.fields)
+	}
+	cur, err := ms.M.C.Database(ms.Db).Collection(ms.Coll).Find(ms.M.Ctx, ms.Query, find)
+	if err != nil {
+		log.Println("mgo find err", err.Error())
+	} else {
+		it.Cursor = cur
+	}
+	return it
+}
+
+type MongodbSim struct {
+	MongodbAddr string
+	Size        int
+	//	MinSize     int
+	DbName   string
+	C        *mongo.Client
+	Ctx      context.Context
+	ShortCtx context.Context
+	pool     chan bool
+	UserName string
+	Password string
+}
+
+func (m *MongodbSim) GetMgoConn() *MgoSess {
+	//m.Open()
+	ms := &MgoSess{}
+	ms.M = m
+	return ms
+}
+
+func (m *MongodbSim) DestoryMongoConn(ms *MgoSess) {
+	//m.Close()
+	ms.M = nil
+	ms = nil
+}
+
+func (m *MongodbSim) InitPool() {
+	opts := options.Client()
+	opts.SetConnectTimeout(3 * time.Second)
+	opts.ApplyURI("mongodb://" + m.MongodbAddr)
+	opts.SetMaxPoolSize(uint64(m.Size))
+	m.pool = make(chan bool, m.Size)
+
+	if m.UserName !="" && m.Password !="" {
+		cre := options.Credential{
+			Username:m.UserName,
+			Password:m.Password,
+		}
+		opts.SetAuth(cre)
+	}
+
+
+
+	opts.SetMaxConnIdleTime(2 * time.Hour)
+	m.Ctx, _ = context.WithTimeout(context.Background(), 99999*time.Hour)
+	m.ShortCtx, _ = context.WithTimeout(context.Background(), 1*time.Minute)
+	client, err := mongo.Connect(m.ShortCtx, opts)
+	if err != nil {
+		log.Println("mgo init error:", err.Error())
+	} else {
+		m.C = client
+		log.Println("init success")
+	}
+}
+
+func (m *MongodbSim) Open() {
+	m.pool <- true
+}
+func (m *MongodbSim) Close() {
+	<-m.pool
+}
+
+//批量插入
+func (m *MongodbSim) UpSertBulk(c string, doc ...[]map[string]interface{}) (map[int64]interface{}, bool) {
+	m.Open()
+	defer m.Close()
+	coll := m.C.Database(m.DbName).Collection(c)
+	var writes []mongo.WriteModel
+	for _, d := range doc {
+		write := mongo.NewUpdateOneModel()
+		write.SetFilter(d[0])
+		write.SetUpdate(d[1])
+		write.SetUpsert(true)
+		writes = append(writes, write)
+	}
+	r, e := coll.BulkWrite(m.Ctx, writes)
+	if e != nil {
+		log.Println("mgo upsert error:", e.Error())
+		return nil, false
+	}
+	//	else {
+	//		if r.UpsertedCount != int64(len(doc)) {
+	//			log.Println("mgo upsert uncomplete:uc/dc", r.UpsertedCount, len(doc))
+	//		}
+	//		return true
+	//	}
+	return r.UpsertedIDs, true
+}
+
+//批量插入
+func (m *MongodbSim) SaveBulk(c string, doc ...map[string]interface{}) bool {
+	m.Open()
+	defer m.Close()
+	coll := m.C.Database(m.DbName).Collection(c)
+	var writes []mongo.WriteModel
+	for _, d := range doc {
+		write := mongo.NewInsertOneModel()
+		write.SetDocument(d)
+		writes = append(writes, write)
+	}
+	_, e := coll.BulkWrite(m.Ctx, writes)
+	if e != nil {
+		log.Println("mgo savebulk error:", e.Error())
+		return false
+	}
+	return true
+}
+
+//保存
+func (m *MongodbSim) Save(c string, doc map[string]interface{}) interface{} {
+	m.Open()
+	defer m.Close()
+	coll := m.C.Database(m.DbName).Collection(c)
+	r, err := coll.InsertOne(m.Ctx, doc)
+	if err != nil {
+		return nil
+	}
+	return r.InsertedID
+}
+
+//更新by Id
+func (m *MongodbSim) UpdateById(c, id string, doc map[string]interface{}) bool {
+	m.Open()
+	defer m.Close()
+	coll := m.C.Database(m.DbName).Collection(c)
+	_, err := coll.UpdateOne(m.Ctx, map[string]interface{}{"_id": StringTOBsonId(id)}, doc)
+	if err != nil {
+		return false
+	}
+	return true
+}
+
+//删除by id
+func (m *MongodbSim) DeleteById(c, id string) int64 {
+	m.Open()
+	defer m.Close()
+	coll := m.C.Database(m.DbName).Collection(c)
+	r, err := coll.DeleteOne(m.Ctx, map[string]interface{}{"_id": StringTOBsonId(id)})
+	if err != nil {
+		return 0
+	}
+	return r.DeletedCount
+}
+
+//通过条件删除
+func (m *MongodbSim) Delete(c string, query map[string]interface{}) int64 {
+	m.Open()
+	defer m.Close()
+	coll := m.C.Database(m.DbName).Collection(c)
+	r, err := coll.DeleteMany(m.Ctx, query)
+	if err != nil {
+		return 0
+	}
+	return r.DeletedCount
+}
+
+//findbyid
+func (m *MongodbSim) FindById(c, id string) map[string]interface{} {
+	m.Open()
+	defer m.Close()
+	coll := m.C.Database(m.DbName).Collection(c)
+	r := coll.FindOne(m.Ctx, map[string]interface{}{"_id": StringTOBsonId(id)})
+	v := map[string]interface{}{}
+	r.Decode(&v)
+	return v
+}
+
+//findone
+func (m *MongodbSim) FindOne(c string, query map[string]interface{}) map[string]interface{} {
+	m.Open()
+	defer m.Close()
+	coll := m.C.Database(m.DbName).Collection(c)
+	r := coll.FindOne(m.Ctx, query)
+	v := map[string]interface{}{}
+	r.Decode(&v)
+	return v
+}
+
+//find
+func (m *MongodbSim) Find(c string, query map[string]interface{}, sort, fields interface{}) ([]map[string]interface{}, error) {
+	m.Open()
+	defer m.Close()
+	coll := m.C.Database(m.DbName).Collection(c)
+	op := options.Find()
+	r, err := coll.Find(m.Ctx, query, op.SetSort(sort), op.SetProjection(fields))
+	if err != nil {
+		log.Fatal(err)
+		return nil, err
+	}
+	var results []map[string]interface{}
+	if err = r.All(m.Ctx, &results); err != nil {
+		log.Fatal(err)
+		return nil, err
+	}
+	return results, nil
+}
+
+//创建_id
+func NewObjectId() primitive.ObjectID {
+	return primitive.NewObjectID()
+}
+
+func StringTOBsonId(id string) primitive.ObjectID {
+	objectId, _ := primitive.ObjectIDFromHex(id)
+	return objectId
+}
+
+func BsonTOStringId(id interface{}) string {
+	return id.(primitive.ObjectID).Hex()
+}

+ 62 - 0
data_monitoring/vps_server/src/sendmail.go

@@ -0,0 +1,62 @@
+package main
+
+import (
+	"fmt"
+	"io/ioutil"
+	"log"
+	"net/http"
+	qu "qfw/util"
+	"qfw/util/mail"
+)
+
+var from,to, smtpHost,user,pwd string
+var smtpPort int
+var tomail string
+var api string
+
+//smtp模式  二选一 皆可
+func sendErrMailSmtp(title,body string) {
+	smtpMail, _ := sysconfig["smtpMail"].(map[string]interface{})
+
+	if smtpMail != nil {
+		from, _ = smtpMail["from"].(string)
+		to, _ = smtpMail["to"].(string)
+		smtpHost, _ = smtpMail["smtpHost"].(string)
+		smtpPort= qu.IntAll(smtpMail["smtpPort"])
+		user, _ = smtpMail["user"].(string)
+		pwd, _ = smtpMail["pwd"].(string)
+	}
+
+	ok := mail.GSendMail_B(user, from, from, from, title, body, "", nil, &mail.GmailAuth{
+		SmtpHost: smtpHost,
+		SmtpPort: smtpPort,
+		User:     user,
+		Pwd:      pwd,
+	})
+	if ok {
+		log.Println("邮件发送-成功...")
+	}else {
+		log.Println("邮件发送-失败...")
+	}
+
+}
+
+
+
+//api模式 二选一皆可
+func sendErrMailApi(title,body string)  {
+	jkmail, _ := sysconfig["jkmail"].(map[string]interface{})
+	if jkmail != nil {
+		tomail, _ = jkmail["to"].(string)
+		api, _ = jkmail["api"].(string)
+	}
+	log.Println(tomail,api)
+	res, err := http.Get(fmt.Sprintf("%s?to=%s&title=%s&body=%s", api, tomail, title, body))
+	if err == nil {
+		defer res.Body.Close()
+		read, err := ioutil.ReadAll(res.Body)
+		log.Println("邮件发送成功:", string(read), err)
+	}else {
+		log.Println("邮件发送失败:", err)
+	}
+}

+ 13 - 0
data_quality/src/mgo.go

@@ -125,6 +125,8 @@ type MongodbSim struct {
 	Ctx      context.Context
 	ShortCtx context.Context
 	pool     chan bool
+	UserName string
+	Password string
 }
 
 func (m *MongodbSim) GetMgoConn() *MgoSess {
@@ -146,6 +148,17 @@ func (m *MongodbSim) InitPool() {
 	opts.ApplyURI("mongodb://" + m.MongodbAddr)
 	opts.SetMaxPoolSize(uint64(m.Size))
 	m.pool = make(chan bool, m.Size)
+
+	if m.UserName !="" && m.Password !="" {
+		cre := options.Credential{
+			Username:m.UserName,
+			Password:m.Password,
+		}
+		opts.SetAuth(cre)
+	}
+
+
+
 	opts.SetMaxConnIdleTime(2 * time.Hour)
 	m.Ctx, _ = context.WithTimeout(context.Background(), 99999*time.Hour)
 	m.ShortCtx, _ = context.WithTimeout(context.Background(), 1*time.Minute)

+ 13 - 5
fullproject/src_v1/config.json

@@ -4,10 +4,11 @@
     "statusdays": 15,
 	"mongodbServers": "192.168.3.207:27092",
     "mongodbPoolSize": 10,
-    "mongodbName": "wjh",
+    "mongodbName": "qfw_data",
 	"hints":"publishtime_1",
-    "extractColl": "jh_info",
-    "projectColl": "jh_project",
+    "extractColl": "bidding",
+    "extractColl1": "bidding",
+    "projectColl": "projectset",
     "backupFlag": true,
     "siteColl": "site",
     "thread": 1,
@@ -18,10 +19,17 @@
     "bidding": {
         "addr": "192.168.3.207:27092",
         "dbname": "qfw",
-        "dbsize": 5
+        "dbsize": 5,
+        "uname": "dataAnyWrite",
+        "upwd": "data@dataAnyWrite"
+    },
+    "spider": {
+        "addr": "192.168.3.207:27092",
+        "dbname": "editor",
+        "dbsize": 2
     },
     "es": {
-        "addr": "http://192.168.3.128:9800",
+        "addr": "http://192.168.3.11:9800",
         "index": "projectset",
         "itype": "projectset",
         "pool": 10

+ 22 - 1
fullproject/src_v1/init.go

@@ -5,6 +5,7 @@ import (
 	"math"
 	mu "mfw/util"
 	"qfw/util"
+	"reflect"
 	"regexp"
 	"sort"
 	"strings"
@@ -15,7 +16,7 @@ import (
 
 var (
 	Sysconfig                                      map[string]interface{} //读取配置文件
-	MongoTool, MgoBidding                          *MongodbSim            //mongodb连接
+	MongoTool, MgoBidding, MgoSpider               *MongodbSim            //mongodb连接
 	ExtractColl, ProjectColl, BackupColl, SiteColl string                 //抽取表、项目表、项目快照表、站点表
 	ExtractColl1                                   string
 	Thread                                         int                    //配置项线程数
@@ -63,8 +64,17 @@ func init() {
 		MongodbAddr: bidding["addr"].(string),
 		Size:        util.IntAll(bidding["dbsize"]),
 		DbName:      bidding["dbname"].(string),
+		//UserName:    bidding["uname"].(string),
+		//Password:    bidding["upwd"].(string),
 	}
 	MgoBidding.InitPool()
+	spider, _ := Sysconfig["spider"].(map[string]interface{})
+	MgoSpider = &MongodbSim{
+		MongodbAddr: spider["addr"].(string),
+		Size:        util.IntAll(spider["dbsize"]),
+		DbName:      spider["dbname"].(string),
+	}
+	MgoSpider.InitPool()
 
 	ExtractColl = Sysconfig["extractColl"].(string)
 	ExtractColl1 = Sysconfig["extractColl1"].(string)
@@ -378,6 +388,17 @@ func BinarySearch(s []string, k string) int {
 	return -1
 }
 
+func Duplicate(a interface{}) (ret []interface{}) {
+	va := reflect.ValueOf(a)
+	for i := 0; i < va.Len(); i++ {
+		if i > 0 && reflect.DeepEqual(va.Index(i-1).Interface(), va.Index(i).Interface()) {
+			continue
+		}
+		ret = append(ret, va.Index(i).Interface())
+	}
+	return ret
+}
+
 //计算文本相似度
 func CosineSimilar(srcWords1, dstWords1 string) float64 {
 	srcWords, dstWords := strings.Split(srcWords1, ""), strings.Split(dstWords1, "")

+ 44 - 2
fullproject/src_v1/load_data.go

@@ -7,8 +7,7 @@ import (
 	"time"
 )
 
-//初始加载数据,默认加载最近6个月的数据
-
+//  初始加载数据,默认加载最近6个月的数据
 func (p *ProjectTask) loadData(starttime int64) {
 	log.Println("load project start..", starttime)
 	p.findLock.Lock()
@@ -161,3 +160,46 @@ func saveFiled(p *ProjectTask, res map[string]interface{}, tmp *ProjectInfo) {
 	}
 	tmp.InfoFiled = tmpMap
 }
+
+//  加载spidercode数据,isflow字段
+func (p *ProjectTask) loadSpiderCode() {
+	log.Println("load spider code start..")
+	p.findLock.Lock()
+	defer p.findLock.Unlock()
+	p.mapSpiderLock.Lock()
+	defer p.mapSpiderLock.Unlock()
+	sess := MgoSpider.GetMgoConn()
+	defer MgoSpider.DestoryMongoConn(sess)
+	q := map[string]interface{}{}
+	field := map[string]interface{}{"code": 1, "isflow": 1}
+	it := sess.DB(MgoSpider.DbName).C("luaconfig").Find(&q).Select(field).Iter()
+	n := 0
+	pool := make(chan map[string]interface{}, 100)
+	over := make(chan bool)
+	go func() {
+		for {
+			select {
+			case tmp := <-pool:
+				n++
+				code := util.ObjToString(tmp["code"])
+				p.mapSpider[code] = util.IntAll(tmp["isflow"])
+			case <-over:
+				return
+			}
+		}
+	}()
+	for {
+		result := make(map[string]interface{})
+		if it.Next(&result) {
+			go func(res map[string]interface{}) {
+				pool <- result
+			}(result)
+		} else {
+			break
+		}
+	}
+	time.Sleep(2 * time.Second)
+	over <- true
+	log.Println("load spider over..", n)
+
+}

+ 13 - 6
fullproject/src_v1/main.go

@@ -70,28 +70,29 @@ func DealSign() {
 	}
 }
 
-func mainT() {
+func main() {
 	//udp跑增量  id段   project
 	//udp跑全量			qlT
 	//udp跑历史数据  信息id1,id2/或id段  ls
 	//udp强制合并  信息id1,id2,id3 [项目id] 不存在时新建  qzhb
 	//udp强制拆分  项目id,信息id1,id2          qzcf
 	//udp重新合并  信息id1,id2,id3             cxhb
+	P_QL.loadSpiderCode()
+	P_QL.loadSite()
 	if Sysconfig["loadStart"] != nil {
 		loadStart := util.Int64All(Sysconfig["loadStart"])
 		if loadStart > -1 {
 			P_QL.loadData(loadStart)
 		}
 	}
-	P_QL.loadSite()
 	go checkMapJob()
 	time.Sleep(99999 * time.Hour)
 }
 
 //测试组人员使用
-func main() {
-	sid = "5f0fd94e801f744d04772ceb"
-	eid = "5f6304a0b49c3a9ded2f5974"
+func mainT() {
+	sid = "600f86a17cdc9beb563d9e33"
+	eid = "600f86a17cdc9beb563d9e34"
 	//flag.StringVar(&sid, "sid", "", "开始id")
 	//flag.StringVar(&eid, "eid", "", "结束id")
 	//flag.Parse()
@@ -184,7 +185,13 @@ func processUdpMsg(act byte, data []byte, ra *net.UDPAddr) {
 					P_QL.pici = time.Now().Unix()
 					P_QL.delInfoPro(mapInfo)
 				}()
-
+			case "spider": // 爬虫代码code、isflow
+				go func() {
+					defer func() {
+						<-SingleThread
+					}()
+					go P_QL.loadSpiderCode()
+				}()
 			case "history": //历史数据合并,暂时不写
 				go func() {
 					defer func() {

+ 29 - 0
fullproject/src_v1/mgotool.go

@@ -2,6 +2,7 @@ package main
 
 import (
 	"context"
+	"go.mongodb.org/mongo-driver/bson/primitive"
 	"log"
 	"time"
 
@@ -139,6 +140,8 @@ type MongodbSim struct {
 	Ctx      context.Context
 	ShortCtx context.Context
 	pool     chan bool
+	UserName string
+	Password string
 }
 
 func (m *MongodbSim) GetMgoConn() *MgoSess {
@@ -159,6 +162,13 @@ func (m *MongodbSim) InitPool() {
 	opts.SetConnectTimeout(3 * time.Second)
 	opts.ApplyURI("mongodb://" + m.MongodbAddr)
 	opts.SetMaxPoolSize(uint64(m.Size))
+	if m.UserName != "" && m.Password != "" {
+		cre := options.Credential{
+			Username: m.UserName,
+			Password: m.Password,
+		}
+		opts.SetAuth(cre)
+	}
 	m.pool = make(chan bool, m.Size)
 	opts.SetMaxConnIdleTime(2 * time.Hour)
 	m.Ctx, _ = context.WithTimeout(context.Background(), 99999*time.Hour)
@@ -195,6 +205,7 @@ func (m *MongodbSim) UpSertBulk(c string, doc ...[]map[string]interface{}) bool
 	r, e := coll.BulkWrite(m.Ctx, writes)
 	if e != nil {
 		log.Println("mgo upsert error:", e.Error(), r)
+		log.Println(doc)
 		return false
 	}
 	return true
@@ -264,3 +275,21 @@ func (m *MongodbSim) FindById(c, id string) map[string]interface{} {
 	_ = r.Decode(&result)
 	return result
 }
+
+func BsonIdToSId(uid interface{}) string {
+	if uid == nil {
+		return ""
+	} else if u, ok := uid.(string); ok {
+		return u
+	} else if u, ok := uid.(primitive.ObjectID); ok {
+		return u.Hex()
+	} else {
+		return ""
+	}
+}
+
+func StringTOBsonId(id string) primitive.ObjectID {
+	objectId, _ := primitive.ObjectIDFromHex(id)
+	return objectId
+}
+

+ 44 - 18
fullproject/src_v1/project.go

@@ -19,8 +19,6 @@ import (
 
 //从对应map中获取对比的项目id
 func (p *ProjectTask) getCompareIds(pn, pc, ptc, pb string) (bpn, bpc, bptc, bpb int, res []*Key, idArr []string, IDArr []*ID) {
-	p.findLock.Lock()
-	defer p.findLock.Unlock()
 	//	p.ConCurrentLock(n1, n2, n3, n4)
 	//	defer p.ConCurrentUnLock(n1, n2, n3, n4)
 	p.wg.Add(1)
@@ -94,6 +92,19 @@ func (p *ProjectTask) getCompareIds(pn, pc, ptc, pb string) (bpn, bpc, bptc, bpb
 }
 
 func (p *ProjectTask) startProjectMerge(info *Info, tmp map[string]interface{}) {
+	p.findLock.Lock()
+	defer p.findLock.Unlock()
+	// 3.18 isfow=0数据不参与项目合并
+	code := qu.ObjToString(tmp["spidercode"])
+	p.mapSpiderLock.Lock()
+	isflow := p.mapSpider[code]
+	p.mapSpiderLock.Unlock()
+	if isflow == 0 {
+		id, _ := p.NewProject(tmp, info)
+		qu.Debug("直接新建项目,", "project id", id)
+		return
+	}
+
 	//只有或没有采购单位的无法合并
 	//bpn, bpc, bptc, bpb 是否查找到,并标识位置。-1代表未查找到。
 	//pids 是项目id数组集合
@@ -225,10 +236,10 @@ func (p *ProjectTask) startProjectMerge(info *Info, tmp map[string]interface{})
 	}
 
 	if !bFindProject {
-		if !IsCreatePro(info) {
-			qu.Debug("舍弃数据---", info.Id)
-			return
-		}
+		//if !IsCreatePro(info) {
+		//	qu.Debug("舍弃数据---", info.Id)
+		//	return
+		//}
 		id, p1 := p.NewProject(tmp, info)
 		p.AllIdsMapLock.Lock()
 		p.AllIdsMap[id] = &ID{Id: id, P: p1}
@@ -532,8 +543,10 @@ func (p *ProjectTask) NewProject(tmp map[string]interface{}, thisinfo *Info) (st
 	}
 	//标的物
 	if thisinfo.Purchasing != "" {
-		set["purchasing"] = thisinfo.Purchasing
-		p1.Purchasing = thisinfo.Purchasing
+		list := Duplicate(strings.Split(thisinfo.Purchasing, ","))		//标的物 去重 03/03
+		p := strings.Join(qu.ObjArrToStringArr(list), ",")
+		set["purchasing"] = p
+		p1.Purchasing = p
 	}
 	//中标候选人
 	if len(thisinfo.WinnerOrder) > 0 {
@@ -653,7 +666,6 @@ func (p *ProjectTask) NewProject(tmp map[string]interface{}, thisinfo *Info) (st
 			"$set": set,
 		},
 	}
-	//log.Println(set)
 	return pId.Hex(), &p1
 }
 
@@ -778,19 +790,20 @@ func (p *ProjectTask) UpdateProject(tmp map[string]interface{}, thisinfo *Info,
 	} else if thisinfo.TopType == "结果" {
 		if thisinfo.SubType == "中标" || thisinfo.SubType == "成交" || thisinfo.SubType == "流标" || thisinfo.SubType == "废标" {
 			if pInfo.Jgtime > 0 {
-				jg1 := int64(math.Abs(float64(pInfo.Jgtime - thisinfo.Publishtime)))
+				//jg1 := int64(math.Abs(float64(pInfo.Jgtime - thisinfo.Publishtime)))
+				// 4.12	直接更新jgtime
 				//公告状态和项目状态同样都是中标或者成交,
 				if (thisinfo.SubType == "中标" || thisinfo.SubType == "成交") && (pInfo.Bidstatus == "中标" || pInfo.Bidstatus == "成交") {
-					if jg1 > p.jgTime {
+					//if jg1 > p.jgTime {
 						set["jgtime"] = tmp["publishtime"]
 						pInfo.Jgtime = thisinfo.Publishtime
-					}
+					//}
 					//公告状态和项目状态同样是流标或者废标
 				} else if (thisinfo.SubType == "流标" || thisinfo.SubType == "废标") && (pInfo.Bidstatus == "流标" || pInfo.Bidstatus == "废标") {
-					if jg1 > p.jgTime {
+					//if jg1 > p.jgTime {
 						set["jgtime"] = tmp["publishtime"]
 						pInfo.Jgtime = thisinfo.Publishtime
-					}
+					//}
 				}
 			} else {
 				set["jgtime"] = tmp["publishtime"]
@@ -918,7 +931,11 @@ func (p *ProjectTask) UpdateProject(tmp map[string]interface{}, thisinfo *Info,
 		set["buyertel"] = ""
 	}
 	if thisinfo.ContractCode != "" {
-		set["contractcode"] = pInfo.ContractCode + "," + thisinfo.ContractCode
+		if pInfo.ContractCode == "" {
+			set["contractcode"] = thisinfo.ContractCode
+		}else {
+			set["contractcode"] = pInfo.ContractCode + "," + thisinfo.ContractCode
+		}
 	}
 
 	//8--代理机构
@@ -945,10 +962,13 @@ func (p *ProjectTask) UpdateProject(tmp map[string]interface{}, thisinfo *Info,
 	}
 	if thisinfo.Purchasing != "" {
 		if pInfo.Purchasing == "" {
-			pInfo.Purchasing = thisinfo.Purchasing
-			set["purchasing"] = thisinfo.Purchasing
+			list := Duplicate(strings.Split(thisinfo.Purchasing, ","))		//标的物 去重 03/03
+			p := strings.Join(qu.ObjArrToStringArr(list), ",")
+			pInfo.Purchasing = p
+			set["purchasing"] = p
 		} else {
 			list := strings.Split(pInfo.Purchasing, ",")
+			list = qu.ObjArrToStringArr(Duplicate(list))
 			for _, k := range list {
 				if BinarySearch(strings.Split(thisinfo.Purchasing, ","), k) == -1 {
 					list = append(list, k)
@@ -1493,7 +1513,9 @@ var bidstatus = map[string]string{
 	"合同": "合同",
 }
 
-func GetBidTypeAndBidStatus(info *Info) (string, string) {
+func (p *ProjectTask) GetBidTypeAndBidStatus(info *Info) (string, string) {
+	p.mapBidLock.Lock()
+	defer p.mapBidLock.Unlock()
 	typeStr := bidtype[info.TopType]
 	statusStr := bidstatus[info.SubType]
 	if info.Infoformat == 2 || info.SubType == "拟建" {
@@ -1514,3 +1536,7 @@ func GetBidTypeAndBidStatus(info *Info) (string, string) {
 	return typeStr, statusStr
 
 }
+
+func ListSort(tmp map[string]interface{}) {
+
+}

+ 37 - 39
fullproject/src_v1/task.go

@@ -6,7 +6,7 @@ import (
 	"gopkg.in/mgo.v2/bson"
 	"log"
 	mu "mfw/util"
-	"mgoutil/mongodb"
+	"mongodb"
 	"qfw/util"
 	"regexp"
 	"strings"
@@ -71,6 +71,9 @@ type ProjectTask struct {
 	//站点
 	mapSite     map[string]*Site
 	mapSiteLock sync.Mutex
+	//spider isflow
+	mapSpider     map[string]int
+	mapSpiderLock sync.Mutex
 	//bidtype、bidstatus 锁
 	mapBidLock sync.Mutex
 	//更新或新增通道
@@ -113,6 +116,7 @@ func NewPT() *ProjectTask {
 		mapPc:     make(map[string]*Key, 5000000),
 		mapHref:   make(map[string]string, 1500000),
 		mapSite:   make(map[string]*Site, 1000000),
+		mapSpider: make(map[string]int, 1000000),
 		saveSize:  100,
 
 		//saveSign:   make(chan bool, 1),
@@ -120,7 +124,7 @@ func NewPT() *ProjectTask {
 		coll:       ProjectColl,
 		validTime:  int64(util.IntAllDef(Sysconfig["validdays"], 150) * 86400),
 		statusTime: int64(util.IntAllDef(Sysconfig["statusdays"], 15) * 86400),
-		jgTime:		int64(util.IntAllDef(3, 3) * 86400),
+		jgTime:		int64(util.IntAllDef(7, 7) * 86400),
 	}
 	return p
 }
@@ -310,18 +314,13 @@ func (p *ProjectTask) taskZl(udpInfo map[string]interface{}) {
 	q, _ := udpInfo["query"].(map[string]interface{})
 	gtid := udpInfo["gtid"].(string)
 	lteid := udpInfo["lteid"].(string)
-	if q == nil {
-		q = map[string]interface{}{
-			"_id": map[string]interface{}{
-				"$gt":  StringTOBsonId(gtid),
-				"$lte": StringTOBsonId(lteid),
-			},
-		}
-	}
-	if q != nil {
-		//生成查询语句执行
-		p.enter(db, coll, q)
+	q = map[string]interface{}{
+		"_id": map[string]interface{}{
+			"$gt":  StringTOBsonId(gtid),
+			"$lte": StringTOBsonId(lteid),
+		},
 	}
+	p.enter(db, coll, q)
 	if udpInfo["stop"] == nil {
 		for i := 0; i < 5; i++ {
 			sp <- true
@@ -432,11 +431,6 @@ func (p *ProjectTask) delInfoPro(udpInfo map[string]interface{}) {
 	}
 }
 
-func StringTOBsonId(id string) primitive.ObjectID {
-	objectId, _ := primitive.ObjectIDFromHex(id)
-	return objectId
-}
-
 //通知下个节点nextNode
 func nextNode(mapInfo map[string]interface{}, pici int64) {
 	mapInfo["stype"] = "project"
@@ -476,24 +470,11 @@ func (p *ProjectTask) enter(db, coll string, q map[string]interface{}) {
 					defer func() {
 						<-pool
 					}()
-					if util.IntAll(tmp["repeat"]) == 0 {
-						if P_QL.currentType == "project" && util.IntAll(tmp["dataging"]) == 1 {
-							//增量	dataging为1不参与合并
-							util.Debug("增量   dataging == 1 ", tmp["_id"])
-							return
-						}
-
-						p.fillInPlace(tmp)
-						info := ParseInfo(tmp)
-						p.currentTime = info.Publishtime
-						//普通合并
-						p.CommonMerge(tmp, info)
-					} else {
-						//信息错误,进行更新
-						p.mapBidLock.Lock()
-						countRepeat++
-						p.mapBidLock.Unlock()
-					}
+					p.fillInPlace(tmp)
+					info := ParseInfo(tmp)
+					p.currentTime = info.Publishtime
+					//普通合并
+					p.CommonMerge(tmp, info)
 				}(tmp)
 			case <-over:
 				break L
@@ -526,10 +507,27 @@ L:
 			tmp := make(map[string]interface{})
 			if query.Next(&tmp) {
 				lastid = tmp["_id"]
-				if count%10000 == 0 {
-					log.Println("current", count, lastid)
+				if P_QL.currentType == "ql" {
+					if count%20000 == 0 {
+						log.Println("current", count, lastid)
+					}
+				}else {
+					if count%1000 == 0 {
+						log.Println("current", count, lastid)
+					}
+				}
+				if util.IntAll(tmp["repeat"]) == 0 {
+					if P_QL.currentType == "project" && util.IntAll(tmp["dataging"]) == 0 {
+						infoPool <- tmp
+					}else {
+						util.Debug("增量   dataging == 1 ", tmp["_id"])
+					}
+				}else {
+					countRepeat++
+					if P_QL.currentType == "project" {
+						util.Debug("repeat err---", tmp["_id"])
+					}
 				}
-				infoPool <- tmp
 				count++
 			} else {
 				break L

+ 5 - 6
fullproject/src_v1/update.go

@@ -8,7 +8,6 @@ import (
 	"go.mongodb.org/mongo-driver/bson/primitive"
 	"math"
 	mu "mfw/util"
-	"mongodb"
 	qu "qfw/util"
 	"reflect"
 	"sort"
@@ -398,7 +397,7 @@ func (p *ProjectTask) ReMerge(info *Info, tmp map[string]interface{}, tmpPro map
 			if len(resArr) > 0 {
 				bFindProject = true
 				findPid = resArr[0].Id.Hex()
-				if findPid == mongodb.BsonIdToSId(tmpPro["_id"]) {
+				if findPid == BsonIdToSId(tmpPro["_id"]) {
 					return false
 				}
 				p.updateProFiled(tmp, info, resArr[0], kv+1, resArr[0].comStr, ex)
@@ -556,7 +555,7 @@ func (p *ProjectTask) updateProFiled(tmp map[string]interface{}, thisinfo *Info,
 		set["bidopentime"] = pInfo.Bidopentime
 	}
 	// bidtype、bidstatus
-	pInfo.Bidtype, pInfo.Bidstatus = GetBidTypeAndBidStatus(thisinfo)
+	pInfo.Bidtype, pInfo.Bidstatus = p.GetBidTypeAndBidStatus(thisinfo)
 	set["bidtype"] = pInfo.Bidtype
 	set["bidstatus"] = pInfo.Bidstatus
 
@@ -791,7 +790,7 @@ func (p *ProjectTask) newPro(tmp, tmpPro map[string]interface{}, thisinfo *Info)
 	if thisinfo.ContractCode != "" {
 		tmpPro["contractcode"] = thisinfo.ContractCode
 	}
-	bs, bt := GetBidTypeAndBidStatus(thisinfo)
+	bs, bt := p.GetBidTypeAndBidStatus(thisinfo)
 	tmpPro["bidtype"] = bs
 	tmpPro["bidstatus"] = bt
 	pkg := PackageFormat(thisinfo, nil)
@@ -939,7 +938,7 @@ func (p *ProjectTask) updateOldProField(pInfo *ProjectInfo, thisinfo *Info, tmpP
 		tmpPro["bidopentime"] = pInfo.Bidopentime
 	}
 	// bidtype、bidstatus
-	pInfo.Bidtype, pInfo.Bidstatus = GetBidTypeAndBidStatus(thisinfo)
+	pInfo.Bidtype, pInfo.Bidstatus = p.GetBidTypeAndBidStatus(thisinfo)
 	tmpPro["bidtype"] = pInfo.Bidtype
 	tmpPro["bidstatus"] = pInfo.Bidstatus
 
@@ -1183,7 +1182,7 @@ func backupPro(tmp map[string]interface{}) {
 		tmp1[k] = v
 	}
 	if Sysconfig["backupFlag"].(bool) {
-		tmp1["sourceprojectid"] = mongodb.BsonIdToSId(tmp1["_id"])
+		tmp1["sourceprojectid"] = BsonIdToSId(tmp1["_id"])
 		delete(tmp1, "_id")
 		MongoTool.Save(BackupColl, tmp1)
 	}

+ 27 - 0
monitor/README.MD

@@ -0,0 +1,27 @@
+- 1.检索库健康状态监控
+- 2.mgo库数据异常监控
+
+
+---
+>
+> mgo监控  
+> 存量统计:对比内容中存储的上次统计的id和数量  
+> 增量统计:当前时间点前一个小时的数量
+> 
+
+---
+> curl -s http://localhost:9800/_cat/health  
+前两个是时间戳,不过多介绍。其余如下:  
+cluster ,集群名称  
+status,集群状态 green代表健康;yellow代表分配了所有主分片,但至少缺少一个副本,此时集群数据仍旧完整;red代表部分主分片不可用,可能已经丢失数据。  
+node.total,代表在线的节点总数量  
+node.data,代表在线的数据节点的数量  
+shards, active_shards 存活的分片数量  
+pri,active_primary_shards 存活的主分片数量 正常情况下 shards的数量是pri的两倍。  
+relo, relocating_shards 迁移中的分片数量,正常情况为 0  
+init, initializing_shards 初始化中的分片数量 正常情况为 0  
+unassign, unassigned_shards 未分配的分片 正常情况为 0  
+pending_tasks,准备中的任务,任务指迁移分片等 正常情况为 0  
+max_task_wait_time,任务最长等待时间(版本差异)  
+active_shards_percent,正常分片百分比 正常情况为(版本差异) 100%  
+> 

+ 25 - 0
monitor/config.json

@@ -0,0 +1,25 @@
+{
+  "tasktime": 1,
+  "count": {
+    "bidding_back_size": 10000,
+    "last_stock_id": "600000000000000000000000",
+    "last_stock_size": 100000,
+    "last_add_size": 0
+  },
+  "bidding": {
+    "mgodb": "192.168.3.207:27092",
+    "dbsize": 12,
+    "dbname": "qfw_data",
+    "uname": "",
+    "upwd": ""
+  },
+  "elastic": {
+    "addr": "http://192.168.3.128:9800",
+    "index": "",
+    "itype": ""
+  },
+  "jkmail": {
+    "to": "wangjianghan@topnet.net.cn",
+    "api": "http://10.171.112.160:19281/_send/_mail"
+  }
+}

+ 56 - 0
monitor/main.go

@@ -0,0 +1,56 @@
+package main
+
+import (
+	"mongodb"
+	"qfw/util"
+	es "qfw/util/elastic"
+)
+
+var (
+	Sysconfig                    map[string]interface{}
+	Mgo                          *mongodb.MongodbSim
+	Es                           *es.Elastic
+	TaskTime					 int
+	Index, Itype				 string
+	BiddingBackSize				 int64		//biding_back	数据量
+	LastStockId					 string		//上次统计存量id
+	LastStockSize				 int64		//上次统计存量数据
+	LastAddSize				 	 int64		//上次统计增量数据
+	api, to						 string
+)
+
+func init() {
+	util.ReadConfig(&Sysconfig)
+	bidding := Sysconfig["bidding"].(map[string]interface{})
+	Mgo = &mongodb.MongodbSim{
+		MongodbAddr: bidding["mgodb"].(string),
+		Size:        util.IntAllDef(bidding["dbsize"], 2),
+		DbName:      bidding["dbname"].(string),
+		UserName:    bidding["uname"].(string),
+		Password:    bidding["upwd"].(string),
+	}
+	Mgo.InitPool()
+	econf := Sysconfig["elastic"].(map[string]interface{})
+	Es = &es.Elastic{
+		S_esurl: econf["addr"].(string),
+		I_size:  util.IntAllDef(econf["pool"], 12),
+	}
+	Es.InitElasticSize()
+	TaskTime = util.IntAll(Sysconfig["tasktime"])
+	Index = util.ObjToString(Sysconfig["index"])
+	Itype = util.ObjToString(Sysconfig["itype"])
+	count := Sysconfig["count"].(map[string]interface{})
+	BiddingBackSize = util.Int64All(count["bidding_back_size"])
+	LastStockId = util.ObjToString(count["last_stock_id"])
+	LastStockSize = util.Int64All(count["last_stock_size"])
+	LastAddSize = util.Int64All(count["last_add_size"])
+	jkmail := Sysconfig["jkmail"].(map[string]interface{})
+	to = util.ObjToString(jkmail["to"])
+	api = util.ObjToString(jkmail["api"])
+}
+
+func main() {
+	go TimeTask()
+	ch := make(chan bool, 1)
+	<-ch
+}

+ 105 - 0
monitor/task.go

@@ -0,0 +1,105 @@
+package main
+
+import (
+	"fmt"
+	"github.com/cron"
+	"go.mongodb.org/mongo-driver/bson"
+	"mongodb"
+	"net/http"
+	"qfw/util"
+	"strconv"
+	"time"
+)
+
+var taskA = 0		// 增量统计跳过
+
+func TimeTask() {
+	//StartTask()
+	c := cron.New()
+	cronstr := "0 0 * * * ?" // 每小时执行一次
+	_ = c.AddFunc(cronstr, func() { StartTask() })
+	c.Start()
+}
+
+func StartTask() {
+	util.Debug("Start Task...")
+	result := MgoCount()
+	result = EsCheck(result)
+	if result != "" {
+		util.Debug(result)
+		SendMail(result)
+	}
+	util.Debug("Task Over...")
+}
+
+// 统计mgo数据
+func MgoCount() string {
+	defer util.Catch()
+	sess := Mgo.GetMgoConn()
+	defer Mgo.DestoryMongoConn(sess)
+	result := ""
+	// biddingback
+	count := Mgo.Count("bidding_back", nil)
+	util.Debug("bidding_back---", BiddingBackSize, count)
+	if int64(count) != BiddingBackSize {
+		result = fmt.Sprintf("bindding_back数据异常,统计结果%d,往常数据量%d", count, BiddingBackSize)
+		result += "<br>"
+	}
+	// bidding
+	st := time.Now().Unix() - 3600
+	currentLastId := fmt.Sprintf("%x0000000000000000", st)
+	//	对比内存中存量id的统计结果
+	q1 := bson.M{"_id": bson.M{"$lte": mongodb.StringTOBsonId(LastStockId)}}
+	count1 := Mgo.Count("bidding", q1)
+	util.Debug("bidding---", LastStockSize, count1, q1)
+	if int64(count1) != LastStockSize {
+		result = fmt.Sprintf("bindding数据存量统计异常,统计条件%v,统计结果%d,上次统计数据量%d", q1, count1, LastStockSize)
+		result += "<br>"
+	}else {
+		//	无异常,替换成当前时间点(当前时间点往前一个小时的id)存量的统计结果
+		LastStockId = currentLastId
+		q2 := bson.M{"_id": bson.M{"$lte": mongodb.StringTOBsonId(LastStockId)}}
+		count2 := Mgo.Count("bidding", q2)
+		LastStockSize = int64(count2)
+	}
+	//	增量
+	et := time.Now().Unix()
+	currentId := fmt.Sprintf("%x0000000000000000", et)
+	q3 := bson.M{"_id": bson.M{"$gt": mongodb.StringTOBsonId(currentLastId), "$lte": mongodb.StringTOBsonId(currentId)}}
+	count3 := Mgo.Count("bidding", q3)
+	util.Debug("bidding---", count3, q3)
+	if int64(count3) == 0 {
+		if taskA > 1 {
+			result += fmt.Sprintf("bindding数据增量统计异常,统计条件%v,统计结果%d", q3, count3)
+			result += "<br><br>"
+			taskA = 0
+		}else {
+			taskA ++
+		}
+	}
+	return result
+}
+
+func EsCheck(result string) string {
+	client := Es.GetEsConn()
+	defer Es.DestoryEsConn(client)
+	resp, _ := client.ClusterHealth().Do()
+	util.Debug(*resp)
+	if resp.Status != "green" {
+		result += "<br>" + "检索库异常,异常内容:" + "<br>" +
+			"cluster_name:" + resp.ClusterName + "<br>" +
+			"status:" + resp.Status + "<br>" +
+			"number_of_nodes:" + strconv.Itoa(resp.NumberOfNodes) + "<br>" +
+			"number_of_data_nodes:" + strconv.Itoa(resp.NumberOfDataNodes) + "<br>" +
+			"number_of_data_nodes:" + strconv.Itoa(resp.ActivePrimaryShards) + "<br>" +
+			"active_shards:" + strconv.Itoa(resp.ActiveShards) + "<br>" +
+			"relocating_shards:" + strconv.Itoa(resp.RelocatingShards) + "<br>" +
+			"initialized_shards:" + strconv.Itoa(resp.InitializedShards) + "<br>" +
+			"unassigned_shards:" + strconv.Itoa(resp.UnassignedShards) + "<br>"
+	}
+	return result
+}
+
+func SendMail(report string) {
+	_, _ = http.Get(fmt.Sprintf("%s?to=%s&title=%s&body=%s", api, to, "异常报告!", report))
+}

+ 0 - 29
projectforecast/config.json

@@ -1,29 +0,0 @@
-{
-  "mongodbServers": "192.168.3.166:27082",
-  "mongodbPoolSize": 10,
-  "mongodbName": "bqData",
-  "mongoColl_pro": "projectinfo_new",
-  "mongoColl_ent": "buyer_enterprise",
-  "mongoColl_tag": "project_biaoqian",
-  "mongoColl_save": "project_new_forecast",
-  "udpport": ":1182",
-  "spiderCodes": ["jzgc_nxjzscjgfwxt_gcyj", "jzgc_fjsjshyxxgkpt_gcxmcx", "jzgc_ahszfhcxjshyggxxcxzx_qycx", "jzgc_ahszfhcxjshyggxxcxzx_xmcx", "jzgc_bjsjzscxxgkpt_qyxx", "jzgc_bjsjzscxxgkpt_xmxx_htbaxx", "jzgc_bjsjzscxxgkpt_xmxx_jgbaxx",
-    "jzgc_bjsjzscxxgkpt_xmxx_lwfblyxx", "jzgc_bjsjzscxxgkpt_xmxx_sgxkxx", "jzgc_bjsjzscxxgkpt_xmxx_yjxx", "jzgc_cqszfhcxjswyh_qyxx", "jzgc_cqszfhcxjswyh_xmxx", "jzgc_fjsjshyxxgkpt_qyxxcx", "jzgc_gdsjshysjkfpt_qyxx", "jzgc_gdsjshysjkfpt_xmxx",
-    "jzgc_gssjzscjgggfwpt_sgxkxm", "jzgc_gxjzscjgycxxxythptxxfb_gcxm", "jzgc_gxjzscjgycxxxythptxxfb_qyxx", "jzgc_hbszfhcxjst_gcxx", "jzgc_hbszfhcxjst_qyzz", "jzgc_hnsjzscjgggfwpt_jsgcqy", "jzgc_hnsjzschgczlaqjgythpt_gcxx", "jzgc_hnsjzschgczlaqjgythpt_qyxx",
-    "jzgc_hnsjzscjgggfwpt_jsxm", "jzgc_jlsjzscjgggfwpt_gcxmxx", "jzgc_jlsjzscjgggfwpt_qyxx", "jzgc_jssjzscjgycxxxythpt_qyxx", "jzgc_lnsjzscggfwpt_gcxmxx", "jzgc_lnsjzscggfwpt_qyxx", "jzgc_nmgzzqjzscjgycxxxglpt_gcxmxx", "jzgc_nmgzzqjzscjgycxxxglpt_qyxx",
-    "jzgc_nxjzscjgfwxt_qysj", "jzgc_nxjzscjgfwxt_gcsj", "jzgc_qhsgcjsjghxyglpt_gcxm", "jzgc_qhsgcjsjghxyglpt_qyxx", "jzgc_scszfcxjshysjgxpt_qyxx", "jzgc_sdszfcxjsfwjgyxyxxzhpt_qycx", "jzgc_sdszfcxjsfwjgyxyxxzhpt_xmcx", "jzgc_sxsjzscjgggfwpt_qyxx",
-    "jzgc_sxsjzscjgggfwpt_xmxx", "jzgc_tjszfhcxjswyh_gcxmxx", "jzgc_sxsjzscjgycxxxfbpt_gcxmxxcx", "jzgc_sxsjzscjgycxxxfbpt_qycx", "jzgc_xjgcjsy_gcxm", "jzgc_xjgcjsy_qyxx", "jzgc_xzzzqjzscjgycxxxpt_gcxx", "jzgc_xzzzqjzscjgycxxxpt_qyxx", "jzgc_scszfcxjshysjgxpt_xmxx"
-  ],
-  "forecast": {
-    "规划可研": ["立项环评", "勘察设计", "建设准备", "前期准备"],
-    "立项环评": ["勘察设计", "建设准备", "前期施工"],
-    "勘察设计": ["建设准备", "前期施工"],
-    "建设准备": ["前期施工"],
-    "前期施工": ["后期施工"],
-    "后期施工": ["竣工验收", "运行维护", "物品采购"],
-    "竣工验收": ["运行维护", "物品采购"],
-    "运行维护": ["物品采购"]},
-  "category": ["道路", "学校", "医院"],
-  "nature": ["新建", "扩建", "拆建"],
-  "rate": "60%"
-}

+ 0 - 76
projectforecast/main.go

@@ -1,76 +0,0 @@
-package main
-
-import (
-	"encoding/json"
-	mu "mfw/util"
-	"mongodb"
-	"net"
-	"qfw/util"
-)
-
-var (
-	Sysconfig   map[string]interface{}
-	MongoTool   *mongodb.MongodbSim
-	Dbname      string
-	CollPro     string //项目表
-	CollTag     string //标签表
-	CollSave    string
-	CollEnt		string
-	Rate        string
-	Forecast    map[string]interface{}
-	Category    []interface{}
-	Nature      []interface{}
-	SpiderCodes []interface{}
-	udpclient   mu.UdpClient
-)
-
-var MgoSaveCache = make(chan map[string]interface{}, 2000)
-var SP = make(chan bool, 5)
-
-func init() {
-	util.ReadConfig(&Sysconfig)
-
-	Dbname = Sysconfig["mongodbName"].(string)
-	MongoTool = &mongodb.MongodbSim{
-		MongodbAddr: Sysconfig["mongodbServers"].(string),
-		Size:        util.IntAll(Sysconfig["mongodbPoolSize"]),
-		DbName:      Dbname,
-	}
-	MongoTool.InitPool()
-
-	CollPro = Sysconfig["mongoColl_pro"].(string)
-	CollTag = Sysconfig["mongoColl_tag"].(string)
-	CollSave = Sysconfig["mongoColl_save"].(string)
-	CollEnt = Sysconfig["mongoColl_ent"].(string)
-	Rate = util.ObjToString(Sysconfig["rate"])
-	Forecast = Sysconfig["forecast"].(map[string]interface{})
-	Category = Sysconfig["category"].([]interface{})
-	Nature = Sysconfig["nature"].([]interface{})
-	SpiderCodes = Sysconfig["spiderCodes"].([]interface{})
-
-	udpport, _ := Sysconfig["udpport"].(string)
-	udpclient = mu.UdpClient{Local: udpport, BufSize: 1024}
-	udpclient.Listen(processUdpMsg)
-	util.Debug("Udp服务监听", udpport)
-}
-
-func main() {
-	go SaveMgo()
-	GetProjectData("1567295000")
-	ch := make(chan bool, 1)
-	<-ch
-}
-
-
-//udp调用信号
-func processUdpMsg(act byte, data []byte, ra *net.UDPAddr) {
-	util.Debug(act)
-	var mapInfo map[string]interface{}
-	err := json.Unmarshal(data, &mapInfo)
-	util.Debug("err:", err, "mapInfo:", mapInfo)
-	if err != nil {
-		_ = udpclient.WriteUdp([]byte("err:"+err.Error()), mu.OP_NOOP, ra)
-	} else if mapInfo != nil {
-		GetProjectData(util.ObjToString(mapInfo["updatetime"]))
-	}
-}

+ 0 - 191
projectforecast/task.go

@@ -1,191 +0,0 @@
-package main
-
-import (
-	"go.mongodb.org/mongo-driver/bson"
-	"log"
-	"mongodb"
-	qu "qfw/util"
-	"time"
-)
-
-var queryClose = make(chan bool)
-var queryCloseOver = make(chan bool)
-
-func SaveMgo() {
-	log.Println("Mgo Save...")
-	arru := make([]map[string]interface{}, 200)
-	indexu := 0
-	for {
-		select {
-		case v := <-MgoSaveCache:
-			arru[indexu] = v
-			indexu++
-			if indexu == 200 {
-				SP <- true
-				go func(arru []map[string]interface{}) {
-					defer func() {
-						<-SP
-					}()
-					MongoTool.SaveBulk(CollSave, arru...)
-				}(arru)
-				arru = make([]map[string]interface{}, 200)
-				indexu = 0
-			}
-		case <-time.After(1000 * time.Millisecond):
-			if indexu > 0 {
-				SP <- true
-				go func(arru []map[string]interface{}) {
-					defer func() {
-						<-SP
-					}()
-					MongoTool.SaveBulk(CollSave, arru...)
-				}(arru[:indexu])
-				arru = make([]map[string]interface{}, 200)
-				indexu = 0
-			}
-		}
-	}
-}
-
-//项目数据
-func GetProjectData(t string) {
-	defer qu.Catch()
-	count, taskcount := 0, 0
-	sess := MongoTool.GetMgoConn()
-	defer MongoTool.DestoryMongoConn(sess)
-	dataPool := make(chan map[string]interface{}, 2000)
-	over := make(chan bool)
-	pool := make(chan bool, 4)
-	go func() {
-	L:
-		for {
-			select {
-			case tmp := <-dataPool:
-				pool <- true
-				taskcount++
-				go func(tmp map[string]interface{}) {
-					defer func() {
-						<-pool
-					}()
-					ForecastMethod(tmp)
-				}(tmp)
-			case <-over:
-				break L
-			}
-		}
-	}()
-	//uptime, err := strconv.ParseInt(t, 10, 64)
-	//if err == nil {
-	//	qu.Debug(err)
-	//}
-	query := bson.M{
-		//"updatetime": bson.M{"$gt": uptime},
-		"o_projectinfo.nature":     bson.M{"$in": Nature},
-		"spidercode": bson.M{"$in": SpiderCodes},
-		"$or": []bson.M{
-			{"category_buyer": bson.M{"$in": Category}},
-			{"category_purpose": bson.M{"$in": Category}},
-		},
-	}
-	//qu.Debug("query-----", CollPro, query["updatetime"])
-	filed := map[string]interface{}{"area": 1, "city": 1, "buyer": 1, "projectname": 1, "nature": 1, "category_buyer": 1, "category_purpose": 1, "stage": 1, "o_projectinfo": 1, "title": 1}
-	it := sess.DB(Dbname).C(CollPro).Select(filed).Find(query).Iter()
-	var lastid interface{}
-L:
-	for {
-		select {
-		case <-queryClose:
-			log.Println("receive interrupt sign")
-			log.Println("close iter..", lastid, it.Cursor.Close(nil))
-			queryCloseOver <- true
-			break L
-		default:
-			tmp := make(map[string]interface{})
-			if it.Next(&tmp) {
-				lastid = tmp["_id"]
-				if count%1000 == 0 {
-					log.Println("current", count, lastid)
-				}
-				dataPool <- tmp
-				count++
-			} else {
-				break L
-			}
-		}
-	}
-	time.Sleep(5 * time.Second)
-	over <- true
-	//阻塞
-	for n := 0; n < 4; n++ {
-		pool <- true
-	}
-}
-
-func ForecastMethod(pro map[string]interface{}) {
-	pro["infoid"] = mongodb.BsonIdToSId(pro["_id"])
-	pro["yucetime"] = time.Now().Unix()
-	pro["nature"] = (*qu.ObjToMap(pro["o_projectinfo"]))["nature"]
-	delete(pro, "_id")
-	delete(pro, "o_projectinfo")
-	category := GetCategory(pro)
-	stage := qu.ObjToString(pro["stage"])
-	q := bson.M{
-		"category": category,
-		"stage":    bson.M{"$in": Forecast[stage]},
-	}
-	var maps []map[string]interface{}
-	ent, _ := MongoTool.FindOne(CollEnt, bson.M{"buyer_name": pro["buyer"]})
-	if len(*ent) > 0 && (*ent)["buyerclass"] != nil {
-		arr := qu.ObjArrToStringArr((*ent)["buyerclass"].([]interface{}))
-		if len(arr) == 1 {
-			pro["buyerclass"] = arr
-		}else {
-			var arrTmp  []string
-			for _, v := range arr {
-				if v != "其它" {
-					arrTmp = append(arrTmp, v)
-				}
-			}
-			pro["buyerclass"] = arrTmp
-		}
-	}
-	result, _ := MongoTool.Find(CollTag, q, nil, nil, false, -1, -1)
-	for _, t := range *result {
-		if len(t) == 0 {
-			continue
-		}
-		tmp := make(map[string]interface{})
-		tmp["stage"] = t["stage"]
-		tmp["purchase_classify"] = t["purchase_classify"]
-		tmp["purchasing"] = t["purchasing"]
-		tmp["p_rate"] = Rate
-		tmp["time"] = ""
-		//tmp["p_projects"] = ""		暂无该字段
-		maps = append(maps, tmp)
-	}
-	if len(maps) > 0 {
-		pro["results"] = maps
-	}
-	MgoSaveCache <- pro
-}
-
-func GetCategory(tmp map[string]interface{}) string {
-	categoryBuyerIndex := -1
-	categoryPurposeIndex := -1
-	for k, v := range Category {
-		if tmp["category_buyer"] != nil {
-			if qu.ObjToString(tmp["category_buyer"]) == qu.ObjToString(v) {
-				categoryBuyerIndex = k
-			}
-		}
-		if tmp["category_purpose"] != nil {
-			categoryPurposeIndex = k
-		}
-	}
-
-	if categoryBuyerIndex >= categoryPurposeIndex {
-		return qu.ObjToString(Category[categoryBuyerIndex])
-	} else {
-		return qu.ObjToString(Category[categoryPurposeIndex])
-	}
-}

+ 4 - 2
qyxy/src/config.json

@@ -1,13 +1,15 @@
 {
 	"mgodb": "192.168.3.207:27092",
 	"dbsize": 12,
-	"dbname": "mixdata",
+	"dbname": "wjh",
 	"dbcoll": "qyxy",
 	"savecoll": "qyxy_std",
+    "uname": "dataAnyWrite",
+    "upwd": "data@dataAnyWrite",
 	"tasktime": 1,
 	"updatetime": 0,
 	"elastic": {
-        "addr": "http://192.168.3.11:9800",
+        "addr": "http://192.168.3.128:9800",
         "index": "qyxy_v1",
         "itype": "qyxy",
         "otherindex": "qyxy_all",

+ 7 - 6
qyxy/src/main.go

@@ -1,15 +1,14 @@
 package main
 
 import (
-	//mgoutil "mgoutil/mongodb"
-	mgoutil "mongodb"
+	"mongodb"
 	qu "qfw/util"
 	es "qfw/util/elastic"
 )
 
 var (
 	Sysconfig        map[string]interface{} //配置文件
-	Mgo              *mgoutil.MongodbSim
+	Mgo              *mongodb.MongodbSim
 	Dbname           string
 	Dbcoll           string
 	Savecoll         string
@@ -39,10 +38,12 @@ func init() {
 	Dbname = Sysconfig["dbname"].(string)
 	Dbcoll = Sysconfig["dbcoll"].(string)
 	Savecoll = Sysconfig["savecoll"].(string)
-	Mgo = &mgoutil.MongodbSim{
+	Mgo = &mongodb.MongodbSim{
 		MongodbAddr: Sysconfig["mgodb"].(string),
 		Size:        qu.IntAllDef(Sysconfig["dbsize"], 5),
 		DbName:      Dbname,
+		//UserName: 	 Sysconfig["uname"].(string),
+		//Password: 	 Sysconfig["upwd"].(string),
 	}
 	Mgo.InitPool()
 	//es
@@ -70,9 +71,9 @@ func init() {
 }
 
 func main() {
-	go TimeTask()
+	//go TimeTask()
 	//QyxyStandard()
-	//HistoryQyxyStandard()
+	HistoryQyxyStandard()
 	ch := make(chan bool, 1)
 	<-ch
 }

+ 0 - 16
qyxy/src/mgoutil/go.mongodb.org/mongo-driver/.errcheck-excludes

@@ -1,16 +0,0 @@
-(go.mongodb.org/mongo-driver/x/mongo/driver.Connection).Close
-(*go.mongodb.org/mongo-driver/x/network/connection.connection).Close
-(go.mongodb.org/mongo-driver/x/network/connection.Connection).Close
-(*go.mongodb.org/mongo-driver/x/mongo/driver/topology.connection).close
-(*go.mongodb.org/mongo-driver/x/mongo/driver/topology.Topology).Unsubscribe
-(*go.mongodb.org/mongo-driver/x/mongo/driver/topology.Server).Close
-(*go.mongodb.org/mongo-driver/x/network/connection.pool).closeConnection
-(*go.mongodb.org/mongo-driver/x/mongo/driver/topology.pool).close
-(go.mongodb.org/mongo-driver/x/network/wiremessage.ReadWriteCloser).Close
-(*go.mongodb.org/mongo-driver/mongo.Cursor).Close
-(*go.mongodb.org/mongo-driver/mongo.ChangeStream).Close
-(*go.mongodb.org/mongo-driver/mongo.Client).Disconnect
-(net.Conn).Close
-encoding/pem.Encode
-fmt.Fprintf
-fmt.Fprint

+ 0 - 911
qyxy/src/mgoutil/go.mongodb.org/mongo-driver/.evergreen/config.yml

@@ -1,911 +0,0 @@
-########################################
-# Evergreen Template for MongoDB Drivers
-########################################
-
-# When a task that used to pass starts to fail
-# Go through all versions that may have been skipped to detect
-# when the task started failing
-stepback: true
-
-# Mark a failure as a system/bootstrap failure (purple box) rather then a task
-# failure by default.
-# Actual testing tasks are marked with `type: test`
-command_type: setup
-
-# Protect ourself against rogue test case, or curl gone wild, that runs forever
-# 12 minutes is the longest we'll ever run
-exec_timeout_secs: 3600 # 12 minutes is the longest we'll ever run
-
-# What to do when evergreen hits the timeout (`post:` tasks are run automatically)
-timeout:
-  - command: shell.exec
-    params:
-      script: |
-        ls -la
-functions:
-
-  fetch-source:
-    # Executes git clone and applies the submitted patch, if any
-    - command: git.get_project
-      type: system
-      params:
-        directory: src/go.mongodb.org/mongo-driver
-    # Make an evergreen expansion file with dynamic values
-    - command: shell.exec
-      params:
-        working_dir: src/go.mongodb.org/mongo-driver
-        script: |
-           if [ "Windows_NT" = "$OS" ]; then
-              export GOPATH=$(cygpath -w $(dirname $(dirname $(dirname `pwd`))))
-           else
-              export GOPATH=$(dirname $(dirname $(dirname `pwd`)))
-           fi;
-
-           # Get the current unique version of this checkout
-           if [ "${is_patch}" = "true" ]; then
-              CURRENT_VERSION=$(git describe)-patch-${version_id}
-           else
-              CURRENT_VERSION=latest
-           fi
-
-           export DRIVERS_TOOLS="$(pwd)/../drivers-tools"
-           export PROJECT_DIRECTORY="$(pwd)"
-           export GOCACHE="$(pwd)/.cache"
-
-           # Python has cygwin path problems on Windows. Detect prospective mongo-orchestration home directory
-           if [ "Windows_NT" = "$OS" ]; then # Magic variable in cygwin
-              export DRIVERS_TOOLS=$(cygpath -m $DRIVERS_TOOLS)
-              export PROJECT_DIRECTORY=$(cygpath -m $PROJECT_DIRECTORY)
-              export GOCACHE=$(cygpath -m $GOCACHE)
-           fi
-
-           export MONGO_ORCHESTRATION_HOME="$DRIVERS_TOOLS/.evergreen/orchestration"
-           export MONGODB_BINARIES="$DRIVERS_TOOLS/mongodb/bin"
-           export UPLOAD_BUCKET="${project}"
-           export PATH="${GO_DIST}/bin:${GCC_PATH}:$GOPATH/bin:$MONGODB_BINARIES:$PATH"
-           export PROJECT="${project}"
-
-           if [ "Windows_NT" = "$OS" ]; then
-              export USERPROFILE=$(cygpath -w $(dirname $(dirname $(dirname `pwd`))))
-              export HOME=$(cygpath -w $(dirname $(dirname $(dirname `pwd`))))
-           fi
-
-           go version
-           go env
-
-           if [ "Windows_NT" = "$OS" ]; then
-              mkdir -p c:/libmongocrypt/include
-              mkdir -p c:/libmongocrypt/bin
-              curl https://s3.amazonaws.com/mciuploads/libmongocrypt/windows-test/master/latest/libmongocrypt.tar.gz --output libmongocrypt.tar.gz
-              tar -xvzf libmongocrypt.tar.gz
-              cp ./bin/mongocrypt.dll c:/libmongocrypt/bin
-              cp ./include/mongocrypt/*.h c:/libmongocrypt/include
-              export PATH=$PATH:/cygdrive/c/libmongocrypt/bin
-           else
-              git clone https://github.com/mongodb/libmongocrypt
-              ./libmongocrypt/.evergreen/compile.sh
-           fi
-
-           cat <<EOT > expansion.yml
-           CURRENT_VERSION: "$CURRENT_VERSION"
-           DRIVERS_TOOLS: "$DRIVERS_TOOLS"
-           MONGO_ORCHESTRATION_HOME: "$MONGO_ORCHESTRATION_HOME"
-           MONGODB_BINARIES: "$MONGODB_BINARIES"
-           UPLOAD_BUCKET: "$UPLOAD_BUCKET"
-           PROJECT_DIRECTORY: "$PROJECT_DIRECTORY"
-           PREPARE_SHELL: |
-              set -o errexit
-              set -o xtrace
-              export GOPATH="$GOPATH"
-              export GOROOT="${GO_DIST}"
-              export GOCACHE="$GOCACHE"
-              export DRIVERS_TOOLS="$DRIVERS_TOOLS"
-              export MONGO_ORCHESTRATION_HOME="$MONGO_ORCHESTRATION_HOME"
-              export MONGODB_BINARIES="$MONGODB_BINARIES"
-              export UPLOAD_BUCKET="$UPLOAD_BUCKET"
-              export PROJECT_DIRECTORY="$PROJECT_DIRECTORY"
-              export TMPDIR="$MONGO_ORCHESTRATION_HOME/db"
-              export PATH="$PATH"
-              export PROJECT="$PROJECT"
-              export PKG_CONFIG_PATH=$(pwd)/install/libmongocrypt/lib/pkgconfig:$(pwd)/install/mongo-c-driver/lib/pkgconfig
-              export LD_LIBRARY_PATH=$(pwd)/install/libmongocrypt/lib
-           EOT
-           # See what we've done
-           cat expansion.yml
-    # Load the expansion file to make an evergreen variable with the current unique version
-    - command: expansions.update
-      params:
-        file: src/go.mongodb.org/mongo-driver/expansion.yml
-
-
-  prepare-resources:
-    - command: shell.exec
-      params:
-        script: |
-          ${PREPARE_SHELL}
-          rm -rf $DRIVERS_TOOLS
-          if [ "${project}" = "drivers-tools" ]; then
-            # If this was a patch build, doing a fresh clone would not actually test the patch
-            cp -R ${PROJECT_DIRECTORY}/ $DRIVERS_TOOLS
-          else
-            git clone git://github.com/mongodb-labs/drivers-evergreen-tools.git $DRIVERS_TOOLS
-          fi
-          echo "{ \"releases\": { \"default\": \"$MONGODB_BINARIES\" }}" > $MONGO_ORCHESTRATION_HOME/orchestration.config
-    - command: shell.exec
-      params:
-        working_dir: src/go.mongodb.org/mongo-driver
-        script: |
-           ${PREPARE_SHELL}
-           # any go tools that we need
-           go get -u golang.org/x/lint/golint
-           go get -u github.com/kisielk/errcheck
-
-           # initialize submodules
-           git submodule init
-           git submodule update
-
-           # generate any source code
-           make generate
-
-
-  upload-mo-artifacts:
-    - command: shell.exec
-      params:
-        script: |
-          ${PREPARE_SHELL}
-          find $MONGO_ORCHESTRATION_HOME -name \*.log | xargs tar czf mongodb-logs.tar.gz
-    - command: s3.put
-      params:
-        aws_key: ${aws_key}
-        aws_secret: ${aws_secret}
-        local_file: mongodb-logs.tar.gz
-        remote_file: ${UPLOAD_BUCKET}/${build_variant}/${revision}/${version_id}/${build_id}/logs/${task_id}-${execution}-mongodb-logs.tar.gz
-        bucket: mciuploads
-        permissions: public-read
-        content_type: ${content_type|application/x-gzip}
-        display_name: "mongodb-logs.tar.gz"
-
-  bootstrap-mongo-orchestration:
-    - command: shell.exec
-      params:
-        script: |
-          ${PREPARE_SHELL}
-
-          cp ${PROJECT_DIRECTORY}/data/certificates/server.pem ${DRIVERS_TOOLS}/.evergreen/x509gen/server.pem
-          cp ${PROJECT_DIRECTORY}/data/certificates/ca.pem ${DRIVERS_TOOLS}/.evergreen/x509gen/ca.pem
-          cp ${PROJECT_DIRECTORY}/data/certificates/client.pem ${DRIVERS_TOOLS}/.evergreen/x509gen/client.pem
-          cp ${PROJECT_DIRECTORY}/data/certificates/client.pem ${MONGO_ORCHESTRATION_HOME}/lib/client.pem
-
-          MONGODB_VERSION=${VERSION} AUTH=${AUTH} SSL=${SSL} sh ${DRIVERS_TOOLS}/.evergreen/run-orchestration.sh
-    - command: expansions.update
-      params:
-        file: mo-expansion.yml
-
-
-  cleanup:
-    - command: shell.exec
-      params:
-        script: |
-          ${PREPARE_SHELL}
-          cd "$MONGO_ORCHESTRATION_HOME"
-          # source the mongo-orchestration virtualenv if it exists
-          if [ -f venv/bin/activate ]; then
-            . venv/bin/activate
-          elif [ -f venv/Scripts/activate ]; then
-            . venv/Scripts/activate
-          fi
-          mongo-orchestration stop
-          cd -
-          rm -rf $DRIVERS_TOOLS || true
-
-
-  fix-absolute-paths:
-    - command: shell.exec
-      params:
-        script: |
-          ${PREPARE_SHELL}
-          for filename in $(find ${DRIVERS_TOOLS} -name \*.json); do
-            perl -p -i -e "s|ABSOLUTE_PATH_REPLACEMENT_TOKEN|${DRIVERS_TOOLS}|g" $filename
-          done
-
-
-  windows-fix:
-    - command: shell.exec
-      params:
-        script: |
-          ${PREPARE_SHELL}
-          for i in $(find ${DRIVERS_TOOLS}/.evergreen ${PROJECT_DIRECTORY} -name \*.sh); do
-            cat $i | tr -d '\r' > $i.new
-            mv $i.new $i
-          done
-
-
-  make-files-executable:
-    - command: shell.exec
-      params:
-        script: |
-          ${PREPARE_SHELL}
-          for i in $(find ${DRIVERS_TOOLS}/.evergreen ${PROJECT_DIRECTORY} -name \*.sh); do
-            chmod +x $i
-          done
-
-
-  run-make:
-    - command: shell.exec
-      type: test
-      params:
-        working_dir: src/go.mongodb.org/mongo-driver
-        script: |
-          ${PREPARE_SHELL}
-          ${BUILD_ENV|} make ${targets} BUILD_TAGS="-tags gssapi"
-
-
-  run-tests:
-    - command: shell.exec
-      type: test
-      params:
-        working_dir: src/go.mongodb.org/mongo-driver
-        script: |
-          ${PREPARE_SHELL}
-
-          if [ ${SSL} = "ssl" ]; then
-              export MONGO_GO_DRIVER_CA_FILE="$PROJECT_DIRECTORY/data/certificates/ca.pem"
-
-              if [ "Windows_NT" = "$OS" ]; then # Magic variable in cygwin
-                  export MONGO_GO_DRIVER_CA_FILE=$(cygpath -m $MONGO_GO_DRIVER_CA_FILE)
-              fi
-          fi
-
-          set +o xtrace
-          AUTH=${AUTH} \
-          SSL=${SSL} \
-          MONGODB_URI="${MONGODB_URI}" \
-          MONGO_GO_DRIVER_COMPRESSOR=${MONGO_GO_DRIVER_COMPRESSOR} \
-          BUILD_TAGS="-tags cse" \
-          AWS_ACCESS_KEY_ID="${cse_aws_access_key_id}" \
-          AWS_SECRET_ACCESS_KEY="${cse_aws_secret_access_key}" \
-          make evg-test \
-          PKG_CONFIG_PATH=$PKG_CONFIG_PATH \
-          LD_LIBRARY_PATH=$LD_LIBRARY_PATH
-
-  send-perf-data:
-   - command: json.send
-     params:
-       name: perf
-       file: src/go.mongodb.org/mongo-driver/perf.json
-
-
-  run-enterprise-auth-tests:
-    - command: shell.exec
-      type: test
-      params:
-        silent: true
-        working_dir: src/go.mongodb.org/mongo-driver
-        script: |
-          # DO NOT ECHO WITH XTRACE (which PREPARE_SHELL does)
-          if [ "Windows_NT" = "$OS" ]; then
-            export GOPATH=$(cygpath -w $(dirname $(dirname $(dirname `pwd`))))
-            export GOCACHE=$(cygpath -w "$(pwd)/.cache")
-          else
-            export GOPATH=$(dirname $(dirname $(dirname `pwd`)))
-            export GOCACHE="$(pwd)/.cache"
-          fi;
-          export GOPATH="$GOPATH"
-          export GOROOT="${GO_DIST}"
-          export GOCACHE="$GOCACHE"
-          export PATH="${GCC_PATH}:${GO_DIST}/bin:$PATH"
-          MONGODB_URI="${MONGODB_URI}" MONGO_GO_DRIVER_COMPRESSOR="${MONGO_GO_DRIVER_COMPRESSOR}" make -s evg-test-auth
-
-  run-enterprise-gssapi-auth-tests:
-    - command: shell.exec
-      type: test
-      params:
-        working_dir: src/go.mongodb.org/mongo-driver
-        script: |
-          # DO NOT ECHO WITH XTRACE (which PREPARE_SHELL does)
-          if [ "Windows_NT" = "$OS" ]; then
-            export GOPATH=$(cygpath -w $(dirname $(dirname $(dirname `pwd`))))
-            export GOCACHE=$(cygpath -w "$(pwd)/.cache")
-            export MONGODB_URI=${gssapi_auth_windows_mongodb_uri}
-          else
-            export GOPATH=$(dirname $(dirname $(dirname `pwd`)))
-            export GOCACHE="$(pwd)/.cache"
-            echo "${gssapi_auth_linux_keytab_base64}" > /tmp/drivers.keytab.base64
-            base64 --decode /tmp/drivers.keytab.base64 > ${PROJECT_DIRECTORY}/.evergreen/drivers.keytab
-            mkdir -p ~/.krb5
-            cat .evergreen/krb5.config | tee -a ~/.krb5/config
-            kinit -k -t ${PROJECT_DIRECTORY}/.evergreen/drivers.keytab -p "${gssapi_auth_username}"
-            export MONGODB_URI="${gssapi_auth_linux_mongodb_uri}"
-          fi;
-          export GOPATH="$GOPATH"
-          export GOROOT="${GO_DIST}"
-          export GOCACHE="$GOCACHE"
-          export PATH="${GCC_PATH}:${GO_DIST}/bin:$PATH"
-          MONGO_GO_DRIVER_COMPRESSOR="${MONGO_GO_DRIVER_COMPRESSOR}" make -s evg-test-auth
-
-  run-enterprise-gssapi-service-host-auth-tests:
-    - command: shell.exec
-      type: test
-      params:
-        working_dir: src/go.mongodb.org/mongo-driver
-        script: |
-          # DO NOT ECHO WITH XTRACE (which PREPARE_SHELL does)
-          if [ "Windows_NT" = "$OS" ]; then
-            export GOPATH=$(cygpath -w $(dirname $(dirname $(dirname `pwd`))))
-            export GOCACHE=$(cygpath -w "$(pwd)/.cache")
-            export MONGODB_URI="${gssapi_service_host_auth_windows_mongodb_uri}"
-          else
-            export GOPATH=$(dirname $(dirname $(dirname `pwd`)))
-            export GOCACHE="$(pwd)/.cache"
-            echo "${gssapi_auth_linux_keytab_base64}" > /tmp/drivers.keytab.base64
-            base64 --decode /tmp/drivers.keytab.base64 > ${PROJECT_DIRECTORY}/.evergreen/drivers.keytab
-            mkdir -p ~/.krb5
-            cat .evergreen/krb5.config | tee -a ~/.krb5/config
-            kinit -k -t ${PROJECT_DIRECTORY}/.evergreen/drivers.keytab -p "${gssapi_auth_username}"
-            export MONGODB_URI="${gssapi_service_host_auth_linux_mongodb_uri}"
-          fi;
-          export GOPATH="$GOPATH"
-          export GOROOT="${GO_DIST}"
-          export GOCACHE="$GOCACHE"
-          export PATH="${GCC_PATH}:${GO_DIST}/bin:$PATH"
-          MONGO_GO_DRIVER_COMPRESSOR="${MONGO_GO_DRIVER_COMPRESSOR}" make -s evg-test-auth
-
-  run-atlas-test:
-    - command: shell.exec
-      type: test
-      params:
-        working_dir: src/go.mongodb.org/mongo-driver
-        script: |
-          # DO NOT ECHO WITH XTRACE (which PREPARE_SHELL does)
-          if [ "Windows_NT" = "$OS" ]; then
-            export GOPATH=$(cygpath -w $(dirname $(dirname $(dirname `pwd`))))
-            export GOCACHE=$(cygpath -w "$(pwd)/.cache")
-          else
-            export GOPATH=$(dirname $(dirname $(dirname `pwd`)))
-            export GOCACHE="$(pwd)/.cache"
-          fi;
-          export GOPATH="$GOPATH"
-          export GOROOT="${GO_DIST}"
-          export GOCACHE="$GOCACHE"
-          export PATH="${GCC_PATH}:${GO_DIST}/bin:$PATH"
-          export ATLAS_FREE="${atlas_free_tier_uri}"
-          export ATLAS_REPLSET="${atlas_replica_set_uri}"
-          export ATLAS_SHARD="${atlas_sharded_uri}"
-          export ATLAS_TLS11="${atlas_tls_v11_uri}"
-          export ATLAS_TLS12="${atlas_tls_v12_uri}"
-          export ATLAS_FREE_SRV="${atlas_free_tier_uri_srv}"
-          export ATLAS_REPLSET_SRV="${atlas_replica_set_uri_srv}"
-          export ATLAS_SHARD_SRV="${atlas_sharded_uri_srv}"
-          export ATLAS_TLS11_SRV="${atlas_tls_v11_uri_srv}"
-          export ATLAS_TLS12_SRV="${atlas_tls_v12_uri_srv}"
-          make -s evg-test-atlas
-
-
-pre:
-  - func: fetch-source
-  - func: prepare-resources
-  - func: windows-fix
-  - func: fix-absolute-paths
-  - func: make-files-executable
-
-post:
-  - command: gotest.parse_files
-    params:
-      files:
-        - "src/go.mongodb.org/mongo-driver/*.suite"
-  - func: upload-mo-artifacts
-  - func: cleanup
-
-tasks:
-    - name: sa-fmt
-      tags: ["static-analysis"]
-      commands:
-        - func: run-make
-          vars:
-            targets: check-fmt
-
-    - name: sa-errcheck
-      tags: ["static-analysis"]
-      commands:
-        - func: run-make
-          vars:
-            targets: errcheck
-
-
-    - name: sa-lint
-      tags: ["static-analysis"]
-      commands:
-        - func: run-make
-          vars:
-            targets: lint
-
-    - name: sa-vet
-      tags: ["static-analysis"]
-      commands:
-        - func: run-make
-          vars:
-            targets: vet
-
-    - name: perf
-      tags: ["performance"]
-      exec_timeout_secs: 7200
-      commands:
-        - func: bootstrap-mongo-orchestration
-          vars:
-            AUTH: "noauth"
-            SSL: "nossl"
-        - func: run-make
-          vars:
-            targets: driver-benchmark
-        - func: send-perf-data
-
-    - name: sa-build-examples
-      tags: ["static-analysis"]
-      commands:
-        - func: run-make
-          vars:
-            targets: build-examples
-
-    - name: test-standalone-noauth-nossl
-      tags: ["test", "standalone"]
-      commands:
-        - func: bootstrap-mongo-orchestration
-          vars:
-            AUTH: "noauth"
-            SSL: "nossl"
-        - func: run-tests
-          vars:
-            AUTH: "noauth"
-            SSL: "nossl"
-
-    - name: test-standalone-noauth-nossl-snappy-compression
-      tags: ["test", "standalone", "compression", "snappy"]
-      commands:
-        - func: bootstrap-mongo-orchestration
-          vars:
-            AUTH: "noauth"
-            SSL: "nossl"
-        - func: run-tests
-          vars:
-            AUTH: "noauth"
-            SSL: "nossl"
-            MONGO_GO_DRIVER_COMPRESSOR: "snappy"
-
-    - name: test-standalone-noauth-nossl-zlib-compression
-      tags: ["test", "standalone", "compression", "zlib"]
-      commands:
-        - func: bootstrap-mongo-orchestration
-          vars:
-            AUTH: "noauth"
-            SSL: "nossl"
-        - func: run-tests
-          vars:
-            AUTH: "noauth"
-            SSL: "nossl"
-            MONGO_GO_DRIVER_COMPRESSOR: "zlib"
-
-    - name: test-standalone-noauth-nossl-zstd-compression
-      tags: ["test", "standalone", "compression", "zstd"]
-      commands:
-        - func: bootstrap-mongo-orchestration
-          vars:
-            AUTH: "noauth"
-            SSL: "nossl"
-        - func: run-tests
-          vars:
-            AUTH: "noauth"
-            SSL: "nossl"
-            MONGO_GO_DRIVER_COMPRESSOR: "zstd"
-
-    - name: test-standalone-auth-ssl
-      tags: ["test", "standalone", "authssl"]
-      commands:
-        - func: bootstrap-mongo-orchestration
-          vars:
-            AUTH: "auth"
-            SSL: "ssl"
-        - func: run-tests
-          vars:
-            AUTH: "auth"
-            SSL: "ssl"
-
-    - name: test-standalone-auth-ssl-snappy-compression
-      tags: ["test", "standalone", "authssl", "compression", "snappy"]
-      commands:
-        - func: bootstrap-mongo-orchestration
-          vars:
-            AUTH: "auth"
-            SSL: "ssl"
-        - func: run-tests
-          vars:
-            AUTH: "auth"
-            SSL: "ssl"
-            MONGO_GO_DRIVER_COMPRESSOR: "snappy"
-
-    - name: test-standalone-auth-ssl-zlib-compression
-      tags: ["test", "standalone", "authssl", "compression", "zlib"]
-      commands:
-        - func: bootstrap-mongo-orchestration
-          vars:
-            AUTH: "auth"
-            SSL: "ssl"
-        - func: run-tests
-          vars:
-            AUTH: "auth"
-            SSL: "ssl"
-            MONGO_GO_DRIVER_COMPRESSOR: "zlib"
-
-    - name: test-standalone-auth-ssl-zstd-compression
-      tags: ["test", "standalone", "authssl", "compression", "zstd"]
-      commands:
-        - func: bootstrap-mongo-orchestration
-          vars:
-            AUTH: "auth"
-            SSL: "ssl"
-        - func: run-tests
-          vars:
-            AUTH: "auth"
-            SSL: "ssl"
-            MONGO_GO_DRIVER_COMPRESSOR: "zstd"
-
-    - name: test-replicaset-noauth-nossl
-      tags: ["test", "replicaset"]
-      commands:
-        - func: bootstrap-mongo-orchestration
-          vars:
-            AUTH: "noauth"
-            SSL: "nossl"
-        - func: run-tests
-          vars:
-            AUTH: "noauth"
-            SSL: "nossl"
-
-    - name: test-replicaset-auth-ssl
-      tags: ["test", "replicaset", "authssl"]
-      commands:
-        - func: bootstrap-mongo-orchestration
-          vars:
-            AUTH: "auth"
-            SSL: "ssl"
-        - func: run-tests
-          vars:
-            AUTH: "auth"
-            SSL: "ssl"
-
-    - name: test-sharded-noauth-nossl
-      tags: ["test", "sharded"]
-      commands:
-        - func: bootstrap-mongo-orchestration
-          vars:
-            AUTH: "noauth"
-            SSL: "nossl"
-        - func: run-tests
-          vars:
-            AUTH: "noauth"
-            SSL: "nossl"
-
-    - name: test-sharded-noauth-nossl-snappy-compression
-      tags: ["test", "sharded", "compression", "snappy"]
-      commands:
-        - func: bootstrap-mongo-orchestration
-          vars:
-            AUTH: "noauth"
-            SSL: "nossl"
-        - func: run-tests
-          vars:
-            AUTH: "noauth"
-            SSL: "nossl"
-            MONGO_GO_DRIVER_COMPRESSOR: "snappy"
-
-    - name: test-sharded-noauth-nossl-zlib-compression
-      tags: ["test", "sharded", "compression", "zlib"]
-      commands:
-        - func: bootstrap-mongo-orchestration
-          vars:
-            AUTH: "noauth"
-            SSL: "nossl"
-        - func: run-tests
-          vars:
-            AUTH: "noauth"
-            SSL: "nossl"
-            MONGO_GO_DRIVER_COMPRESSOR: "zlib"
-
-    - name: test-sharded-noauth-nossl-zstd-compression
-      tags: ["test", "sharded", "compression", "zstd"]
-      commands:
-        - func: bootstrap-mongo-orchestration
-          vars:
-            AUTH: "noauth"
-            SSL: "nossl"
-        - func: run-tests
-          vars:
-            AUTH: "noauth"
-            SSL: "nossl"
-            MONGO_GO_DRIVER_COMPRESSOR: "zstd"
-
-    - name: test-sharded-auth-ssl
-      tags: ["test", "sharded", "authssl"]
-      commands:
-        - func: bootstrap-mongo-orchestration
-          vars:
-            AUTH: "auth"
-            SSL: "ssl"
-        - func: run-tests
-          vars:
-            AUTH: "auth"
-            SSL: "ssl"
-
-    - name: test-sharded-auth-ssl-snappy-compression
-      tags: ["test", "sharded", "authssl", "compression", "snappy"]
-      commands:
-        - func: bootstrap-mongo-orchestration
-          vars:
-            AUTH: "auth"
-            SSL: "ssl"
-        - func: run-tests
-          vars:
-            AUTH: "auth"
-            SSL: "ssl"
-            MONGO_GO_DRIVER_COMPRESSOR: "snappy"
-
-    - name: test-sharded-auth-ssl-zlib-compression
-      tags: ["test", "sharded", "authssl", "compression", "zlib"]
-      commands:
-        - func: bootstrap-mongo-orchestration
-          vars:
-            AUTH: "auth"
-            SSL: "ssl"
-        - func: run-tests
-          vars:
-            AUTH: "auth"
-            SSL: "ssl"
-            MONGO_GO_DRIVER_COMPRESSOR: "zlib"
-
-    - name: test-sharded-auth-ssl-zstd-compression
-      tags: ["test", "sharded", "authssl", "compression", "zstd"]
-      commands:
-        - func: bootstrap-mongo-orchestration
-          vars:
-            AUTH: "auth"
-            SSL: "ssl"
-        - func: run-tests
-          vars:
-            AUTH: "auth"
-            SSL: "ssl"
-            MONGO_GO_DRIVER_COMPRESSOR: "zstd"
-
-    - name: test-enterprise-auth-plain
-      tags: ["test", "enterprise-auth"]
-      commands:
-        - func: run-enterprise-auth-tests
-          vars:
-            MONGODB_URI: "${plain_auth_mongodb_uri}"
-
-    - name: test-enterprise-auth-gssapi
-      tags: ["test", "enterprise-auth"]
-      commands:
-        - func: run-enterprise-gssapi-auth-tests
-
-    - name: test-enterprise-auth-gssapi-service-host
-      tags: ["test", "enterprise-auth"]
-      commands:
-        - func: run-enterprise-gssapi-service-host-auth-tests
-          vars:
-            MONGO_GO_DRIVER_COMPRESSOR: "snappy"
-
-    - name: go1.9-build
-      tags: ["compile-check"]
-      commands:
-        - func: run-make
-          vars:
-            targets: "build"
-            BUILD_ENV: "PATH=/opt/golang/go1.9/bin:$PATH GOROOT=/opt/golang/go1.9"
-
-    - name: go1.9-build-nocgo
-      tags: ["compile-check"]
-      commands:
-        - func: run-make
-          vars:
-            targets: "build"
-            BUILD_ENV: "CGO_ENABLED=0 PATH=/opt/golang/go1.9/bin:$PATH GOROOT=/opt/golang/go1.9"
-
-    - name: go1.10-build
-      tags: ["compile-check"]
-      commands:
-        - func: run-make
-          vars:
-            targets: "build"
-            BUILD_ENV: "PATH=/opt/golang/go1.10/bin:$PATH GOROOT=/opt/golang/go1.10"
-
-    - name: go1.10-build-nocgo
-      tags: ["compile-check"]
-      commands:
-        - func: run-make
-          vars:
-            targets: "build"
-            BUILD_ENV: "CGO_ENABLED=0 PATH=/opt/golang/go1.10/bin:$PATH GOROOT=/opt/golang/go1.10"
-
-    - name: linux-32-bit
-      tags: ["compile-check"]
-      commands:
-        - func: run-make
-          vars:
-            targets: "build"
-            BUILD_ENV: "GOARCH=386"
-
-    - name: linux-arm64
-      tags: ["compile-check"]
-      commands:
-        - func: run-make
-          vars:
-            targets: "build"
-            BUILD_ENV: "GOARCH=arm64"
-
-    - name: linux-s390x
-      tags: ["compile-check"]
-      commands:
-        - func: run-make
-          vars:
-            targets: "build"
-            BUILD_ENV: "GOARCH=ppc64le"
-
-    - name: "atlas-test"
-      commands:
-        - func: "run-atlas-test"
-
-    - name: go1.10-build-cse
-      tags: ["compile-check"]
-      commands:
-        - func: run-make
-          vars:
-            targets: "build-cse"
-            BUILD_ENV: "PATH=/opt/golang/go1.10/bin:$PATH GOROOT=/opt/golang/go1.10"
-
-axes:
-  - id: version
-    display_name: MongoDB Version
-    values:
-      - id: "4.2"
-        display_name: "4.2"
-        variables:
-          VERSION: "4.2"
-      - id: "4.0"
-        display_name: "4.0"
-        variables:
-           VERSION: "4.0"
-      - id: "3.6"
-        display_name: "3.6"
-        variables:
-           VERSION: "3.6"
-      - id: "3.4"
-        display_name: "3.4"
-        variables:
-           VERSION: "3.4"
-      - id: "3.2"
-        display_name: "3.2"
-        variables:
-           VERSION: "3.2"
-      - id: "3.0"
-        display_name: "3.0"
-        variables:
-          VERSION: "3.0"
-      - id: "2.6"
-        display_name: "2.6"
-        variables:
-          VERSION: "2.6"
-      - id: "latest"
-        display_name: "latest"
-        variables:
-           VERSION: "latest"
-
-  # OSes that support versions of MongoDB >= 2.6 with SSL.
-  - id: os-ssl-legacy
-    display_name: OS
-    values:
-      - id: "ubuntu1404-go-1-12"
-        display_name: "Ubuntu 14.04"
-        run_on: ubuntu1404-test
-        variables:
-          GO_DIST: "/opt/golang/go1.12"
-
-  # OSes that require >= 3.2 for SSL
-  - id: os-ssl-32
-    display_name: OS
-    values:
-      - id: "windows-64-go-1-12"
-        display_name: "Windows 64-bit"
-        run_on:
-          - windows-64-vs2015-test
-        variables:
-          GCC_PATH: "/cygdrive/c/mingw-w64/x86_64-4.9.1-posix-seh-rt_v3-rev1/mingw64/bin"
-          GO_DIST: "C:\\golang\\go1.12"
-      - id: "ubuntu1604-64-go-1-12"
-        display_name: "Ubuntu 16.04"
-        run_on: ubuntu1604-build
-        variables:
-          GO_DIST: "/opt/golang/go1.12"
-      - id: "osx-go-1-12"
-        display_name: "MacOS 10.14"
-        run_on: macos-1014
-        variables:
-          GO_DIST: "/opt/golang/go1.12"
-
-
-buildvariants:
-- name: static-analysis
-  display_name: "Static Analysis"
-  run_on:
-    - ubuntu1604-build
-  expansions:
-    GO_DIST: "/opt/golang/go1.12"
-  tasks:
-    - name: ".static-analysis"
-
-- name: perf
-  display_name: "Performance"
-  run_on:
-    - ubuntu1604-build
-  expansions:
-    GO_DIST: "/opt/golang/go1.12"
-  tasks:
-    - name: ".performance"
-
-- name: build-check
-  display_name: "Compile Only Checks"
-  run_on:
-    - ubuntu1604-test
-  expansions:
-    GO_DIST: "/opt/golang/go1.12"
-  tasks:
-    - name: ".compile-check"
-
-- name: atlas-test
-  display_name: "Atlas test"
-  run_on:
-    - ubuntu1604-build
-  expansions:
-    GO_DIST: "/opt/golang/go1.12"
-  tasks:
-    - name: "atlas-test"
-
-- matrix_name: "tests-legacy-auth-ssl"
-  matrix_spec: { version: ["2.6", "3.0"], os-ssl-legacy: "*" }
-  display_name: "${version} ${os-ssl-legacy}"
-  tasks:
-    - name: ".test !.enterprise-auth !.compression"
-
-- matrix_name: "tests-legacy-noauth-nossl"
-  matrix_spec: { version: ["2.6", "3.0"], os-ssl-32: "*" }
-  display_name: "${version} ${os-ssl-32}"
-  tasks:
-    - name: ".test !.authssl !.enterprise-auth !.compression"
-
-- matrix_name: "tests-nonlegacy-servers"
-  matrix_spec: { version: "3.2", os-ssl-32: "*" }
-  display_name: "${version} ${os-ssl-32}"
-  tasks:
-    - name: ".test !.enterprise-auth !.compression"
-
-- matrix_name: "tests-nonlegacy-servers-with-snappy-support"
-  matrix_spec: { version: "3.4", os-ssl-32: "*" }
-  display_name: "${version} ${os-ssl-32}"
-  tasks:
-    - name: ".test !.enterprise-auth !.zlib !.zstd"
-
-- matrix_name: "tests-36-40-with-zlib-support"
-  matrix_spec: { version: ["3.6", "4.0"], os-ssl-32: "*" }
-  display_name: "${version} ${os-ssl-32}"
-  tasks:
-    - name: ".test !.enterprise-auth !.snappy !.zstd"
-
-- matrix_name: "tests-42-lts-zlib-zstd-support"
-  matrix_spec: { version: ["4.2", "latest"], os-ssl-32: "*" }
-  display_name: "${version} ${os-ssl-32}"
-  tasks:
-    - name: ".test !.enterprise-auth !.snappy"
-
-- matrix_name: "enterprise-auth-tests"
-  matrix_spec: { os-ssl-32: "*" }
-  display_name: "Enterprise Auth - ${os-ssl-32}"
-  tasks:
-     - name: ".test .enterprise-auth"

+ 0 - 8
qyxy/src/mgoutil/go.mongodb.org/mongo-driver/.evergreen/krb5.config

@@ -1,8 +0,0 @@
-[realms]
-  LDAPTEST.10GEN.CC = {
-    kdc = ldaptest.10gen.cc
-    admin_server = ldaptest.10gen.cc
-  }
-
-[libdefaults]
-  rdns = false

+ 0 - 12
qyxy/src/mgoutil/go.mongodb.org/mongo-driver/.gitignore

@@ -1,12 +0,0 @@
-.vscode
-debug
-.idea
-*.iml
-*.ipr
-*.iws
-.idea
-*.sublime-project
-*.sublime-workspace
-driver-test-data.tar.gz
-perf
-**mongocryptd.pid

+ 0 - 3
qyxy/src/mgoutil/go.mongodb.org/mongo-driver/.gitmodules

@@ -1,3 +0,0 @@
-[submodule "specifications"]
-	path = specifications
-	url = git@github.com:mongodb/specifications.git

+ 0 - 64
qyxy/src/mgoutil/go.mongodb.org/mongo-driver/.lint-whitelist

@@ -1,64 +0,0 @@
-bson/bson.go:103:5: error var SetZero should have name of the form ErrFoo
-bson/bson.go:187:6: type ObjectId should be ObjectID
-bson/bson.go:192:6: func ObjectIdHex should be ObjectIDHex
-bson/bson.go:202:6: func IsObjectIdHex should be IsObjectIDHex
-bson/bson.go:249:6: func NewObjectId should be NewObjectID
-bson/bson.go:273:6: func NewObjectIdWithTime should be NewObjectIDWithTime
-bson/bson.go:470:2: struct field Id should be ID
-bson/bson.go:587:21: error strings should not be capitalized or end with punctuation or a newline
-bson/bson.go:589:21: error strings should not be capitalized or end with punctuation or a newline
-bson/bson.go:613:21: error strings should not be capitalized or end with punctuation or a newline
-bson/bson.go:615:21: error strings should not be capitalized or end with punctuation or a newline
-bson/encode.go:46:2: var typeObjectId should be typeObjectID
-bson/internal/json/stream_test.go:196:3: struct field Id should be ID
-bson/internal/json/stream_test.go:221:3: struct field Id should be ID
-bson/internal/json/stream_test.go:285:22: should omit type []tokenStreamCase from declaration of var tokenStreamCases; it will be inferred from the right-hand side
-bson/internal/testutil/close_helper.go:14:1: exported function CloseReadOnlyFile should have comment or be unexported
-bson/internal/testutil/close_helper.go:8:1: exported function CloseOrError should have comment or be unexported
-bson/json.go:246:6: func jdecObjectId should be jdecObjectID
-bson/json.go:263:6: func jencObjectId should be jencObjectID
-mongo/internal/testutil/helpers/helpers.go:10:1: exported function RequireNoErrorOnClose should have comment or be unexported
-mongo/internal/testutil/helpers/helpers.go:14:1: exported function FindJSONFilesInDir should have comment or be unexported
-mongo/internal/testutil/helpers/helpers.go:45:1: exported function VerifyConnStringOptions should have comment or be unexported
-mongo/options/find_and_modify.go:19:1: exported function CopyFindOneAndReplaceOptions should have comment or be unexported
-mongo/options/find_and_modify.go:29:1: exported function CopyFindOneAndUpdateOptions should have comment or be unexported
-mongo/options/find_and_modify.go:9:1: exported function CopyFindOneAndDeleteOptions should have comment or be unexported
-mongo/options.go:157:1: exported function OplogReplay should have comment or be unexported
-mongo/options.go:177:56: exported func ReadPreference returns unexported type *mongo.optReadPreference, which can be annoying to use
-bson/internal/jsonparser/bytes.go:9:10: should omit type bool from declaration of var neg; it will be inferred from the right-hand side
-bson/internal/jsonparser/bytes.go:25:9: if block ends with a return statement, so drop this else and outdent its block
-bson/internal/jsonparser/escape.go:113:10: if block ends with a return statement, so drop this else and outdent its block (move short variable declaration to its own line if necessary)
-bson/internal/jsonparser/escape.go:123:1: comment on exported function Unescape should be of the form "Unescape ..."
-bson/internal/jsonparser/parser.go:14:2: error var KeyPathNotFoundError should have name of the form ErrFoo
-bson/internal/jsonparser/parser.go:15:2: error var UnknownValueTypeError should have name of the form ErrFoo
-bson/internal/jsonparser/parser.go:16:2: error var MalformedJsonError should have name of the form ErrFoo
-bson/internal/jsonparser/parser.go:16:2: var MalformedJsonError should be MalformedJSONError
-bson/internal/jsonparser/parser.go:17:2: error var MalformedStringError should have name of the form ErrFoo
-bson/internal/jsonparser/parser.go:18:2: error var MalformedArrayError should have name of the form ErrFoo
-bson/internal/jsonparser/parser.go:19:2: error var MalformedObjectError should have name of the form ErrFoo
-bson/internal/jsonparser/parser.go:20:2: error var MalformedValueError should have name of the form ErrFoo
-bson/internal/jsonparser/parser.go:21:2: error var MalformedStringEscapeError should have name of the form ErrFoo
-bson/internal/jsonparser/parser.go:147:11: if block ends with a return statement, so drop this else and outdent its block
-bson/internal/jsonparser/parser.go:285:6: should replace curIdx += 1 with curIdx++
-bson/internal/jsonparser/parser.go:292:12: if block ends with a return statement, so drop this else and outdent its block
-bson/internal/jsonparser/parser.go:303:12: if block ends with a return statement, so drop this else and outdent its block (move short variable declaration to its own line if necessary)
-bson/internal/jsonparser/parser.go:329:6: don't use underscores in Go names; range var pi_1 should be pi1
-bson/internal/jsonparser/parser.go:329:12: don't use underscores in Go names; range var p_1 should be p1
-bson/internal/jsonparser/parser.go:338:1: exported function EachKey should have comment or be unexported
-bson/internal/jsonparser/parser.go:489:6: should replace curIdx += 1 with curIdx++
-bson/internal/jsonparser/parser.go:503:12: if block ends with a return statement, so drop this else and outdent its block (move short variable declaration to its own line if necessary)
-bson/internal/jsonparser/parser.go:517:1: comment on exported type ValueType should be of the form "ValueType ..." (with optional leading article)
-bson/internal/jsonparser/parser.go:521:2: exported const NotExist should have comment (or a comment on this block) or be unexported
-bson/internal/jsonparser/parser.go:582:1: comment on exported function Delete should be of the form "Delete ..."
-bson/internal/jsonparser/parser.go:931:10: if block ends with a return statement, so drop this else and outdent its block (move short variable declaration to its own line if necessary)
-bson/internal/jsonparser/parser.go:971:10: if block ends with a return statement, so drop this else and outdent its block (move short variable declaration to its own line if necessary)
-bson/internal/jsonparser/parser.go:980:11: if block ends with a return statement, so drop this else and outdent its block (move short variable declaration to its own line if necessary)
-bson/internal/jsonparser/parser.go:1006:10: if block ends with a return statement, so drop this else and outdent its block (move short variable declaration to its own line if necessary)
-bson/internal/jsonparser/parser.go:1021:10: if block ends with a return statement, so drop this else and outdent its block (move short variable declaration to its own line if necessary)
-bson/internal/jsonparser/parser.go:1128:9: if block ends with a return statement, so drop this else and outdent its block (move short variable declaration to its own line if necessary)
-bson/internal/jsonparser/parser.go:1133:1: comment on exported function ParseFloat should be of the form "ParseFloat ..."
-bson/internal/jsonparser/parser.go:1137:9: if block ends with a return statement, so drop this else and outdent its block (move short variable declaration to its own line if necessary)
-bson/internal/jsonparser/parser.go:1146:9: if block ends with a return statement, so drop this else and outdent its block (move short variable declaration to its own line if necessary)
-bson/internal/jsonparser/parser_test.go:1361:5: var testJson should be testJSON
-bson/internal/jsonpretty/pretty.go:7:1: comment on exported type Options should be of the form "Options ..." (with optional leading article)
-examples/documentation_examples/examples.go:10:1: don't use an underscore in package name

+ 0 - 37
qyxy/src/mgoutil/go.mongodb.org/mongo-driver/CONTRIBUTING.md

@@ -1,37 +0,0 @@
-# Contributing to the MongoDB Go Driver
-
-Thank you for your interest in contributing to the MongoDB Go driver.
-
-We are building this software together and strongly encourage contributions from the community that are within the guidelines set forth
-below.
-
-## Bug Fixes and New Features
-
-Before starting to write code, look for existing [tickets](https://jira.mongodb.org/browse/GODRIVER) or
-[create one](https://jira.mongodb.org/secure/CreateIssue!default.jspa) for your bug, issue, or feature request. This helps the community
-avoid working on something that might not be of interest or which has already been addressed.
-
-## Pull Requests & Patches
-
-The Go Driver team is experimenting with GerritHub for contributions. GerritHub uses GitHub for authentication and uses a patch based
-workflow. Since GerritHub supports importing of Pull Requests we will also accept Pull Requests, but Code Review will be done in
-GerritHub.
-
-Patches should generally be made against the master (default) branch and include relevant tests, if applicable.
-
-Code should compile and tests should pass under all go versions which the driver currently supports.  Currently the driver
-supports a minimum version of go 1.7. Please ensure the following tools have been run on the code: gofmt, golint, errcheck,
-go test (with coverage and with the race detector), and go vet. For convenience, you can run 'make' to run all these tools.
-**By default, running the tests requires that you have a mongod server running on localhost, listening on the default port.**
-At minimum, please test against the latest release version of the MongoDB server.
-
-If any tests do not pass, or relevant tests are not included, the patch will not be considered.
-
-If you are working on a bug or feature listed in Jira, please include the ticket number prefixed with GODRIVER in the commit,
-e.g. GODRIVER-123. For the patch commit message itself, please follow the [How to Write a Git Commit Message](https://chris.beams.io/posts/git-commit/) guide.
-
-## Talk To Us
-
-If you want to work on the driver, write documentation, or have questions/complaints, please reach out to use either via
-the [mongo-go-driver Google Group](https://groups.google.com/forum/#!forum/mongodb-go-driver) or by creating a Question
-issue at (https://jira.mongodb.org/secure/CreateIssue!default.jspa).

+ 0 - 367
qyxy/src/mgoutil/go.mongodb.org/mongo-driver/Gopkg.lock

@@ -1,367 +0,0 @@
-# This file is autogenerated, do not edit; changes may be undone by the next 'dep ensure'.
-
-
-[[projects]]
-  digest = "1:6d8a3b164679872fa5a4c44559235f7fb109c7b5cd0f456a2159d579b76cc9ba"
-  name = "github.com/DataDog/zstd"
-  packages = ["."]
-  pruneopts = "UT"
-  revision = "809b919c325d7887bff7bd876162af73db53e878"
-  version = "v1.4.0"
-
-[[projects]]
-  digest = "1:ffe9824d294da03b391f44e1ae8281281b4afc1bdaa9588c9097785e3af10cec"
-  name = "github.com/davecgh/go-spew"
-  packages = ["spew"]
-  pruneopts = "UT"
-  revision = "8991bc29aa16c548c550c7ff78260e27b9ab7c73"
-  version = "v1.1.1"
-
-[[projects]]
-  digest = "1:586ea76dbd0374d6fb649a91d70d652b7fe0ccffb8910a77468e7702e7901f3d"
-  name = "github.com/go-stack/stack"
-  packages = ["."]
-  pruneopts = "UT"
-  revision = "2fee6af1a9795aafbe0253a0cfbdf668e1fb8a9a"
-  version = "v1.8.0"
-
-[[projects]]
-  digest = "1:d29ee5ef14a7e0253facd0bcebe6a69a7a4e02a67eb24d2aacd8ccb4a7cea6fc"
-  name = "github.com/gobuffalo/envy"
-  packages = ["."]
-  pruneopts = "UT"
-  revision = "043cb4b8af871b49563291e32c66bb84378a60ac"
-  version = "v1.7.0"
-
-[[projects]]
-  digest = "1:149bf2c3b6b332f0cfefed9ae4b8c01c527927d369d7a0f41a211c8bf588b556"
-  name = "github.com/gobuffalo/genny"
-  packages = ["."]
-  pruneopts = "UT"
-  revision = "05dc5921e98daa5d406f90c2844ff163cb1e1c4e"
-  version = "v0.1.1"
-
-[[projects]]
-  digest = "1:3812ee37547a0d26633006c910672c42ddf6f932f79dea6a4446979a561f7d60"
-  name = "github.com/gobuffalo/gogen"
-  packages = [
-    ".",
-    "goimports",
-    "gomods",
-  ]
-  pruneopts = "UT"
-  revision = "5482e6ef5d999f8cfa9b038a53953c9b4ee090af"
-  version = "v0.1.1"
-
-[[projects]]
-  branch = "master"
-  digest = "1:f391538f4166f7c0aa50943372af196304488b039fe663c134d42f064e1ed92c"
-  name = "github.com/gobuffalo/logger"
-  packages = ["."]
-  pruneopts = "UT"
-  revision = "86e12af44bc273e0063fad5b6ad588890b8cfe6b"
-
-[[projects]]
-  digest = "1:a3259d2a6c245b62e40232800e3ebb4d7d5840940638de0e4754cb13cdd37790"
-  name = "github.com/gobuffalo/mapi"
-  packages = ["."]
-  pruneopts = "UT"
-  revision = "0bb5e840be332d4280e40f2e6c50777c615bbac5"
-  version = "v1.0.2"
-
-[[projects]]
-  digest = "1:1342bed0d7aded5e5c1c958675f0662c9dbaf2d61fa0a8c5918a144737cff3e4"
-  name = "github.com/gobuffalo/packd"
-  packages = ["."]
-  pruneopts = "UT"
-  revision = "9efbb667f2024a9370cadda45a57a0657c88a6fb"
-  version = "v0.1.0"
-
-[[projects]]
-  digest = "1:0fac441be66684180b031233313b8315644c0734fd73944c3e156e3cf5fbe203"
-  name = "github.com/gobuffalo/packr"
-  packages = [
-    "v2",
-    "v2/file",
-    "v2/file/resolver",
-    "v2/file/resolver/encoding/hex",
-    "v2/jam/parser",
-    "v2/plog",
-  ]
-  pruneopts = "UT"
-  revision = "cda4ac25577350dac682c8715dc6659327232596"
-  version = "v2.2.0"
-
-[[projects]]
-  branch = "master"
-  digest = "1:b90ac64448d67ef218124185a8524f3c665fb7f51f096d5dd51ce950a1775d89"
-  name = "github.com/gobuffalo/syncx"
-  packages = ["."]
-  pruneopts = "UT"
-  revision = "33c29581e754bd354236e977dfe426e55331c45d"
-
-[[projects]]
-  branch = "master"
-  digest = "1:e4f5819333ac698d294fe04dbf640f84719658d5c7ce195b10060cc37292ce79"
-  name = "github.com/golang/snappy"
-  packages = ["."]
-  pruneopts = "UT"
-  revision = "2a8bb927dd31d8daada140a5d09578521ce5c36a"
-
-[[projects]]
-  digest = "1:d2754cafcab0d22c13541618a8029a70a8959eb3525ff201fe971637e2274cd0"
-  name = "github.com/google/go-cmp"
-  packages = [
-    "cmp",
-    "cmp/cmpopts",
-    "cmp/internal/diff",
-    "cmp/internal/function",
-    "cmp/internal/value",
-  ]
-  pruneopts = "UT"
-  revision = "3af367b6b30c263d47e8895973edcca9a49cf029"
-  version = "v0.2.0"
-
-[[projects]]
-  digest = "1:ecd9aa82687cf31d1585d4ac61d0ba180e42e8a6182b85bd785fcca8dfeefc1b"
-  name = "github.com/joho/godotenv"
-  packages = ["."]
-  pruneopts = "UT"
-  revision = "23d116af351c84513e1946b527c88823e476be13"
-  version = "v1.3.0"
-
-[[projects]]
-  digest = "1:19cce3954c778b676622745e850f7d201eefffbb62d2c42ce87673617f96e95a"
-  name = "github.com/karrick/godirwalk"
-  packages = ["."]
-  pruneopts = "UT"
-  revision = "5e617d9cfec6f870e63b168e9a2fb7c490a1c108"
-  version = "v1.10.3"
-
-[[projects]]
-  digest = "1:31e761d97c76151dde79e9d28964a812c46efc5baee4085b86f68f0c654450de"
-  name = "github.com/konsorten/go-windows-terminal-sequences"
-  packages = ["."]
-  pruneopts = "UT"
-  revision = "f55edac94c9bbba5d6182a4be46d86a2c9b5b50e"
-  version = "v1.0.2"
-
-[[projects]]
-  digest = "1:ca955a9cd5b50b0f43d2cc3aeb35c951473eeca41b34eb67507f1dbcc0542394"
-  name = "github.com/kr/pretty"
-  packages = ["."]
-  pruneopts = "UT"
-  revision = "73f6ac0b30a98e433b289500d779f50c1a6f0712"
-  version = "v0.1.0"
-
-[[projects]]
-  digest = "1:15b5cc79aad436d47019f814fde81a10221c740dc8ddf769221a65097fb6c2e9"
-  name = "github.com/kr/text"
-  packages = ["."]
-  pruneopts = "UT"
-  revision = "e2ffdb16a802fe2bb95e2e35ff34f0e53aeef34f"
-  version = "v0.1.0"
-
-[[projects]]
-  branch = "master"
-  digest = "1:6e2ed1bdbf1d14b4d0be58bcd3f1c3000c1e226964354457b8e6ca69e83a1cbb"
-  name = "github.com/markbates/oncer"
-  packages = ["."]
-  pruneopts = "UT"
-  revision = "bf2de49a0be218916e69a11d22866e6cd0a560f2"
-
-[[projects]]
-  digest = "1:28687e854cec240942c103259668b132a8450b05a6cc677eea2282b26ae29310"
-  name = "github.com/markbates/safe"
-  packages = ["."]
-  pruneopts = "UT"
-  revision = "6fea05a5732486546a4836b7a1d596c5ec687b98"
-  version = "v1.0.1"
-
-[[projects]]
-  digest = "1:246ab598a22ea9d50f46e65f655f78161a19822f6597268b02f04af998684807"
-  name = "github.com/montanaflynn/stats"
-  packages = ["."]
-  pruneopts = "UT"
-  revision = "1bf9dbcd8cbe1fdb75add3785b1d4a9a646269ab"
-  version = "0.3.0"
-
-[[projects]]
-  digest = "1:93131d8002d7025da13582877c32d1fc302486775a1b06f62241741006428c5e"
-  name = "github.com/pelletier/go-toml"
-  packages = ["."]
-  pruneopts = "UT"
-  revision = "728039f679cbcd4f6a54e080d2219a4c4928c546"
-  version = "v1.4.0"
-
-[[projects]]
-  digest = "1:cf31692c14422fa27c83a05292eb5cbe0fb2775972e8f1f8446a71549bd8980b"
-  name = "github.com/pkg/errors"
-  packages = ["."]
-  pruneopts = "UT"
-  revision = "ba968bfe8b2f7e042a574c888954fccecfa385b4"
-  version = "v0.8.1"
-
-[[projects]]
-  digest = "1:0028cb19b2e4c3112225cd871870f2d9cf49b9b4276531f03438a88e94be86fe"
-  name = "github.com/pmezard/go-difflib"
-  packages = ["difflib"]
-  pruneopts = "UT"
-  revision = "792786c7400a136282c1664665ae0a8db921c6c2"
-  version = "v1.0.0"
-
-[[projects]]
-  digest = "1:e09ada96a5a41deda4748b1659cc8953961799e798aea557257b56baee4ecaf3"
-  name = "github.com/rogpeppe/go-internal"
-  packages = [
-    "modfile",
-    "module",
-    "semver",
-  ]
-  pruneopts = "UT"
-  revision = "438578804ca6f31be148c27683afc419ce47c06e"
-  version = "v1.3.0"
-
-[[projects]]
-  digest = "1:04457f9f6f3ffc5fea48e71d62f2ca256637dee0a04d710288e27e05c8b41976"
-  name = "github.com/sirupsen/logrus"
-  packages = ["."]
-  pruneopts = "UT"
-  revision = "839c75faf7f98a33d445d181f3018b5c3409a45e"
-  version = "v1.4.2"
-
-[[projects]]
-  digest = "1:5da8ce674952566deae4dbc23d07c85caafc6cfa815b0b3e03e41979cedb8750"
-  name = "github.com/stretchr/testify"
-  packages = [
-    "assert",
-    "require",
-  ]
-  pruneopts = "UT"
-  revision = "ffdc059bfe9ce6a4e144ba849dbedead332c6053"
-  version = "v1.3.0"
-
-[[projects]]
-  branch = "master"
-  digest = "1:ddfe0a54e5f9b29536a6d7b2defa376f2cb2b6e4234d676d7ff214d5b097cb50"
-  name = "github.com/tidwall/pretty"
-  packages = ["."]
-  pruneopts = "UT"
-  revision = "1166b9ac2b65e46a43d8618d30d1554f4652d49b"
-
-[[projects]]
-  branch = "master"
-  digest = "1:40fdfd6ab85ca32b6935853bbba35935dcb1d796c8135efd85947566c76e662e"
-  name = "github.com/xdg/scram"
-  packages = ["."]
-  pruneopts = "UT"
-  revision = "7eeb5667e42c09cb51bf7b7c28aea8c56767da90"
-
-[[projects]]
-  branch = "master"
-  digest = "1:f5c1d04bc09c644c592b45b9f0bad4030521b1a7d11c7dadbb272d9439fa6e8e"
-  name = "github.com/xdg/stringprep"
-  packages = ["."]
-  pruneopts = "UT"
-  revision = "73f8eece6fdcd902c185bf651de50f3828bed5ed"
-
-[[projects]]
-  branch = "master"
-  digest = "1:35ce874cf16f78a2da908ab28b0277497e36603d289db00d39da5200bc8ace08"
-  name = "golang.org/x/crypto"
-  packages = [
-    "pbkdf2",
-    "ssh/terminal",
-  ]
-  pruneopts = "UT"
-  revision = "20be4c3c3ed52bfccdb2d59a412ee1a936d175a7"
-
-[[projects]]
-  branch = "master"
-  digest = "1:76ee51c3f468493aff39dbacc401e8831fbb765104cbf613b89bef01cf4bad70"
-  name = "golang.org/x/net"
-  packages = ["context"]
-  pruneopts = "UT"
-  revision = "f3200d17e092c607f615320ecaad13d87ad9a2b3"
-
-[[projects]]
-  branch = "master"
-  digest = "1:382bb5a7fb4034db3b6a2d19e5a4a6bcf52f4750530603c01ca18a172fa3089b"
-  name = "golang.org/x/sync"
-  packages = ["semaphore"]
-  pruneopts = "UT"
-  revision = "112230192c580c3556b8cee6403af37a4fc5f28c"
-
-[[projects]]
-  branch = "master"
-  digest = "1:a02364950e8c7394b03f886e57a3f7acfc4fba32ce03c186dd9f36b501d0484b"
-  name = "golang.org/x/sys"
-  packages = [
-    "unix",
-    "windows",
-  ]
-  pruneopts = "UT"
-  revision = "4c3a928424d249a1013e789cf5e458d480bcba16"
-
-[[projects]]
-  digest = "1:1093f2eb4b344996604f7d8b29a16c5b22ab9e1b25652140d3fede39f640d5cd"
-  name = "golang.org/x/text"
-  packages = [
-    "internal/gen",
-    "internal/triegen",
-    "internal/ucd",
-    "transform",
-    "unicode/cldr",
-    "unicode/norm",
-  ]
-  pruneopts = "UT"
-  revision = "342b2e1fbaa52c93f31447ad2c6abc048c63e475"
-  version = "v0.3.2"
-
-[[projects]]
-  branch = "master"
-  digest = "1:7c7aa31cc6bc5c85038e46d8c6541a2fb2332b1687229a5a5a04d7b91cea0efe"
-  name = "golang.org/x/tools"
-  packages = [
-    "go/ast/astutil",
-    "go/gcexportdata",
-    "go/internal/gcimporter",
-    "go/internal/packagesdriver",
-    "go/packages",
-    "go/types/typeutil",
-    "imports",
-    "internal/fastwalk",
-    "internal/gopathwalk",
-    "internal/imports",
-    "internal/module",
-    "internal/semver",
-  ]
-  pruneopts = "UT"
-  revision = "b3315ee88b7da2b23cc6c62484a006958910e841"
-
-[solve-meta]
-  analyzer-name = "dep"
-  analyzer-version = 1
-  input-imports = [
-    "github.com/DataDog/zstd",
-    "github.com/go-stack/stack",
-    "github.com/gobuffalo/packr/v2",
-    "github.com/golang/snappy",
-    "github.com/google/go-cmp/cmp",
-    "github.com/google/go-cmp/cmp/cmpopts",
-    "github.com/kr/pretty",
-    "github.com/montanaflynn/stats",
-    "github.com/pelletier/go-toml",
-    "github.com/pkg/errors",
-    "github.com/stretchr/testify/assert",
-    "github.com/stretchr/testify/require",
-    "github.com/tidwall/pretty",
-    "github.com/xdg/scram",
-    "github.com/xdg/stringprep",
-    "golang.org/x/net/context",
-    "golang.org/x/sync/semaphore",
-    "golang.org/x/tools/go/packages",
-    "golang.org/x/tools/imports",
-  ]
-  solver-name = "gps-cdcl"
-  solver-version = 1

+ 0 - 58
qyxy/src/mgoutil/go.mongodb.org/mongo-driver/Gopkg.toml

@@ -1,58 +0,0 @@
-# Gopkg.toml example
-#
-# Refer to https://golang.github.io/dep/docs/Gopkg.toml.html
-# for detailed Gopkg.toml documentation.
-#
-# required = ["github.com/user/thing/cmd/thing"]
-# ignored = ["github.com/user/project/pkgX", "bitbucket.org/user/project/pkgA/pkgY"]
-#
-# [[constraint]]
-#   name = "github.com/user/project"
-#   version = "1.0.0"
-#
-# [[constraint]]
-#   name = "github.com/user/project2"
-#   branch = "dev"
-#   source = "github.com/myfork/project2"
-#
-# [[override]]
-#   name = "github.com/x/y"
-#   version = "2.4.0"
-#
-# [prune]
-#   non-go = false
-#   go-tests = true
-#   unused-packages = true
-
-
-[[constraint]]
-  name = "github.com/go-stack/stack"
-  version = "1.7.0"
-
-[[constraint]]
-  branch = "master"
-  name = "github.com/golang/snappy"
-
-[[constraint]]
-  name = "github.com/google/go-cmp"
-  version = "0.2.0"
-
-[[constraint]]
-  name = "github.com/montanaflynn/stats"
-  version = "0.3.0"
-
-[[constraint]]
-  branch = "master"
-  name = "github.com/tidwall/pretty"
-
-[[constraint]]
-  branch = "master"
-  name = "github.com/xdg/stringprep"
-
-[prune]
-  go-tests = true
-  unused-packages = true
-
-[[constraint]]
-  name = "github.com/DataDog/zstd"
-  version = "~1.4.0"

+ 0 - 201
qyxy/src/mgoutil/go.mongodb.org/mongo-driver/LICENSE

@@ -1,201 +0,0 @@
-                                 Apache License
-                           Version 2.0, January 2004
-                        http://www.apache.org/licenses/
-
-   TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION
-
-   1. Definitions.
-
-      "License" shall mean the terms and conditions for use, reproduction,
-      and distribution as defined by Sections 1 through 9 of this document.
-
-      "Licensor" shall mean the copyright owner or entity authorized by
-      the copyright owner that is granting the License.
-
-      "Legal Entity" shall mean the union of the acting entity and all
-      other entities that control, are controlled by, or are under common
-      control with that entity. For the purposes of this definition,
-      "control" means (i) the power, direct or indirect, to cause the
-      direction or management of such entity, whether by contract or
-      otherwise, or (ii) ownership of fifty percent (50%) or more of the
-      outstanding shares, or (iii) beneficial ownership of such entity.
-
-      "You" (or "Your") shall mean an individual or Legal Entity
-      exercising permissions granted by this License.
-
-      "Source" form shall mean the preferred form for making modifications,
-      including but not limited to software source code, documentation
-      source, and configuration files.
-
-      "Object" form shall mean any form resulting from mechanical
-      transformation or translation of a Source form, including but
-      not limited to compiled object code, generated documentation,
-      and conversions to other media types.
-
-      "Work" shall mean the work of authorship, whether in Source or
-      Object form, made available under the License, as indicated by a
-      copyright notice that is included in or attached to the work
-      (an example is provided in the Appendix below).
-
-      "Derivative Works" shall mean any work, whether in Source or Object
-      form, that is based on (or derived from) the Work and for which the
-      editorial revisions, annotations, elaborations, or other modifications
-      represent, as a whole, an original work of authorship. For the purposes
-      of this License, Derivative Works shall not include works that remain
-      separable from, or merely link (or bind by name) to the interfaces of,
-      the Work and Derivative Works thereof.
-
-      "Contribution" shall mean any work of authorship, including
-      the original version of the Work and any modifications or additions
-      to that Work or Derivative Works thereof, that is intentionally
-      submitted to Licensor for inclusion in the Work by the copyright owner
-      or by an individual or Legal Entity authorized to submit on behalf of
-      the copyright owner. For the purposes of this definition, "submitted"
-      means any form of electronic, verbal, or written communication sent
-      to the Licensor or its representatives, including but not limited to
-      communication on electronic mailing lists, source code control systems,
-      and issue tracking systems that are managed by, or on behalf of, the
-      Licensor for the purpose of discussing and improving the Work, but
-      excluding communication that is conspicuously marked or otherwise
-      designated in writing by the copyright owner as "Not a Contribution."
-
-      "Contributor" shall mean Licensor and any individual or Legal Entity
-      on behalf of whom a Contribution has been received by Licensor and
-      subsequently incorporated within the Work.
-
-   2. Grant of Copyright License. Subject to the terms and conditions of
-      this License, each Contributor hereby grants to You a perpetual,
-      worldwide, non-exclusive, no-charge, royalty-free, irrevocable
-      copyright license to reproduce, prepare Derivative Works of,
-      publicly display, publicly perform, sublicense, and distribute the
-      Work and such Derivative Works in Source or Object form.
-
-   3. Grant of Patent License. Subject to the terms and conditions of
-      this License, each Contributor 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, and otherwise transfer the Work,
-      where such license applies only to those patent claims licensable
-      by such Contributor that are necessarily infringed by their
-      Contribution(s) alone or by combination of their Contribution(s)
-      with the Work to which such Contribution(s) was submitted. If You
-      institute patent litigation against any entity (including a
-      cross-claim or counterclaim in a lawsuit) alleging that the Work
-      or a Contribution incorporated within the Work constitutes direct
-      or contributory patent infringement, then any patent licenses
-      granted to You under this License for that Work shall terminate
-      as of the date such litigation is filed.
-
-   4. Redistribution. You may reproduce and distribute copies of the
-      Work or Derivative Works thereof in any medium, with or without
-      modifications, and in Source or Object form, provided that You
-      meet the following conditions:
-
-      (a) You must give any other recipients of the Work or
-          Derivative Works a copy of this License; and
-
-      (b) You must cause any modified files to carry prominent notices
-          stating that You changed the files; and
-
-      (c) You must retain, in the Source form of any Derivative Works
-          that You distribute, all copyright, patent, trademark, and
-          attribution notices from the Source form of the Work,
-          excluding those notices that do not pertain to any part of
-          the Derivative Works; and
-
-      (d) If the Work includes a "NOTICE" text file as part of its
-          distribution, then any Derivative Works that You distribute must
-          include a readable copy of the attribution notices contained
-          within such NOTICE file, excluding those notices that do not
-          pertain to any part of the Derivative Works, in at least one
-          of the following places: within a NOTICE text file distributed
-          as part of the Derivative Works; within the Source form or
-          documentation, if provided along with the Derivative Works; or,
-          within a display generated by the Derivative Works, if and
-          wherever such third-party notices normally appear. The contents
-          of the NOTICE file are for informational purposes only and
-          do not modify the License. You may add Your own attribution
-          notices within Derivative Works that You distribute, alongside
-          or as an addendum to the NOTICE text from the Work, provided
-          that such additional attribution notices cannot be construed
-          as modifying the License.
-
-      You may add Your own copyright statement to Your modifications and
-      may provide additional or different license terms and conditions
-      for use, reproduction, or distribution of Your modifications, or
-      for any such Derivative Works as a whole, provided Your use,
-      reproduction, and distribution of the Work otherwise complies with
-      the conditions stated in this License.
-
-   5. Submission of Contributions. Unless You explicitly state otherwise,
-      any Contribution intentionally submitted for inclusion in the Work
-      by You to the Licensor shall be under the terms and conditions of
-      this License, without any additional terms or conditions.
-      Notwithstanding the above, nothing herein shall supersede or modify
-      the terms of any separate license agreement you may have executed
-      with Licensor regarding such Contributions.
-
-   6. Trademarks. This License does not grant permission to use the trade
-      names, trademarks, service marks, or product names of the Licensor,
-      except as required for reasonable and customary use in describing the
-      origin of the Work and reproducing the content of the NOTICE file.
-
-   7. Disclaimer of Warranty. Unless required by applicable law or
-      agreed to in writing, Licensor provides the Work (and each
-      Contributor provides its Contributions) on an "AS IS" BASIS,
-      WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or
-      implied, including, without limitation, any warranties or conditions
-      of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A
-      PARTICULAR PURPOSE. You are solely responsible for determining the
-      appropriateness of using or redistributing the Work and assume any
-      risks associated with Your exercise of permissions under this License.
-
-   8. Limitation of Liability. In no event and under no legal theory,
-      whether in tort (including negligence), contract, or otherwise,
-      unless required by applicable law (such as deliberate and grossly
-      negligent acts) or agreed to in writing, shall any Contributor be
-      liable to You for damages, including any direct, indirect, special,
-      incidental, or consequential damages of any character arising as a
-      result of this License or out of the use or inability to use the
-      Work (including but not limited to damages for loss of goodwill,
-      work stoppage, computer failure or malfunction, or any and all
-      other commercial damages or losses), even if such Contributor
-      has been advised of the possibility of such damages.
-
-   9. Accepting Warranty or Additional Liability. While redistributing
-      the Work or Derivative Works thereof, You may choose to offer,
-      and charge a fee for, acceptance of support, warranty, indemnity,
-      or other liability obligations and/or rights consistent with this
-      License. However, in accepting such obligations, You may act only
-      on Your own behalf and on Your sole responsibility, not on behalf
-      of any other Contributor, and only if You agree to indemnify,
-      defend, and hold each Contributor harmless for any liability
-      incurred by, or claims asserted against, such Contributor by reason
-      of your accepting any such warranty or additional liability.
-
-   END OF TERMS AND CONDITIONS
-
-   APPENDIX: How to apply the Apache License to your work.
-
-      To apply the Apache License to your work, attach the following
-      boilerplate notice, with the fields enclosed by brackets "[]"
-      replaced with your own identifying information. (Don't include
-      the brackets!)  The text should be enclosed in the appropriate
-      comment syntax for the file format. We also recommend that a
-      file or class name and description of purpose be included on the
-      same "printed page" as the copyright notice for easier
-      identification within third-party archives.
-
-   Copyright [yyyy] [name of copyright owner]
-
-   Licensed under the Apache License, Version 2.0 (the "License");
-   you may not use this file except in compliance with the License.
-   You may obtain a copy of the License at
-
-       http://www.apache.org/licenses/LICENSE-2.0
-
-   Unless required by applicable law or agreed to in writing, software
-   distributed under the License is distributed on an "AS IS" BASIS,
-   WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
-   See the License for the specific language governing permissions and
-   limitations under the License.

+ 0 - 147
qyxy/src/mgoutil/go.mongodb.org/mongo-driver/Makefile

@@ -1,147 +0,0 @@
-BSON_PKGS = $(shell etc/list_pkgs.sh ./bson)
-BSON_TEST_PKGS = $(shell etc/list_test_pkgs.sh ./bson)
-MONGO_PKGS = $(shell etc/list_pkgs.sh ./mongo)
-MONGO_TEST_PKGS = $(shell etc/list_test_pkgs.sh ./mongo)
-UNSTABLE_PKGS = $(shell etc/list_pkgs.sh ./x)
-UNSTABLE_TEST_PKGS = $(shell etc/list_test_pkgs.sh ./x)
-TAG_PKG = $(shell etc/list_pkgs.sh ./tag)
-TAG_TEST_PKG = $(shell etc/list_test_pkgs.sh ./tag)
-EXAMPLES_PKGS = $(shell etc/list_pkgs.sh ./examples)
-EXAMPLES_TEST_PKGS = $(shell etc/list_test_pkgs.sh ./examples)
-PKGS = $(BSON_PKGS) $(MONGO_PKGS) $(UNSTABLE_PKGS) $(TAG_PKG) $(EXAMPLES_PKGS)
-TEST_PKGS = $(BSON_TEST_PKGS) $(MONGO_TEST_PKGS) $(UNSTABLE_TEST_PKGS) $(TAG_PKG) $(EXAMPLES_TEST_PKGS)
-ATLAS_URIS = "$(ATLAS_FREE)" "$(ATLAS_REPLSET)" "$(ATLAS_SHARD)" "$(ATLAS_TLS11)" "$(ATLAS_TLS12)" "$(ATLAS_FREE_SRV)" "$(ATLAS_REPLSET_SRV)" "$(ATLAS_SHARD_SRV)" "$(ATLAS_TLS11_SRV)" "$(ATLAS_TLS12_SRV)"
-
-TEST_TIMEOUT = 600
-
-.PHONY: default
-default: check-env check-fmt vet build-examples lint errcheck test-cover test-race
-
-.PHONY: check-env
-check-env:
-	etc/check_env.sh
-
-.PHONY: doc
-doc:
-	godoc -http=:6060 -index
-
-.PHONY: build-examples
-build-examples:
-	go build $(BUILD_TAGS) ./examples/... ./x/mongo/driver/examples/...
-
-.PHONY: build
-build:
-	go build $(filter-out ./core/auth/internal/gssapi,$(PKGS))
-
-.PHONY: build-cse
-build-cse:
-	go build -tags cse $(filter-out ./core/auth/internal/gssapi,$(PKGS))
-
-.PHONY: check-fmt
-check-fmt:
-	etc/check_fmt.sh $(PKGS)
-
-.PHONY: fmt
-fmt:
-	gofmt -l -s -w $(PKGS)
-
-.PHONY: lint
-lint:
-	golint $(PKGS) | ./etc/lintscreen.pl .lint-whitelist
-
-.PHONY: lint-add-whitelist
-lint-add-whitelist:
-	golint $(PKGS) | ./etc/lintscreen.pl -u .lint-whitelist
-	sort .lint-whitelist -o .lint-whitelist
-
-.PHONY: errcheck
-errcheck:
-	errcheck -exclude .errcheck-excludes ./bson/... ./mongo/... ./x/...
-
-.PHONY: test
-test:
-	for TEST in $(TEST_PKGS) ; do \
-		go test $(BUILD_TAGS) -timeout $(TEST_TIMEOUT)s $$TEST ; \
-	done
-
-.PHONY: test-cover
-test-cover:
-	for TEST in $(TEST_PKGS) ; do \
-    	go test $(BUILD_TAGS) -timeout $(TEST_TIMEOUT)s -cover $(COVER_ARGS) $$TEST ; \
-    done
-
-.PHONY: test-race
-test-race:
-	for TEST in $(TEST_PKGS) ; do \
-    	go test $(BUILD_TAGS) -timeout $(TEST_TIMEOUT)s -race $(COVER_ARGS) $$TEST ; \
-    done
-
-.PHONY: test-short
-test-short:
-	for TEST in $(TEST_PKGS) ; do \
-    	go test $(BUILD_TAGS) -timeout $(TEST_TIMEOUT)s -short $(COVER_ARGS) $$TEST ; \
-    done
-
-.PHONY: update-bson-corpus-tests
-update-bson-corpus-tests:
-	etc/update-spec-tests.sh bson-corpus
-
-.PHONY: update-connection-string-tests
-update-connection-string-tests:
-	etc/update-spec-tests.sh connection-string
-
-.PHONY: update-crud-tests
-update-crud-tests:
-	etc/update-spec-tests.sh crud
-
-.PHONY: update-initial-dns-seedlist-discovery-tests
-update-initial-dns-seedlist-discovery-tests:
-	etc/update-spec-tests.sh initial-dns-seedlist-discovery
-
-.PHONY: update-max-staleness-tests
-update-max-staleness-tests:
-	etc/update-spec-tests.sh max-staleness
-
-.PHONY: update-server-discovery-and-monitoring-tests
-update-server-discovery-and-monitoring-tests:
-	etc/update-spec-tests.sh server-discovery-and-monitoring
-
-.PHONY: update-server-selection-tests
-update-server-selection-tests:
-	etc/update-spec-tests.sh server-selection
-
-.PHONY: update-notices
-update-notices:
-	etc/generate-notices.pl > THIRD-PARTY-NOTICES
-
-.PHONY: vet
-vet:
-	go vet -cgocall=false -composites=false -unusedstringmethods="Error" $(PKGS)
-
-
-# Evergreen specific targets
-.PHONY: evg-test
-evg-test:
-	for TEST in $(TEST_PKGS) ; do \
-		LD_LIBRARY_PATH=$(LD_LIBRARY_PATH) PKG_CONFIG_PATH=$(PKG_CONFIG_PATH) go test $(BUILD_TAGS) -v -timeout $(TEST_TIMEOUT)s $$TEST >> test.suite ; \
-	done
-
-.PHONY: evg-test-auth
-evg-test-auth:
-	go run -tags gssapi ./x/mongo/driver/examples/count/main.go -uri $(MONGODB_URI)
-
-.PHONY: evg-test-atlas
-evg-test-atlas:
-	go run ./mongo/testatlas/main.go $(ATLAS_URIS)
-
-# benchmark specific targets and support
-perf:driver-test-data.tar.gz
-	tar -zxf $< $(if $(eq $(UNAME_S),Darwin),-s , --transform=s)/data/perf/
-	@touch $@
-driver-test-data.tar.gz:
-	curl --retry 5 "https://s3.amazonaws.com/boxes.10gen.com/build/driver-test-data.tar.gz" -o driver-test-data.tar.gz --silent --max-time 120
-benchmark:perf
-	go test $(BUILD_TAGS) -benchmem -bench=. ./benchmark
-driver-benchmark:perf
-	@go run cmd/godriver-benchmark/main.go | tee perf.suite
-.PHONY:benchmark driver-benchmark

+ 0 - 193
qyxy/src/mgoutil/go.mongodb.org/mongo-driver/README.md

@@ -1,193 +0,0 @@
-<p align="center"><img src="etc/assets/mongo-gopher.png" width="250"></p>
-<p align="center">
-  <a href="https://goreportcard.com/report/go.mongodb.org/mongo-driver"><img src="https://goreportcard.com/badge/go.mongodb.org/mongo-driver"></a>
-  <a href="https://godoc.org/go.mongodb.org/mongo-driver/mongo"><img src="etc/assets/godoc-mongo-blue.svg" alt="GoDoc"></a>
-  <a href="https://godoc.org/go.mongodb.org/mongo-driver/bson"><img src="etc/assets/godoc-bson-blue.svg" alt="GoDoc"></a>
-  <a href="https://docs.mongodb.com/ecosystem/drivers/go/"><img src="etc/assets/docs-mongodb-green.svg"></a>
-</p>
-
-# MongoDB Go Driver
-
-The MongoDB supported driver for Go.
-
--------------------------
-- [Requirements](#requirements)
-- [Installation](#installation)
-- [Usage](#usage)
-- [Bugs / Feature Reporting](#bugs--feature-reporting)
-- [Testing / Development](#testing--development)
-- [Continuous Integration](#continuous-integration)
-- [License](#license)
-
--------------------------
-## Requirements
-
-- Go 1.10 or higher. We aim to support the latest supported versions of go.
-- MongoDB 2.6 and higher.
-
--------------------------
-## Installation
-
-The recommended way to get started using the MongoDB Go driver is by using `dep` to install the dependency in your project.
-
-```bash
-dep ensure -add "go.mongodb.org/mongo-driver/mongo@~1.1.0"
-```
-
--------------------------
-## Usage
-
-To get started with the driver, import the `mongo` package, create a `mongo.Client`:
-
-```go
-import (
-    "go.mongodb.org/mongo-driver/mongo"
-    "go.mongodb.org/mongo-driver/mongo/options"
-)
-
-client, err := mongo.NewClient(options.Client().ApplyURI("mongodb://localhost:27017"))
-```
-
-And connect it to your running MongoDB server:
-
-```go
-ctx, _ := context.WithTimeout(context.Background(), 10*time.Second)
-err = client.Connect(ctx)
-```
-
-To do this in a single step, you can use the `Connect` function:
-
-```go
-ctx, _ := context.WithTimeout(context.Background(), 10*time.Second)
-client, err := mongo.Connect(ctx, options.Client().ApplyURI("mongodb://localhost:27017"))
-```
-
-Calling `Connect` does not block for server discovery. If you wish to know if a MongoDB server has been found and connected to,
-use the `Ping` method:
-
-```go
-ctx, _ = context.WithTimeout(context.Background(), 2*time.Second)
-err = client.Ping(ctx, readpref.Primary())
-```
-
-To insert a document into a collection, first retrieve a `Database` and then `Collection` instance from the `Client`:
-
-```go
-collection := client.Database("testing").Collection("numbers")
-```
-
-The `Collection` instance can then be used to insert documents:
-
-```go
-ctx, _ = context.WithTimeout(context.Background(), 5*time.Second)
-res, err := collection.InsertOne(ctx, bson.M{"name": "pi", "value": 3.14159})
-id := res.InsertedID
-```
-
-Several query methods return a cursor, which can be used like this:
-
-```go
-ctx, _ = context.WithTimeout(context.Background(), 30*time.Second)
-cur, err := collection.Find(ctx, bson.D{})
-if err != nil { log.Fatal(err) }
-defer cur.Close(ctx)
-for cur.Next(ctx) {
-   var result bson.M
-   err := cur.Decode(&result)
-   if err != nil { log.Fatal(err) }
-   // do something with result....
-}
-if err := cur.Err(); err != nil {
-  log.Fatal(err)
-}
-```
-
-For methods that return a single item, a `SingleResult` instance is returned:
-
-```go
-var result struct {
-    Value float64
-}
-filter := bson.M{"name": "pi"}
-ctx, _ = context.WithTimeout(context.Background(), 5*time.Second)
-err = collection.FindOne(ctx, filter).Decode(&result)
-if err != nil {
-    log.Fatal(err)
-}
-// Do something with result...
-```
-
-Additional examples and documentation can be found under the examples directory and [on the MongoDB Documentation website](https://docs.mongodb.com/ecosystem/drivers/go/).
-
--------------------------
-## Bugs / Feature Reporting
-
-New Features and bugs can be reported on jira: https://jira.mongodb.org/browse/GODRIVER
-
--------------------------
-## Testing / Development
-
-The driver tests can be run against several database configurations. The most simple configuration is a standalone mongod with no auth, no ssl, and no compression. To run these basic driver tests, make sure a standalone MongoDB server instance is running at localhost:27017. To run the tests, you can run `make` (on Windows, run `nmake`). This will run coverage, run go-lint, run go-vet, and build the examples.
-
-### Testing Different Topologies
-
-To test a **replica set** or **sharded cluster**, set `MONGODB_URI="<connection-string>"` for the `make` command.
-For example, for a local replica set named `rs1` comprised of three nodes on ports 27017, 27018, and 27019:
-
-```
-MONGODB_URI="mongodb://localhost:27017,localhost:27018,localhost:27018/?replicaSet=rs1" make
-```
-
-### Testing Auth and SSL
-
-To test authentication and SSL, first set up a MongoDB cluster with auth and SSL configured. Testing authentication requires a user with the `root` role on the `admin` database. The Go Driver repository comes with example certificates in the `data/certificates` directory. These certs can be used for testing. Here is an example command that would run a mongod with SSL correctly configured for tests:
-
-```
-mongod \
---auth \
---sslMode requireSSL \
---sslPEMKeyFile $(pwd)/data/certificates/server.pem \
---sslCAFile $(pwd)/data/certificates/ca.pem \
---sslWeakCertificateValidation
-```
-
-To run the tests with `make`, set `MONGO_GO_DRIVER_CA_FILE` to the location of the CA file used by the database, set `MONGODB_URI` to the connection string of the server, set `AUTH=auth`, and set `SSL=ssl`. For example:
-
-```
-AUTH=auth SSL=ssl MONGO_GO_DRIVER_CA_FILE=$(pwd)/data/certificates/ca.pem  MONGODB_URI="mongodb://user:password@localhost:27017/?authSource=admin" make
-```
-
-Notes:
-- The `--sslWeakCertificateValidation` flag is required on the server for the test suite to work correctly.
-- The test suite requires the auth database to be set with `?authSource=admin`, not `/admin`.
-
-### Testing Compression
-
-The MongoDB Go Driver supports wire protocol compression using Snappy, zLib, or zstd. To run tests with wire protocol compression, set `MONGO_GO_DRIVER_COMPRESSOR` to `snappy`, `zlib`, or `zstd`.  For example:
-
-```
-MONGO_GO_DRIVER_COMPRESSOR=snappy make
-```
-
-Ensure the [`--networkMessageCompressors` flag](https://docs.mongodb.com/manual/reference/program/mongod/#cmdoption-mongod-networkmessagecompressors) on mongod or mongos includes `zlib` if testing zLib compression.
-
--------------------------
-## Feedback
-
-The MongoDB Go Driver is not feature complete, so any help is appreciated. Check out the [project page](https://jira.mongodb.org/browse/GODRIVER)
-for tickets that need completing. See our [contribution guidelines](CONTRIBUTING.md) for details.
-
--------------------------
-## Continuous Integration
-
-Commits to master are run automatically on [evergreen](https://evergreen.mongodb.com/waterfall/mongo-go-driver).
-
--------------------------
-## Thanks and Acknowledgement 
-
-<a href="https://github.com/ashleymcnamara">@ashleymcnamara</a> - Mongo Gopher Artwork
-
--------------------------
-## License
-
-The MongoDB Go Driver is licensed under the [Apache License](LICENSE).

+ 0 - 1336
qyxy/src/mgoutil/go.mongodb.org/mongo-driver/THIRD-PARTY-NOTICES

@@ -1,1336 +0,0 @@
----------------------------------------------------------------------
-License notice for gopkg.in/mgo.v2/bson
----------------------------------------------------------------------
-
-BSON library for Go
-
-Copyright (c) 2010-2013 - Gustavo Niemeyer <gustavo@niemeyer.net>
-
-All rights reserved.
-
-Redistribution and use in source and binary forms, with or without
-modification, are permitted provided that the following conditions are met: 
-
-1. Redistributions of source code must retain the above copyright notice, this
-   list of conditions and the following disclaimer. 
-2. 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. 
-
-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.
-
----------------------------------------------------------------------
-License notice for JSON and CSV code from github.com/golang/go
----------------------------------------------------------------------
-
-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.
-
-----------------------------------------------------------------------
-License notice for github.com/davecgh/go-spew
-----------------------------------------------------------------------
-
-ISC License
-
-Copyright (c) 2012-2016 Dave Collins <dave@davec.name>
-
-Permission to use, copy, modify, and/or distribute this software for any
-purpose with or without fee is hereby granted, provided that the above
-copyright notice and this permission notice appear in all copies.
-
-THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES
-WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF
-MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR
-ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES
-WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN
-ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF
-OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
-
-----------------------------------------------------------------------
-License notice for github.com/gobuffalo/genny
-----------------------------------------------------------------------
-
-The MIT License (MIT)
-
-Copyright (c) 2019 Mark Bates
-
-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.
-
-----------------------------------------------------------------------
-License notice for github.com/gobuffalo/genny/genny
-----------------------------------------------------------------------
-
-The MIT License (MIT)
-
-Copyright © 2018 Mark Bates
-
-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.
-
-----------------------------------------------------------------------
-License notice for github.com/gobuffalo/gogen
-----------------------------------------------------------------------
-
-The MIT License (MIT)
-
-Copyright (c) 2019 Mark Bates
-
-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.
-
-----------------------------------------------------------------------
-License notice for github.com/gobuffalo/gogen/goimports
-----------------------------------------------------------------------
-
-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.
-
-----------------------------------------------------------------------
-License notice for github.com/gobuffalo/logger
-----------------------------------------------------------------------
-
-The MIT License (MIT)
-
-Copyright (c) 2018 Mark Bates
-
-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.
-
-----------------------------------------------------------------------
-License notice for github.com/gobuffalo/mapi
-----------------------------------------------------------------------
-
-The MIT License (MIT)
-
-Copyright (c) 2018 Mark Bates
-
-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.
-
-----------------------------------------------------------------------
-License notice for github.com/gobuffalo/packd
-----------------------------------------------------------------------
-
-The MIT License (MIT)
-
-Copyright (c) 2018 Mark Bates
-
-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.
-
-----------------------------------------------------------------------
-License notice for github.com/gobuffalo/packr/v2/packr2
-----------------------------------------------------------------------
-
-The MIT License (MIT)
-
-Copyright © 2018 Mark Bates
-
-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.
-
-----------------------------------------------------------------------
-License notice for github.com/gobuffalo/syncx
-----------------------------------------------------------------------
-
-The MIT License (MIT)
-
-Copyright (c) 2018 Mark Bates
-
-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.
-
-----------------------------------------------------------------------
-License notice for github.com/golang/snappy
-----------------------------------------------------------------------
-
-Copyright (c) 2011 The Snappy-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.
-
-----------------------------------------------------------------------
-License notice for github.com/google/go-cmp
-----------------------------------------------------------------------
-
-Copyright (c) 2017 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.
-
-----------------------------------------------------------------------
-License notice for github.com/karrick/godirwalk
-----------------------------------------------------------------------
-
-BSD 2-Clause License
-
-Copyright (c) 2017, Karrick McDermott
-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.
-
-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 HOLDER 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.
-
-----------------------------------------------------------------------
-License notice for github.com/konsorten/go-windows-terminal-sequences
-----------------------------------------------------------------------
-
-(The MIT License)
-
-Copyright (c) 2017 marvin + konsorten GmbH (open-source@konsorten.de)
-
-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.
-
-----------------------------------------------------------------------
-License notice for github.com/kr/pretty
-----------------------------------------------------------------------
-
-The MIT License (MIT)
-
-Copyright 2012 Keith Rarick
-
-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.
-
-----------------------------------------------------------------------
-License notice for github.com/kr/text
-----------------------------------------------------------------------
-
-Copyright 2012 Keith Rarick
-
-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.
-
-----------------------------------------------------------------------
-License notice for github.com/markbates/oncer
-----------------------------------------------------------------------
-
-The MIT License (MIT)
-
-Copyright (c) 2018 Mark Bates
-
-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.
-
-----------------------------------------------------------------------
-License notice for github.com/markbates/safe
-----------------------------------------------------------------------
-
-The MIT License (MIT)
-
-Copyright (c) 2018 Mark Bates
-
-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.
-
-----------------------------------------------------------------------
-License notice for github.com/montanaflynn/stats
-----------------------------------------------------------------------
-
-The MIT License (MIT)
-
-Copyright (c) 2014-2015 Montana Flynn (https://anonfunction.com)
-
-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.
-
-----------------------------------------------------------------------
-License notice for github.com/pelletier/go-toml
-----------------------------------------------------------------------
-
-The MIT License (MIT)
-
-Copyright (c) 2013 - 2017 Thomas Pelletier, Eric Anderton
-
-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.
-
-----------------------------------------------------------------------
-License notice for github.com/pkg/errors
-----------------------------------------------------------------------
-
-Copyright (c) 2015, Dave Cheney <dave@cheney.net>
-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.
-
-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 HOLDER 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.
-
-----------------------------------------------------------------------
-License notice for github.com/pmezard/go-difflib
-----------------------------------------------------------------------
-
-Copyright (c) 2013, Patrick Mezard
-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.
-    The names of its contributors may not 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
-HOLDER 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.
-
-----------------------------------------------------------------------
-License notice for github.com/rogpeppe/go-internal
-----------------------------------------------------------------------
-
-Copyright (c) 2018 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.
-
-----------------------------------------------------------------------
-License notice for github.com/sirupsen/logrus
-----------------------------------------------------------------------
-
-The MIT License (MIT)
-
-Copyright (c) 2014 Simon Eskildsen
-
-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.
-
-----------------------------------------------------------------------
-License notice for github.com/stretchr/testify
-----------------------------------------------------------------------
-
-MIT License
-
-Copyright (c) 2012-2018 Mat Ryer and Tyler Bunnell
-
-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.
-
-----------------------------------------------------------------------
-License notice for github.com/tidwall/pretty
-----------------------------------------------------------------------
-
-The MIT License (MIT)
-
-Copyright (c) 2017 Josh Baker
-
-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.
-
-----------------------------------------------------------------------
-License notice for github.com/xdg/scram
-----------------------------------------------------------------------
-
-
-                                 Apache License
-                           Version 2.0, January 2004
-                        http://www.apache.org/licenses/
-
-   TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION
-
-   1. Definitions.
-
-      "License" shall mean the terms and conditions for use, reproduction,
-      and distribution as defined by Sections 1 through 9 of this document.
-
-      "Licensor" shall mean the copyright owner or entity authorized by
-      the copyright owner that is granting the License.
-
-      "Legal Entity" shall mean the union of the acting entity and all
-      other entities that control, are controlled by, or are under common
-      control with that entity. For the purposes of this definition,
-      "control" means (i) the power, direct or indirect, to cause the
-      direction or management of such entity, whether by contract or
-      otherwise, or (ii) ownership of fifty percent (50%) or more of the
-      outstanding shares, or (iii) beneficial ownership of such entity.
-
-      "You" (or "Your") shall mean an individual or Legal Entity
-      exercising permissions granted by this License.
-
-      "Source" form shall mean the preferred form for making modifications,
-      including but not limited to software source code, documentation
-      source, and configuration files.
-
-      "Object" form shall mean any form resulting from mechanical
-      transformation or translation of a Source form, including but
-      not limited to compiled object code, generated documentation,
-      and conversions to other media types.
-
-      "Work" shall mean the work of authorship, whether in Source or
-      Object form, made available under the License, as indicated by a
-      copyright notice that is included in or attached to the work
-      (an example is provided in the Appendix below).
-
-      "Derivative Works" shall mean any work, whether in Source or Object
-      form, that is based on (or derived from) the Work and for which the
-      editorial revisions, annotations, elaborations, or other modifications
-      represent, as a whole, an original work of authorship. For the purposes
-      of this License, Derivative Works shall not include works that remain
-      separable from, or merely link (or bind by name) to the interfaces of,
-      the Work and Derivative Works thereof.
-
-      "Contribution" shall mean any work of authorship, including
-      the original version of the Work and any modifications or additions
-      to that Work or Derivative Works thereof, that is intentionally
-      submitted to Licensor for inclusion in the Work by the copyright owner
-      or by an individual or Legal Entity authorized to submit on behalf of
-      the copyright owner. For the purposes of this definition, "submitted"
-      means any form of electronic, verbal, or written communication sent
-      to the Licensor or its representatives, including but not limited to
-      communication on electronic mailing lists, source code control systems,
-      and issue tracking systems that are managed by, or on behalf of, the
-      Licensor for the purpose of discussing and improving the Work, but
-      excluding communication that is conspicuously marked or otherwise
-      designated in writing by the copyright owner as "Not a Contribution."
-
-      "Contributor" shall mean Licensor and any individual or Legal Entity
-      on behalf of whom a Contribution has been received by Licensor and
-      subsequently incorporated within the Work.
-
-   2. Grant of Copyright License. Subject to the terms and conditions of
-      this License, each Contributor hereby grants to You a perpetual,
-      worldwide, non-exclusive, no-charge, royalty-free, irrevocable
-      copyright license to reproduce, prepare Derivative Works of,
-      publicly display, publicly perform, sublicense, and distribute the
-      Work and such Derivative Works in Source or Object form.
-
-   3. Grant of Patent License. Subject to the terms and conditions of
-      this License, each Contributor 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, and otherwise transfer the Work,
-      where such license applies only to those patent claims licensable
-      by such Contributor that are necessarily infringed by their
-      Contribution(s) alone or by combination of their Contribution(s)
-      with the Work to which such Contribution(s) was submitted. If You
-      institute patent litigation against any entity (including a
-      cross-claim or counterclaim in a lawsuit) alleging that the Work
-      or a Contribution incorporated within the Work constitutes direct
-      or contributory patent infringement, then any patent licenses
-      granted to You under this License for that Work shall terminate
-      as of the date such litigation is filed.
-
-   4. Redistribution. You may reproduce and distribute copies of the
-      Work or Derivative Works thereof in any medium, with or without
-      modifications, and in Source or Object form, provided that You
-      meet the following conditions:
-
-      (a) You must give any other recipients of the Work or
-          Derivative Works a copy of this License; and
-
-      (b) You must cause any modified files to carry prominent notices
-          stating that You changed the files; and
-
-      (c) You must retain, in the Source form of any Derivative Works
-          that You distribute, all copyright, patent, trademark, and
-          attribution notices from the Source form of the Work,
-          excluding those notices that do not pertain to any part of
-          the Derivative Works; and
-
-      (d) If the Work includes a "NOTICE" text file as part of its
-          distribution, then any Derivative Works that You distribute must
-          include a readable copy of the attribution notices contained
-          within such NOTICE file, excluding those notices that do not
-          pertain to any part of the Derivative Works, in at least one
-          of the following places: within a NOTICE text file distributed
-          as part of the Derivative Works; within the Source form or
-          documentation, if provided along with the Derivative Works; or,
-          within a display generated by the Derivative Works, if and
-          wherever such third-party notices normally appear. The contents
-          of the NOTICE file are for informational purposes only and
-          do not modify the License. You may add Your own attribution
-          notices within Derivative Works that You distribute, alongside
-          or as an addendum to the NOTICE text from the Work, provided
-          that such additional attribution notices cannot be construed
-          as modifying the License.
-
-      You may add Your own copyright statement to Your modifications and
-      may provide additional or different license terms and conditions
-      for use, reproduction, or distribution of Your modifications, or
-      for any such Derivative Works as a whole, provided Your use,
-      reproduction, and distribution of the Work otherwise complies with
-      the conditions stated in this License.
-
-   5. Submission of Contributions. Unless You explicitly state otherwise,
-      any Contribution intentionally submitted for inclusion in the Work
-      by You to the Licensor shall be under the terms and conditions of
-      this License, without any additional terms or conditions.
-      Notwithstanding the above, nothing herein shall supersede or modify
-      the terms of any separate license agreement you may have executed
-      with Licensor regarding such Contributions.
-
-   6. Trademarks. This License does not grant permission to use the trade
-      names, trademarks, service marks, or product names of the Licensor,
-      except as required for reasonable and customary use in describing the
-      origin of the Work and reproducing the content of the NOTICE file.
-
-   7. Disclaimer of Warranty. Unless required by applicable law or
-      agreed to in writing, Licensor provides the Work (and each
-      Contributor provides its Contributions) on an "AS IS" BASIS,
-      WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or
-      implied, including, without limitation, any warranties or conditions
-      of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A
-      PARTICULAR PURPOSE. You are solely responsible for determining the
-      appropriateness of using or redistributing the Work and assume any
-      risks associated with Your exercise of permissions under this License.
-
-   8. Limitation of Liability. In no event and under no legal theory,
-      whether in tort (including negligence), contract, or otherwise,
-      unless required by applicable law (such as deliberate and grossly
-      negligent acts) or agreed to in writing, shall any Contributor be
-      liable to You for damages, including any direct, indirect, special,
-      incidental, or consequential damages of any character arising as a
-      result of this License or out of the use or inability to use the
-      Work (including but not limited to damages for loss of goodwill,
-      work stoppage, computer failure or malfunction, or any and all
-      other commercial damages or losses), even if such Contributor
-      has been advised of the possibility of such damages.
-
-   9. Accepting Warranty or Additional Liability. While redistributing
-      the Work or Derivative Works thereof, You may choose to offer,
-      and charge a fee for, acceptance of support, warranty, indemnity,
-      or other liability obligations and/or rights consistent with this
-      License. However, in accepting such obligations, You may act only
-      on Your own behalf and on Your sole responsibility, not on behalf
-      of any other Contributor, and only if You agree to indemnify,
-      defend, and hold each Contributor harmless for any liability
-      incurred by, or claims asserted against, such Contributor by reason
-      of your accepting any such warranty or additional liability.
-
-----------------------------------------------------------------------
-License notice for github.com/xdg/stringprep
-----------------------------------------------------------------------
-
-
-                                 Apache License
-                           Version 2.0, January 2004
-                        http://www.apache.org/licenses/
-
-   TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION
-
-   1. Definitions.
-
-      "License" shall mean the terms and conditions for use, reproduction,
-      and distribution as defined by Sections 1 through 9 of this document.
-
-      "Licensor" shall mean the copyright owner or entity authorized by
-      the copyright owner that is granting the License.
-
-      "Legal Entity" shall mean the union of the acting entity and all
-      other entities that control, are controlled by, or are under common
-      control with that entity. For the purposes of this definition,
-      "control" means (i) the power, direct or indirect, to cause the
-      direction or management of such entity, whether by contract or
-      otherwise, or (ii) ownership of fifty percent (50%) or more of the
-      outstanding shares, or (iii) beneficial ownership of such entity.
-
-      "You" (or "Your") shall mean an individual or Legal Entity
-      exercising permissions granted by this License.
-
-      "Source" form shall mean the preferred form for making modifications,
-      including but not limited to software source code, documentation
-      source, and configuration files.
-
-      "Object" form shall mean any form resulting from mechanical
-      transformation or translation of a Source form, including but
-      not limited to compiled object code, generated documentation,
-      and conversions to other media types.
-
-      "Work" shall mean the work of authorship, whether in Source or
-      Object form, made available under the License, as indicated by a
-      copyright notice that is included in or attached to the work
-      (an example is provided in the Appendix below).
-
-      "Derivative Works" shall mean any work, whether in Source or Object
-      form, that is based on (or derived from) the Work and for which the
-      editorial revisions, annotations, elaborations, or other modifications
-      represent, as a whole, an original work of authorship. For the purposes
-      of this License, Derivative Works shall not include works that remain
-      separable from, or merely link (or bind by name) to the interfaces of,
-      the Work and Derivative Works thereof.
-
-      "Contribution" shall mean any work of authorship, including
-      the original version of the Work and any modifications or additions
-      to that Work or Derivative Works thereof, that is intentionally
-      submitted to Licensor for inclusion in the Work by the copyright owner
-      or by an individual or Legal Entity authorized to submit on behalf of
-      the copyright owner. For the purposes of this definition, "submitted"
-      means any form of electronic, verbal, or written communication sent
-      to the Licensor or its representatives, including but not limited to
-      communication on electronic mailing lists, source code control systems,
-      and issue tracking systems that are managed by, or on behalf of, the
-      Licensor for the purpose of discussing and improving the Work, but
-      excluding communication that is conspicuously marked or otherwise
-      designated in writing by the copyright owner as "Not a Contribution."
-
-      "Contributor" shall mean Licensor and any individual or Legal Entity
-      on behalf of whom a Contribution has been received by Licensor and
-      subsequently incorporated within the Work.
-
-   2. Grant of Copyright License. Subject to the terms and conditions of
-      this License, each Contributor hereby grants to You a perpetual,
-      worldwide, non-exclusive, no-charge, royalty-free, irrevocable
-      copyright license to reproduce, prepare Derivative Works of,
-      publicly display, publicly perform, sublicense, and distribute the
-      Work and such Derivative Works in Source or Object form.
-
-   3. Grant of Patent License. Subject to the terms and conditions of
-      this License, each Contributor 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, and otherwise transfer the Work,
-      where such license applies only to those patent claims licensable
-      by such Contributor that are necessarily infringed by their
-      Contribution(s) alone or by combination of their Contribution(s)
-      with the Work to which such Contribution(s) was submitted. If You
-      institute patent litigation against any entity (including a
-      cross-claim or counterclaim in a lawsuit) alleging that the Work
-      or a Contribution incorporated within the Work constitutes direct
-      or contributory patent infringement, then any patent licenses
-      granted to You under this License for that Work shall terminate
-      as of the date such litigation is filed.
-
-   4. Redistribution. You may reproduce and distribute copies of the
-      Work or Derivative Works thereof in any medium, with or without
-      modifications, and in Source or Object form, provided that You
-      meet the following conditions:
-
-      (a) You must give any other recipients of the Work or
-          Derivative Works a copy of this License; and
-
-      (b) You must cause any modified files to carry prominent notices
-          stating that You changed the files; and
-
-      (c) You must retain, in the Source form of any Derivative Works
-          that You distribute, all copyright, patent, trademark, and
-          attribution notices from the Source form of the Work,
-          excluding those notices that do not pertain to any part of
-          the Derivative Works; and
-
-      (d) If the Work includes a "NOTICE" text file as part of its
-          distribution, then any Derivative Works that You distribute must
-          include a readable copy of the attribution notices contained
-          within such NOTICE file, excluding those notices that do not
-          pertain to any part of the Derivative Works, in at least one
-          of the following places: within a NOTICE text file distributed
-          as part of the Derivative Works; within the Source form or
-          documentation, if provided along with the Derivative Works; or,
-          within a display generated by the Derivative Works, if and
-          wherever such third-party notices normally appear. The contents
-          of the NOTICE file are for informational purposes only and
-          do not modify the License. You may add Your own attribution
-          notices within Derivative Works that You distribute, alongside
-          or as an addendum to the NOTICE text from the Work, provided
-          that such additional attribution notices cannot be construed
-          as modifying the License.
-
-      You may add Your own copyright statement to Your modifications and
-      may provide additional or different license terms and conditions
-      for use, reproduction, or distribution of Your modifications, or
-      for any such Derivative Works as a whole, provided Your use,
-      reproduction, and distribution of the Work otherwise complies with
-      the conditions stated in this License.
-
-   5. Submission of Contributions. Unless You explicitly state otherwise,
-      any Contribution intentionally submitted for inclusion in the Work
-      by You to the Licensor shall be under the terms and conditions of
-      this License, without any additional terms or conditions.
-      Notwithstanding the above, nothing herein shall supersede or modify
-      the terms of any separate license agreement you may have executed
-      with Licensor regarding such Contributions.
-
-   6. Trademarks. This License does not grant permission to use the trade
-      names, trademarks, service marks, or product names of the Licensor,
-      except as required for reasonable and customary use in describing the
-      origin of the Work and reproducing the content of the NOTICE file.
-
-   7. Disclaimer of Warranty. Unless required by applicable law or
-      agreed to in writing, Licensor provides the Work (and each
-      Contributor provides its Contributions) on an "AS IS" BASIS,
-      WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or
-      implied, including, without limitation, any warranties or conditions
-      of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A
-      PARTICULAR PURPOSE. You are solely responsible for determining the
-      appropriateness of using or redistributing the Work and assume any
-      risks associated with Your exercise of permissions under this License.
-
-   8. Limitation of Liability. In no event and under no legal theory,
-      whether in tort (including negligence), contract, or otherwise,
-      unless required by applicable law (such as deliberate and grossly
-      negligent acts) or agreed to in writing, shall any Contributor be
-      liable to You for damages, including any direct, indirect, special,
-      incidental, or consequential damages of any character arising as a
-      result of this License or out of the use or inability to use the
-      Work (including but not limited to damages for loss of goodwill,
-      work stoppage, computer failure or malfunction, or any and all
-      other commercial damages or losses), even if such Contributor
-      has been advised of the possibility of such damages.
-
-   9. Accepting Warranty or Additional Liability. While redistributing
-      the Work or Derivative Works thereof, You may choose to offer,
-      and charge a fee for, acceptance of support, warranty, indemnity,
-      or other liability obligations and/or rights consistent with this
-      License. However, in accepting such obligations, You may act only
-      on Your own behalf and on Your sole responsibility, not on behalf
-      of any other Contributor, and only if You agree to indemnify,
-      defend, and hold each Contributor harmless for any liability
-      incurred by, or claims asserted against, such Contributor by reason
-      of your accepting any such warranty or additional liability.
-
-----------------------------------------------------------------------
-License notice for golang.org/x/crypto
-----------------------------------------------------------------------
-
-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.
-
-----------------------------------------------------------------------
-License notice for golang.org/x/net
-----------------------------------------------------------------------
-
-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.
-
-----------------------------------------------------------------------
-License notice for golang.org/x/sync
-----------------------------------------------------------------------
-
-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.
-
-----------------------------------------------------------------------
-License notice for golang.org/x/sys
-----------------------------------------------------------------------
-
-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.
-
-----------------------------------------------------------------------
-License notice for golang.org/x/text
-----------------------------------------------------------------------
-
-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.
-
-----------------------------------------------------------------------
-License notice for golang.org/x/tools
-----------------------------------------------------------------------
-
-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.
-
-----------------------------------------------------------------------
-License notice for golang.org/x/tools/cmd/getgo
-----------------------------------------------------------------------
-
-Copyright (c) 2017 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.

+ 0 - 75
qyxy/src/mgoutil/go.mongodb.org/mongo-driver/benchmark/bson.go

@@ -1,75 +0,0 @@
-// Copyright (C) MongoDB, Inc. 2017-present.
-//
-// Licensed under the Apache License, Version 2.0 (the "License"); you may
-// not use this file except in compliance with the License. You may obtain
-// a copy of the License at http://www.apache.org/licenses/LICENSE-2.0
-
-package benchmark
-
-import (
-	"errors"
-	"io/ioutil"
-	"path/filepath"
-
-	"go.mongodb.org/mongo-driver/bson"
-	"go.mongodb.org/mongo-driver/x/bsonx"
-)
-
-const (
-	perfDataDir  = "perf"
-	bsonDataDir  = "extended_bson"
-	flatBSONData = "flat_bson.json"
-	deepBSONData = "deep_bson.json"
-	fullBSONData = "full_bson.json"
-)
-
-// utility functions for the bson benchmarks
-
-func loadSourceDocument(pathParts ...string) (bsonx.Doc, error) {
-	data, err := ioutil.ReadFile(filepath.Join(pathParts...))
-	if err != nil {
-		return nil, err
-	}
-	doc := bsonx.Doc{}
-	err = bson.UnmarshalExtJSON(data, true, &doc)
-	if err != nil {
-		return nil, err
-	}
-
-	if len(doc) == 0 {
-		return nil, errors.New("empty bson document")
-	}
-
-	return doc, nil
-}
-
-func loadSourceRaw(pathParts ...string) (bson.Raw, error) {
-	doc, err := loadSourceDocument(pathParts...)
-	if err != nil {
-		return nil, err
-	}
-	raw, err := doc.MarshalBSON()
-	if err != nil {
-		return nil, err
-	}
-
-	return bson.Raw(raw), nil
-}
-
-func loadSourceD(pathParts ...string) (bson.D, error) {
-	data, err := ioutil.ReadFile(filepath.Join(pathParts...))
-	if err != nil {
-		return nil, err
-	}
-	doc := bson.D{}
-	err = bson.UnmarshalExtJSON(data, true, &doc)
-	if err != nil {
-		return nil, err
-	}
-
-	if len(doc) == 0 {
-		return nil, errors.New("empty bson document")
-	}
-
-	return doc, nil
-}

+ 0 - 123
qyxy/src/mgoutil/go.mongodb.org/mongo-driver/benchmark/bson_document.go

@@ -1,123 +0,0 @@
-// Copyright (C) MongoDB, Inc. 2017-present.
-//
-// Licensed under the Apache License, Version 2.0 (the "License"); you may
-// not use this file except in compliance with the License. You may obtain
-// a copy of the License at http://www.apache.org/licenses/LICENSE-2.0
-
-package benchmark
-
-import (
-	"context"
-	"errors"
-
-	"go.mongodb.org/mongo-driver/x/bsonx"
-)
-
-func bsonDocumentEncoding(ctx context.Context, tm TimerManager, iters int, source string) error {
-	doc, err := loadSourceDocument(getProjectRoot(), perfDataDir, bsonDataDir, source)
-	if err != nil {
-		return err
-	}
-
-	tm.ResetTimer()
-
-	for i := 0; i < iters; i++ {
-		out, err := doc.MarshalBSON()
-		if err != nil {
-			return err
-		}
-		if len(out) == 0 {
-			return errors.New("marshaling error")
-		}
-	}
-
-	return nil
-}
-
-func bsonDocumentDecodingLazy(ctx context.Context, tm TimerManager, iters int, source string) error {
-	doc, err := loadSourceDocument(getProjectRoot(), perfDataDir, bsonDataDir, source)
-	if err != nil {
-		return err
-	}
-
-	raw, err := doc.MarshalBSON()
-	if err != nil {
-		return err
-	}
-
-	tm.ResetTimer()
-
-	for i := 0; i < iters; i++ {
-		out, err := bsonx.ReadDoc(raw)
-		if err != nil {
-			return err
-		}
-		if len(out) == 0 {
-			return errors.New("marshaling error")
-		}
-	}
-	return nil
-}
-
-func bsonDocumentDecoding(ctx context.Context, tm TimerManager, iters, numKeys int, source string) error {
-	doc, err := loadSourceDocument(getProjectRoot(), perfDataDir, bsonDataDir, source)
-	if err != nil {
-		return err
-	}
-
-	raw, err := doc.MarshalBSON()
-	if err != nil {
-		return err
-	}
-
-	tm.ResetTimer()
-
-	for i := 0; i < iters; i++ {
-		out, err := bsonx.ReadDoc(raw)
-		if err != nil {
-			return err
-		}
-
-		if len(out) != numKeys {
-			return errors.New("document parsing error")
-		}
-	}
-	return nil
-
-}
-
-func BSONFlatDocumentEncoding(ctx context.Context, tm TimerManager, iters int) error {
-	return bsonDocumentEncoding(ctx, tm, iters, flatBSONData)
-}
-
-func BSONFlatDocumentDecodingLazy(ctx context.Context, tm TimerManager, iters int) error {
-	return bsonDocumentDecodingLazy(ctx, tm, iters, flatBSONData)
-}
-
-func BSONFlatDocumentDecoding(ctx context.Context, tm TimerManager, iters int) error {
-	return bsonDocumentDecoding(ctx, tm, iters, 145, flatBSONData)
-}
-
-func BSONDeepDocumentEncoding(ctx context.Context, tm TimerManager, iters int) error {
-	return bsonDocumentEncoding(ctx, tm, iters, deepBSONData)
-}
-
-func BSONDeepDocumentDecodingLazy(ctx context.Context, tm TimerManager, iters int) error {
-	return bsonDocumentDecodingLazy(ctx, tm, iters, deepBSONData)
-}
-
-func BSONDeepDocumentDecoding(ctx context.Context, tm TimerManager, iters int) error {
-	return bsonDocumentDecoding(ctx, tm, iters, 126, deepBSONData)
-}
-
-func BSONFullDocumentEncoding(ctx context.Context, tm TimerManager, iters int) error {
-	return bsonDocumentEncoding(ctx, tm, iters, fullBSONData)
-}
-
-func BSONFullDocumentDecodingLazy(ctx context.Context, tm TimerManager, iters int) error {
-	return bsonDocumentDecodingLazy(ctx, tm, iters, fullBSONData)
-}
-
-func BSONFullDocumentDecoding(ctx context.Context, tm TimerManager, iters int) error {
-	return bsonDocumentDecoding(ctx, tm, iters, 145, fullBSONData)
-}

+ 0 - 88
qyxy/src/mgoutil/go.mongodb.org/mongo-driver/benchmark/bson_map.go

@@ -1,88 +0,0 @@
-// Copyright (C) MongoDB, Inc. 2017-present.
-//
-// Licensed under the Apache License, Version 2.0 (the "License"); you may
-// not use this file except in compliance with the License. You may obtain
-// a copy of the License at http://www.apache.org/licenses/LICENSE-2.0
-
-package benchmark
-
-import (
-	"context"
-	"errors"
-	"fmt"
-
-	"go.mongodb.org/mongo-driver/bson"
-)
-
-func bsonMapDecoding(ctx context.Context, tm TimerManager, iters int, dataSet string) error {
-	r, err := loadSourceRaw(getProjectRoot(), perfDataDir, bsonDataDir, dataSet)
-	if err != nil {
-		return err
-	}
-
-	tm.ResetTimer()
-
-	for i := 0; i < iters; i++ {
-		out := make(map[string]interface{})
-		err := bson.Unmarshal(r, &out)
-		if err != nil {
-			return nil
-		}
-		if len(out) == 0 {
-			return fmt.Errorf("decoding failed")
-		}
-	}
-	return nil
-}
-
-func bsonMapEncoding(ctx context.Context, tm TimerManager, iters int, dataSet string) error {
-	r, err := loadSourceRaw(getProjectRoot(), perfDataDir, bsonDataDir, dataSet)
-	if err != nil {
-		return err
-	}
-
-	doc := make(map[string]interface{})
-	err = bson.Unmarshal(r, &doc)
-	if err != nil {
-		return err
-	}
-
-	var buf []byte
-	tm.ResetTimer()
-	for i := 0; i < iters; i++ {
-		buf, err = bson.MarshalAppend(buf[:0], doc)
-		if err != nil {
-			return nil
-		}
-
-		if len(buf) == 0 {
-			return errors.New("encoding failed")
-		}
-	}
-
-	return nil
-}
-
-func BSONFlatMapDecoding(ctx context.Context, tm TimerManager, iters int) error {
-	return bsonMapDecoding(ctx, tm, iters, flatBSONData)
-}
-
-func BSONFlatMapEncoding(ctx context.Context, tm TimerManager, iters int) error {
-	return bsonMapEncoding(ctx, tm, iters, flatBSONData)
-}
-
-func BSONDeepMapDecoding(ctx context.Context, tm TimerManager, iters int) error {
-	return bsonMapDecoding(ctx, tm, iters, deepBSONData)
-}
-
-func BSONDeepMapEncoding(ctx context.Context, tm TimerManager, iters int) error {
-	return bsonMapEncoding(ctx, tm, iters, deepBSONData)
-}
-
-func BSONFullMapDecoding(ctx context.Context, tm TimerManager, iters int) error {
-	return bsonMapDecoding(ctx, tm, iters, fullBSONData)
-}
-
-func BSONFullMapEncoding(ctx context.Context, tm TimerManager, iters int) error {
-	return bsonMapEncoding(ctx, tm, iters, fullBSONData)
-}

+ 0 - 103
qyxy/src/mgoutil/go.mongodb.org/mongo-driver/benchmark/bson_struct.go

@@ -1,103 +0,0 @@
-// Copyright (C) MongoDB, Inc. 2017-present.
-//
-// Licensed under the Apache License, Version 2.0 (the "License"); you may
-// not use this file except in compliance with the License. You may obtain
-// a copy of the License at http://www.apache.org/licenses/LICENSE-2.0
-
-package benchmark
-
-import (
-	"context"
-	"errors"
-
-	"go.mongodb.org/mongo-driver/bson"
-)
-
-func BSONFlatStructDecoding(ctx context.Context, tm TimerManager, iters int) error {
-	r, err := loadSourceRaw(getProjectRoot(), perfDataDir, bsonDataDir, flatBSONData)
-	if err != nil {
-		return err
-	}
-
-	tm.ResetTimer()
-
-	for i := 0; i < iters; i++ {
-		out := flatBSON{}
-		err := bson.Unmarshal(r, &out)
-		if err != nil {
-			return err
-		}
-	}
-	return nil
-}
-
-func BSONFlatStructEncoding(ctx context.Context, tm TimerManager, iters int) error {
-	r, err := loadSourceRaw(getProjectRoot(), perfDataDir, bsonDataDir, flatBSONData)
-	if err != nil {
-		return err
-	}
-
-	doc := flatBSON{}
-	err = bson.Unmarshal(r, &doc)
-	if err != nil {
-		return err
-	}
-
-	var buf []byte
-
-	tm.ResetTimer()
-	for i := 0; i < iters; i++ {
-		buf, err = bson.Marshal(doc)
-		if err != nil {
-			return err
-		}
-		if len(buf) == 0 {
-			return errors.New("encoding failed")
-		}
-	}
-	return nil
-}
-
-func BSONFlatStructTagsEncoding(ctx context.Context, tm TimerManager, iters int) error {
-	r, err := loadSourceRaw(getProjectRoot(), perfDataDir, bsonDataDir, flatBSONData)
-	if err != nil {
-		return err
-	}
-
-	doc := flatBSONTags{}
-	err = bson.Unmarshal(r, &doc)
-	if err != nil {
-		return err
-	}
-
-	var buf []byte
-
-	tm.ResetTimer()
-	for i := 0; i < iters; i++ {
-		buf, err = bson.MarshalAppend(buf[:0], doc)
-		if err != nil {
-			return err
-		}
-		if len(buf) == 0 {
-			return errors.New("encoding failed")
-		}
-	}
-	return nil
-}
-
-func BSONFlatStructTagsDecoding(ctx context.Context, tm TimerManager, iters int) error {
-	r, err := loadSourceRaw(getProjectRoot(), perfDataDir, bsonDataDir, flatBSONData)
-	if err != nil {
-		return err
-	}
-
-	tm.ResetTimer()
-	for i := 0; i < iters; i++ {
-		out := flatBSONTags{}
-		err := bson.Unmarshal(r, &out)
-		if err != nil {
-			return err
-		}
-	}
-	return nil
-}

+ 0 - 35
qyxy/src/mgoutil/go.mongodb.org/mongo-driver/benchmark/bson_test.go

@@ -1,35 +0,0 @@
-// Copyright (C) MongoDB, Inc. 2017-present.
-//
-// Licensed under the Apache License, Version 2.0 (the "License"); you may
-// not use this file except in compliance with the License. You may obtain
-// a copy of the License at http://www.apache.org/licenses/LICENSE-2.0
-
-package benchmark
-
-import "testing"
-
-// func BenchmarkBSONFullReaderDecoding(b *testing.B)       { WrapCase(BSONFullReaderDecoding)(b) }
-
-func BenchmarkBSONFlatDocumentEncoding(b *testing.B)     { WrapCase(BSONFlatDocumentEncoding)(b) }
-func BenchmarkBSONFlatDocumentDecodingLazy(b *testing.B) { WrapCase(BSONFlatDocumentDecodingLazy)(b) }
-func BenchmarkBSONFlatDocumentDecoding(b *testing.B)     { WrapCase(BSONFlatDocumentDecoding)(b) }
-func BenchmarkBSONDeepDocumentEncoding(b *testing.B)     { WrapCase(BSONDeepDocumentEncoding)(b) }
-func BenchmarkBSONDeepDocumentDecodingLazy(b *testing.B) { WrapCase(BSONDeepDocumentDecodingLazy)(b) }
-func BenchmarkBSONDeepDocumentDecoding(b *testing.B)     { WrapCase(BSONDeepDocumentDecoding)(b) }
-
-// func BenchmarkBSONFullDocumentEncoding(b *testing.B)     { WrapCase(BSONFullDocumentEncoding)(b) }
-// func BenchmarkBSONFullDocumentDecodingLazy(b *testing.B) { WrapCase(BSONFullDocumentDecodingLazy)(b) }
-// func BenchmarkBSONFullDocumentDecoding(b *testing.B)     { WrapCase(BSONFullDocumentDecoding)(b) }
-
-func BenchmarkBSONFlatMapDecoding(b *testing.B) { WrapCase(BSONFlatMapDecoding)(b) }
-func BenchmarkBSONFlatMapEncoding(b *testing.B) { WrapCase(BSONFlatMapEncoding)(b) }
-func BenchmarkBSONDeepMapDecoding(b *testing.B) { WrapCase(BSONDeepMapDecoding)(b) }
-func BenchmarkBSONDeepMapEncoding(b *testing.B) { WrapCase(BSONDeepMapEncoding)(b) }
-
-// func BenchmarkBSONFullMapDecoding(b *testing.B)       { WrapCase(BSONFullMapDecoding)(b) }
-// func BenchmarkBSONFullMapEncoding(b *testing.B)       { WrapCase(BSONFullMapEncoding)(b) }
-
-func BenchmarkBSONFlatStructDecoding(b *testing.B)     { WrapCase(BSONFlatStructDecoding)(b) }
-func BenchmarkBSONFlatStructTagsDecoding(b *testing.B) { WrapCase(BSONFlatStructTagsDecoding)(b) }
-func BenchmarkBSONFlatStructEncoding(b *testing.B)     { WrapCase(BSONFlatStructEncoding)(b) }
-func BenchmarkBSONFlatStructTagsEncoding(b *testing.B) { WrapCase(BSONFlatStructTagsEncoding)(b) }

+ 0 - 306
qyxy/src/mgoutil/go.mongodb.org/mongo-driver/benchmark/bson_types.go

@@ -1,306 +0,0 @@
-// Copyright (C) MongoDB, Inc. 2017-present.
-//
-// Licensed under the Apache License, Version 2.0 (the "License"); you may
-// not use this file except in compliance with the License. You may obtain
-// a copy of the License at http://www.apache.org/licenses/LICENSE-2.0
-
-package benchmark
-
-import "go.mongodb.org/mongo-driver/bson/primitive"
-
-type flatBSONTags struct {
-	ID primitive.ObjectID `bson:"_id"`
-
-	AA  int64  `bson:"AAgSNVyBb"`
-	AI  bool   `bson:"aicoMxZq"`
-	AM  int64  `bson:"AMQrGQmu"`
-	Ag  int    `bson:"AgYYbYPr"`
-	Ah  int64  `bson:"ahFCBmqT"`
-	At  int64  `bson:"AtWNZJXa"`
-	BB  string `bson:"BBqZInWV"`
-	BK  int64  `bson:"bkuaZWRT"`
-	Bw  int    `bson:"BwTXiovJ"`
-	CD  int    `bson:"CDIGOuIZ"`
-	CEA string `bson:"CEtYKsdd"`
-	CEB string `bson:"cepcgozk"`
-	CF  int    `bson:"CFujXoob"`
-	CV  int64  `bson:"cVjWCrlu"`
-	CX  string `bson:"cxOHMeDJ"`
-	CY  string `bson:"CYhSCkWB"`
-	Cq  string `bson:"CqCssWxW"`
-	DC  int    `bson:"dCLfYqqM"`
-	DDA int    `bson:"ddPdLgGg"`
-	DDB int    `bson:"ddVenEkK"`
-	DH  string `bson:"dHsYhRbV"`
-	DJ  int    `bson:"DJsnHZIC"`
-	DN  string `bson:"dNSuxlSU"`
-	DO  int64  `bson:"doshbrpF"`
-	DP  string `bson:"dpbwfSRb"`
-	DQ  int64  `bson:"DQBQcQFj"`
-	DT  string `bson:"dtywOLeD"`
-	DV  int    `bson:"dVkWIafN"`
-	EG  bool   `bson:"egxZaSsw"`
-	ER  string `bson:"eRTIdIJR"`
-	FD  int64  `bson:"FDYGeSiR"`
-	FE  string `bson:"fEheUtop"`
-	Fp  bool   `bson:"FpduyhQP"`
-	GE  string `bson:"gErhgZTh"`
-	GY  int    `bson:"gySFZeAE"`
-	Gi  uint   `bson:"GiAHzFII"`
-	HN  string `bson:"hnVgYIQi"`
-	HQA int    `bson:"HQeCoswW"`
-	HQB int    `bson:"HQiykral"`
-	HV  int64  `bson:"HVHyetUM"`
-	HW  int    `bson:"hwHOTmmW"`
-	Hi  bool   `bson:"HicJbMpj"`
-	Hr  int    `bson:"HrUPbFHD"`
-	IF  string `bson:"iFFGfTXc"`
-	IJ  int    `bson:"ijwXMKqI"`
-	IW  int    `bson:"iwfbMdcv"`
-	Ib  string `bson:"Ibrdrtgg"`
-	Is  bool   `bson:"IsorvnMR"`
-	JB  string `bson:"jbUymqiB"`
-	JM  string `bson:"jmglLvAS"`
-	JW  int    `bson:"jWaFvVAz"`
-	JX  int    `bson:"JXMyYkfb"`
-	Jh  bool   `bson:"JhImQOkw"`
-	Jr  string `bson:"JrJzKiIx"`
-	Jz  int    `bson:"JzgaUWVG"`
-	KF  bool   `bson:"kfvcFmKw"`
-	KM  int64  `bson:"KMKBtlov"`
-	Kn  string `bson:"KnhgtAOJ"`
-	Ky  int    `bson:"KyxOoCqS"`
-	LU  string `bson:"LUPqMOHS"`
-	LV  bool   `bson:"LVNIFCYm"`
-	Ln  int    `bson:"LngvlnTV"`
-	ML  int    `bson:"mlfZVfVT"`
-	MN  bool   `bson:"MNuWZMLP"`
-	MX  int    `bson:"MXMxLVBk"`
-	Mc  string `bson:"McpOBmaR"`
-	Me  string `bson:"MeUYSkPS"`
-	Mq  int    `bson:"MqfkBZJF"`
-	NB  int    `bson:"nBKWWUWk"`
-	NK  int    `bson:"nKhiSITP"`
-	OB  int    `bson:"obcwwqWZ"`
-	OC  string `bson:"OCsIhHxq"`
-	OM  int    `bson:"omnwvBbA"`
-	OR  string `bson:"oRWMNJTE"`
-	Of  string `bson:"OfTmCvDx"`
-	PA  int    `bson:"pacTBmxE"`
-	PF  int    `bson:"PFZSRHNN"`
-	PK  bool   `bson:"pKjOghFa"`
-	PO  int    `bson:"pOMEwSod"`
-	PP  string `bson:"pPtPsgRl"`
-	PQ  int    `bson:"pQyCJaEd"`
-	Pj  int    `bson:"PjKiuWnQ"`
-	Pv  int    `bson:"PvfnpsMV"`
-	QH  int    `bson:"qHzOMXeT"`
-	QR  bool   `bson:"qrJASGzU"`
-	Qo  string `bson:"QobifTeZ"`
-	RE  int64  `bson:"reiKnuza"`
-	RM  string `bson:"rmzUAgmk"`
-	RP  string `bson:"RPsQhgRD"`
-	Rb  uint   `bson:"Rbxpznea"`
-	ReA bool   `bson:"RemSsnnR"`
-	ReB int    `bson:"ReOZakjB"`
-	Rw  string `bson:"RwAVVKHM"`
-	SG  bool   `bson:"sGWJTAcT"`
-	SU  uint8  `bson:"SUWXijHT"`
-	SYA int64  `bson:"sYtnozSc"`
-	SYB string `bson:"SYtZkQbC"`
-	Sq  int64  `bson:"SqNvlUZF"`
-	TA  int    `bson:"taoNnQYY"`
-	TD  string `bson:"TDUzNJiH"`
-	TI  string `bson:"tIJEYSYM"`
-	TR  bool   `bson:"TRpgnInA"`
-	Tg  int    `bson:"TgSwBbgp"`
-	Tk  int64  `bson:"TkXMwZlU"`
-	Tm  int64  `bson:"TmUnYUrv"`
-	UK  int    `bson:"UKwbAKGw"`
-	UM  string `bson:"uMDWqLMf"`
-	Up  bool   `bson:"UpdMADoN"`
-	Ut  int64  `bson:"UtbwOKLt"`
-	VC  int64  `bson:"VCSKFCoE"`
-	VK  string `bson:"vkEDWgmN"`
-	VL  string `bson:"vlSZaxCV"`
-	VS  string `bson:"vSLTtfDF"`
-	VVA bool   `bson:"vvUeXASH"`
-	VVB int    `bson:"VVvwKVRG"`
-	Vc  bool   `bson:"VcCSqSmp"`
-	Vp  int16  `bson:"VplFgewF"`
-	Vt  string `bson:"VtzeOlCT"`
-	WH  bool   `bson:"WHSQVLKG"`
-	WJA bool   `bson:"wjfyueDC"`
-	WJB string `bson:"wjAWaOog"`
-	WM  int64  `bson:"wmDLUkXt"`
-	WY  string `bson:"WYJdGJLu"`
-	Wm  bool   `bson:"WmMOvgFc"`
-	Wo  string `bson:"WoFGfdvb"`
-	XE  int    `bson:"XEBqaXkB"`
-	XG  bool   `bson:"XGxlHrXf"`
-	XR  string `bson:"xrzGnsEK"`
-	XWA int64  `bson:"xWpeGNjl"`
-	XWB string `bson:"xWUlYggc"`
-	XX  int64  `bson:"XXKbyIXG"`
-	XZ  int64  `bson:"xZOksssj"`
-	Xe  uint   `bson:"XeRkAyCq"`
-	Xx  int    `bson:"XxvXmHiQ"`
-	YD  string `bson:"YDHWnEXV"`
-	YE  bool   `bson:"yeTUgNrU"`
-	YK  int    `bson:"yKfZnGKG"`
-	YX  string `bson:"yXSBbPeT"`
-	ZD  bool   `bson:"zDzSGNnW"`
-	ZE  bool   `bson:"zEgGhhZf"`
-	ZM  string `bson:"zMCFzcWY"`
-	ZSA int64  `bson:"zSYvADVf"`
-	ZSB int64  `bson:"zswQbWEI"`
-	Zm  string `bson:"ZmtEJFSO"`
-}
-
-type flatBSON struct {
-	AMQrGQmu  int64
-	AAgSNVyBb int64
-	AgYYbYPr  int
-	AtWNZJXa  int64
-	BBqZInWV  string
-	BwTXiovJ  int
-	CDIGOuIZ  int
-	CEtYKsdd  string
-	CFujXoob  int
-	CYhSCkWB  string
-	CqCssWxW  string
-	DJsnHZIC  int
-	DQBQcQFj  int64
-	FDYGeSiR  int64
-	FpduyhQP  bool
-	GiAHzFII  uint
-	HQeCoswW  int
-	HQiykral  int
-	HVHyetUM  int64
-	HicJbMpj  bool
-	HrUPbFHD  int
-	Ibrdrtgg  string
-	IsorvnMR  bool
-	JXMyYkfb  int
-	JhImQOkw  bool
-	JrJzKiIx  string
-	JzgaUWVG  int
-	KMKBtlov  int64
-	KnhgtAOJ  string
-	KyxOoCqS  int
-	LUPqMOHS  string
-	LVNIFCYm  bool
-	LngvlnTV  int
-	MNuWZMLP  bool
-	MXMxLVBk  int
-	McpOBmaR  string
-	MeUYSkPS  string
-	MqfkBZJF  int
-	OCsIhHxq  string
-	OfTmCvDx  string
-	PjKiuWnQ  int
-	PvfnpsMV  int
-	QobifTeZ  string
-	RPsQhgRD  string
-	Rbxpznea  uint
-	ReOZakjB  int
-	RemSsnnR  bool
-	RwAVVKHM  string
-	SUWXijHT  uint8
-	SYtZkQbC  string
-	SqNvlUZF  int64
-	TDUzNJiH  string
-	TRpgnInA  bool
-	TgSwBbgp  int
-	TkXMwZlU  int64
-	TmUnYUrv  int64
-	UKwbAKGw  int
-	UpdMADoN  bool
-	UtbwOKLt  int64
-	VCSKFCoE  int64
-	VVvwKVRG  int
-	VcCSqSmp  bool
-	VplFgewF  int16
-	VtzeOlCT  string
-	WHSQVLKG  bool
-	WYJdGJLu  string
-	WmMOvgFc  bool
-	WoFGfdvb  string
-	XEBqaXkB  int
-	XGxlHrXf  bool
-	XXKbyIXG  int64
-	XeRkAyCq  uint
-	XxvXmHiQ  int
-	YDHWnEXV  string
-	ZmtEJFSO  string
-	ID        primitive.ObjectID `bson:"_id"`
-	AhFCBmqT  int64
-	AicoMxZq  bool
-	BkuaZWRT  int64
-	CVjWCrlu  int64
-	Cepcgozk  string
-	CxOHMeDJ  string
-	DCLfYqqM  int
-	DHsYhRbV  string
-	DNSuxlSU  string
-	DVkWIafN  int
-	DdPdLgGg  int
-	DdVenEkK  int
-	DoshbrpF  int64
-	DpbwfSRb  string
-	DtywOLeD  string
-	ERTIdIJR  string
-	EgxZaSsw  bool
-	FEheUtop  string
-	GErhgZTh  string
-	GySFZeAE  int
-	HnVgYIQi  string
-	HwHOTmmW  int
-	IFFGfTXc  string
-	IjwXMKqI  int
-	IwfbMdcv  int
-	JWaFvVAz  int
-	JbUymqiB  string
-	JmglLvAS  string
-	KfvcFmKw  bool
-	MlfZVfVT  int
-	NBKWWUWk  int
-	NKhiSITP  int
-	ORWMNJTE  string
-	ObcwwqWZ  int
-	OmnwvBbA  int
-	PKjOghFa  bool
-	POMEwSod  int
-	PPtPsgRl  string
-	PQyCJaEd  int
-	PacTBmxE  int
-	QHzOMXeT  int
-	QrJASGzU  bool
-	ReiKnuza  int64
-	RmzUAgmk  string
-	SGWJTAcT  bool
-	SYtnozSc  int64
-	TIJEYSYM  string
-	TaoNnQYY  int
-	UMDWqLMf  string
-	VSLTtfDF  string
-	VkEDWgmN  string
-	VlSZaxCV  string
-	VvUeXASH  bool
-	WjAWaOog  string
-	WjfyueDC  bool
-	WmDLUkXt  int64
-	XWUlYggc  string
-	XWpeGNjl  int64
-	XZOksssj  int64
-	XrzGnsEK  string
-	YKfZnGKG  int
-	YXSBbPeT  string
-	YeTUgNrU  bool
-	ZDzSGNnW  bool
-	ZEgGhhZf  bool
-	ZMCFzcWY  string
-	ZSYvADVf  int64
-	ZswQbWEI  int64
-	PfZSRHnn  int
-}

+ 0 - 29
qyxy/src/mgoutil/go.mongodb.org/mongo-driver/benchmark/canary.go

@@ -1,29 +0,0 @@
-// Copyright (C) MongoDB, Inc. 2017-present.
-//
-// Licensed under the Apache License, Version 2.0 (the "License"); you may
-// not use this file except in compliance with the License. You may obtain
-// a copy of the License at http://www.apache.org/licenses/LICENSE-2.0
-
-package benchmark
-
-import (
-	"context"
-)
-
-func CanaryIncCase(ctx context.Context, tm TimerManager, iters int) error {
-	var canaryCount int
-	for i := 0; i < iters; i++ {
-		canaryCount++
-	}
-	return nil
-}
-
-var globalCanaryCount int
-
-func GlobalCanaryIncCase(ctx context.Context, tm TimerManager, iters int) error {
-	for i := 0; i < iters; i++ {
-		globalCanaryCount++
-	}
-
-	return nil
-}

+ 0 - 12
qyxy/src/mgoutil/go.mongodb.org/mongo-driver/benchmark/canary_test.go

@@ -1,12 +0,0 @@
-// Copyright (C) MongoDB, Inc. 2017-present.
-//
-// Licensed under the Apache License, Version 2.0 (the "License"); you may
-// not use this file except in compliance with the License. You may obtain
-// a copy of the License at http://www.apache.org/licenses/LICENSE-2.0
-
-package benchmark
-
-import "testing"
-
-func BenchmarkCanaryInc(b *testing.B)       { WrapCase(CanaryIncCase)(b) }
-func BenchmarkGlobalCanaryInc(b *testing.B) { WrapCase(GlobalCanaryIncCase)(b) }

+ 0 - 226
qyxy/src/mgoutil/go.mongodb.org/mongo-driver/benchmark/harness.go

@@ -1,226 +0,0 @@
-// Copyright (C) MongoDB, Inc. 2017-present.
-//
-// Licensed under the Apache License, Version 2.0 (the "License"); you may
-// not use this file except in compliance with the License. You may obtain
-// a copy of the License at http://www.apache.org/licenses/LICENSE-2.0
-
-package benchmark // import "go.mongodb.org/mongo-driver/benchmark"
-
-import (
-	"context"
-	"testing"
-	"time"
-
-	"github.com/stretchr/testify/require"
-)
-
-const (
-	five            = 5
-	ten             = 2 * five
-	hundred         = ten * ten
-	thousand        = ten * hundred
-	tenThousand     = ten * thousand
-	hundredThousand = hundred * thousand
-	million         = hundred * hundredThousand
-	halfMillion     = five * hundredThousand
-
-	ExecutionTimeout = five * time.Minute
-	StandardRuntime  = time.Minute
-	MinimumRuntime   = five * time.Second
-	MinIterations    = hundred
-)
-
-type BenchCase func(context.Context, TimerManager, int) error
-type BenchFunction func(*testing.B)
-
-func WrapCase(bench BenchCase) BenchFunction {
-	name := getName(bench)
-	return func(b *testing.B) {
-		ctx := context.Background()
-		b.ResetTimer()
-		err := bench(ctx, b, b.N)
-		require.NoError(b, err, "case='%s'", name)
-	}
-}
-
-func getAllCases() []*CaseDefinition {
-	return []*CaseDefinition{
-		{
-			Bench:              CanaryIncCase,
-			Count:              million,
-			Size:               -1,
-			Runtime:            MinimumRuntime,
-			RequiredIterations: ten,
-		},
-		{
-			Bench:              GlobalCanaryIncCase,
-			Count:              million,
-			Size:               -1,
-			Runtime:            MinimumRuntime,
-			RequiredIterations: ten,
-		},
-		{
-			Bench:   BSONFlatDocumentEncoding,
-			Count:   tenThousand,
-			Size:    75310000,
-			Runtime: StandardRuntime,
-		},
-		{
-			Bench:   BSONFlatDocumentDecodingLazy,
-			Count:   tenThousand,
-			Size:    75310000,
-			Runtime: StandardRuntime,
-		},
-		{
-			Bench:   BSONFlatDocumentDecoding,
-			Count:   tenThousand,
-			Size:    75310000,
-			Runtime: StandardRuntime,
-		},
-		{
-			Bench:   BSONDeepDocumentEncoding,
-			Count:   tenThousand,
-			Size:    19640000,
-			Runtime: StandardRuntime,
-		},
-		{
-			Bench:   BSONDeepDocumentDecodingLazy,
-			Count:   tenThousand,
-			Size:    19640000,
-			Runtime: StandardRuntime,
-		},
-		{
-			Bench:   BSONDeepDocumentDecoding,
-			Count:   tenThousand,
-			Size:    19640000,
-			Runtime: StandardRuntime,
-		},
-		// {
-		//	Bench:   BSONFullDocumentEncoding,
-		//	Count:   tenThousand,
-		//	Size:    57340000,
-		//	Runtime: StandardRuntime,
-		// },
-		// {
-		//	Bench:   BSONFullDocumentDecodingLazy,
-		//	Count:   tenThousand,
-		//	Size:    57340000,
-		//	Runtime: StandardRuntime,
-		// },
-		// {
-		//	Bench:   BSONFullDocumentDecoding,
-		//	Count:   tenThousand,
-		//	Size:    57340000,
-		//	Runtime: StandardRuntime,
-		// },
-		// {
-		//	Bench:   BSONFullReaderDecoding,
-		//	Count:   tenThousand,
-		//	Size:    57340000,
-		//	Runtime: StandardRuntime,
-		// },
-		{
-			Bench:   BSONFlatMapDecoding,
-			Count:   tenThousand,
-			Size:    75310000,
-			Runtime: StandardRuntime,
-		},
-		{
-			Bench:   BSONFlatMapEncoding,
-			Count:   tenThousand,
-			Size:    75310000,
-			Runtime: StandardRuntime,
-		},
-		{
-			Bench:   BSONDeepMapDecoding,
-			Count:   tenThousand,
-			Size:    19640000,
-			Runtime: StandardRuntime,
-		},
-		{
-			Bench:   BSONDeepMapEncoding,
-			Count:   tenThousand,
-			Size:    19640000,
-			Runtime: StandardRuntime,
-		},
-		// {
-		//	Bench:   BSONFullMapDecoding,
-		//	Count:   tenThousand,
-		//	Size:    57340000,
-		//	Runtime: StandardRuntime,
-		// },
-		// {
-		//	Bench:   BSONFullMapEncoding,
-		//	Count:   tenThousand,
-		//	Size:    57340000,
-		//	Runtime: StandardRuntime,
-		// },
-		{
-			Bench:   BSONFlatStructDecoding,
-			Count:   tenThousand,
-			Size:    75310000,
-			Runtime: StandardRuntime,
-		},
-		{
-			Bench:   BSONFlatStructTagsDecoding,
-			Count:   tenThousand,
-			Size:    75310000,
-			Runtime: StandardRuntime,
-		},
-		{
-			Bench:   BSONFlatStructEncoding,
-			Count:   tenThousand,
-			Size:    75310000,
-			Runtime: StandardRuntime,
-		},
-		{
-			Bench:   BSONFlatStructTagsEncoding,
-			Count:   tenThousand,
-			Size:    75310000,
-			Runtime: StandardRuntime,
-		},
-		{
-			Bench:   SingleRunCommand,
-			Count:   tenThousand,
-			Size:    160000,
-			Runtime: StandardRuntime,
-		},
-		{
-			Bench:   SingleFindOneByID,
-			Count:   tenThousand,
-			Size:    16220000,
-			Runtime: StandardRuntime,
-		},
-		{
-			Bench:   SingleInsertSmallDocument,
-			Count:   tenThousand,
-			Size:    2750000,
-			Runtime: StandardRuntime,
-		},
-		{
-			Bench:   SingleInsertLargeDocument,
-			Count:   ten,
-			Size:    27310890,
-			Runtime: StandardRuntime,
-		},
-		{
-			Bench:   MultiFindMany,
-			Count:   tenThousand,
-			Size:    16220000,
-			Runtime: StandardRuntime,
-		},
-		{
-			Bench:   MultiInsertSmallDocument,
-			Count:   tenThousand,
-			Size:    2750000,
-			Runtime: StandardRuntime,
-		},
-		{
-			Bench:              MultiInsertLargeDocument,
-			Count:              ten,
-			Size:               27310890,
-			Runtime:            StandardRuntime,
-			RequiredIterations: tenThousand,
-		},
-	}
-}

+ 0 - 154
qyxy/src/mgoutil/go.mongodb.org/mongo-driver/benchmark/harness_case.go

@@ -1,154 +0,0 @@
-// Copyright (C) MongoDB, Inc. 2017-present.
-//
-// Licensed under the Apache License, Version 2.0 (the "License"); you may
-// not use this file except in compliance with the License. You may obtain
-// a copy of the License at http://www.apache.org/licenses/LICENSE-2.0
-
-package benchmark
-
-import (
-	"context"
-	"fmt"
-	"path/filepath"
-	"reflect"
-	"runtime"
-	"strings"
-	"time"
-)
-
-type CaseDefinition struct {
-	Bench              BenchCase
-	Count              int
-	Size               int
-	RequiredIterations int
-	Runtime            time.Duration
-
-	cumulativeRuntime time.Duration
-	elapsed           time.Duration
-	startAt           time.Time
-	isRunning         bool
-}
-
-// TimerManager is a subset of the testing.B tool, used to manage
-// setup code.
-type TimerManager interface {
-	ResetTimer()
-	StartTimer()
-	StopTimer()
-}
-
-func (c *CaseDefinition) ResetTimer() {
-	c.startAt = time.Now()
-	c.elapsed = 0
-	c.isRunning = true
-}
-
-func (c *CaseDefinition) StartTimer() {
-	c.startAt = time.Now()
-	c.isRunning = true
-}
-
-func (c *CaseDefinition) StopTimer() {
-	if !c.isRunning {
-		return
-	}
-	c.elapsed += time.Since(c.startAt)
-	c.isRunning = false
-}
-
-func (c *CaseDefinition) roundedRuntime() time.Duration {
-	return roundDurationMS(c.Runtime)
-}
-
-func (c *CaseDefinition) Run(ctx context.Context) *BenchResult {
-	out := &BenchResult{
-		Trials:     1,
-		DataSize:   c.Size,
-		Name:       c.Name(),
-		Operations: c.Count,
-	}
-	var cancel context.CancelFunc
-	ctx, cancel = context.WithTimeout(ctx, 2*ExecutionTimeout)
-	defer cancel()
-
-	fmt.Println("=== RUN", out.Name)
-	if c.RequiredIterations == 0 {
-		c.RequiredIterations = MinIterations
-	}
-
-benchRepeat:
-	for {
-		if ctx.Err() != nil {
-			break
-		}
-		if c.cumulativeRuntime >= c.Runtime {
-			if out.Trials >= c.RequiredIterations {
-				break
-			} else if c.cumulativeRuntime >= ExecutionTimeout {
-				break
-			}
-		}
-
-		res := Result{
-			Iterations: c.Count,
-		}
-
-		c.StartTimer()
-		res.Error = c.Bench(ctx, c, c.Count)
-		c.StopTimer()
-		res.Duration = c.elapsed
-		c.cumulativeRuntime += res.Duration
-
-		switch res.Error {
-		case context.DeadlineExceeded:
-			break benchRepeat
-		case context.Canceled:
-			break benchRepeat
-		case nil:
-			out.Trials++
-			c.elapsed = 0
-			out.Raw = append(out.Raw, res)
-		default:
-			continue
-		}
-
-	}
-
-	out.Duration = out.totalDuration()
-	fmt.Printf("    --- REPORT: count=%d trials=%d requiredTrials=%d runtime=%s\n",
-		c.Count, out.Trials, c.RequiredIterations, c.Runtime)
-	if out.HasErrors() {
-		fmt.Printf("    --- ERRORS: %s\n", strings.Join(out.errReport(), "\n       "))
-		fmt.Printf("--- FAIL: %s (%s)\n", out.Name, out.roundedRuntime())
-	} else {
-		fmt.Printf("--- PASS: %s (%s)\n", out.Name, out.roundedRuntime())
-	}
-
-	return out
-
-}
-
-func (c *CaseDefinition) String() string {
-	return fmt.Sprintf("name=%s, count=%d, runtime=%s timeout=%s",
-		c.Name(), c.Count, c.Runtime, ExecutionTimeout)
-}
-
-func (c *CaseDefinition) Name() string { return getName(c.Bench) }
-func getName(i interface{}) string {
-	n := runtime.FuncForPC(reflect.ValueOf(i).Pointer()).Name()
-	parts := strings.Split(n, ".")
-	if len(parts) > 1 {
-		return parts[len(parts)-1]
-	}
-
-	return n
-
-}
-
-func getProjectRoot() string { return filepath.Dir(getDirectoryOfFile()) }
-
-func getDirectoryOfFile() string {
-	_, file, _, _ := runtime.Caller(1)
-
-	return filepath.Dir(file)
-}

+ 0 - 69
qyxy/src/mgoutil/go.mongodb.org/mongo-driver/benchmark/harness_main.go

@@ -1,69 +0,0 @@
-// Copyright (C) MongoDB, Inc. 2017-present.
-//
-// Licensed under the Apache License, Version 2.0 (the "License"); you may
-// not use this file except in compliance with the License. You may obtain
-// a copy of the License at http://www.apache.org/licenses/LICENSE-2.0
-
-package benchmark
-
-import (
-	"context"
-	"encoding/json"
-	"flag"
-	"fmt"
-	"io/ioutil"
-	"os"
-)
-
-func DriverBenchmarkMain() int {
-	var hasErrors bool
-	var outputFileName string
-	flag.StringVar(&outputFileName, "output", "perf.json", "path to write the 'perf.json' file")
-	flag.Parse()
-
-	ctx := context.Background()
-	output := []interface{}{}
-	for _, res := range runDriverCases(ctx) {
-		if res.HasErrors() {
-			hasErrors = true
-		}
-
-		evg, err := res.EvergreenPerfFormat()
-		if err != nil {
-			hasErrors = true
-			continue
-		}
-
-		output = append(output, evg...)
-	}
-
-	evgOutput, err := json.MarshalIndent(map[string]interface{}{"results": output}, "", "   ")
-	if err != nil {
-		return 1
-	}
-	evgOutput = append(evgOutput, []byte("\n")...)
-
-	if outputFileName == "" {
-		fmt.Println(string(evgOutput))
-	} else if err := ioutil.WriteFile(outputFileName, evgOutput, 0644); err != nil {
-		fmt.Fprintf(os.Stderr, "problem writing file '%s': %s", outputFileName, err.Error())
-		return 1
-	}
-
-	if hasErrors {
-		return 1
-	}
-
-	return 0
-}
-
-func runDriverCases(ctx context.Context) []*BenchResult {
-	cases := getAllCases()
-
-	results := []*BenchResult{}
-	for _, bc := range cases {
-		results = append(results, bc.Run(ctx))
-	}
-
-	return results
-}

+ 0 - 140
qyxy/src/mgoutil/go.mongodb.org/mongo-driver/benchmark/harness_results.go

@@ -1,140 +0,0 @@
-// Copyright (C) MongoDB, Inc. 2017-present.
-//
-// Licensed under the Apache License, Version 2.0 (the "License"); you may
-// not use this file except in compliance with the License. You may obtain
-// a copy of the License at http://www.apache.org/licenses/LICENSE-2.0
-
-package benchmark
-
-import (
-	"fmt"
-	"time"
-
-	"github.com/montanaflynn/stats"
-)
-
-type BenchResult struct {
-	Name       string
-	Trials     int
-	Duration   time.Duration
-	Raw        []Result
-	DataSize   int
-	Operations int
-	hasErrors  *bool
-}
-
-func (r *BenchResult) EvergreenPerfFormat() ([]interface{}, error) {
-	timings := r.timings()
-
-	median, err := stats.Median(timings)
-	if err != nil {
-		return nil, err
-	}
-
-	min, err := stats.Min(timings)
-	if err != nil {
-		return nil, err
-	}
-
-	max, err := stats.Max(timings)
-	if err != nil {
-		return nil, err
-	}
-
-	out := []interface{}{
-		map[string]interface{}{
-			"name": r.Name + "-throughput",
-			"results": map[string]interface{}{
-				"1": map[string]interface{}{
-					"seconds":        r.Duration.Round(time.Millisecond).Seconds(),
-					"ops_per_second": r.getThroughput(median),
-					"ops_per_second_values": []float64{
-						r.getThroughput(min),
-						r.getThroughput(max),
-					},
-				},
-			},
-		},
-	}
-
-	if r.DataSize > 0 {
-		out = append(out, interface{}(map[string]interface{}{
-			"name": r.Name + "-MB-adjusted",
-			"results": map[string]interface{}{
-				"1": map[string]interface{}{
-					"seconds":        r.Duration.Round(time.Millisecond).Seconds(),
-					"ops_per_second": r.adjustResults(median),
-					"ops_per_second_values": []float64{
-						r.adjustResults(min),
-						r.adjustResults(max),
-					},
-				},
-			},
-		}))
-	}
-
-	return out, nil
-}
-
-func (r *BenchResult) timings() []float64 {
-	out := []float64{}
-	for _, r := range r.Raw {
-		out = append(out, r.Duration.Seconds())
-	}
-	return out
-}
-
-func (r *BenchResult) totalDuration() time.Duration {
-	var out time.Duration
-	for _, trial := range r.Raw {
-		out += trial.Duration
-	}
-	return out
-}
-
-func (r *BenchResult) adjustResults(data float64) float64 { return float64(r.DataSize) / data }
-func (r *BenchResult) getThroughput(data float64) float64 { return float64(r.Operations) / data }
-func (r *BenchResult) roundedRuntime() time.Duration      { return roundDurationMS(r.Duration) }
-
-func (r *BenchResult) String() string {
-	return fmt.Sprintf("name=%s, trials=%d, secs=%s", r.Name, r.Trials, r.Duration)
-}
-
-func (r *BenchResult) HasErrors() bool {
-	if r.hasErrors == nil {
-		var val bool
-		for _, res := range r.Raw {
-			if res.Error != nil {
-				val = true
-				break
-			}
-		}
-		r.hasErrors = &val
-	}
-
-	return *r.hasErrors
-}
-
-func (r *BenchResult) errReport() []string {
-	errs := []string{}
-	for _, res := range r.Raw {
-		if res.Error != nil {
-			errs = append(errs, res.Error.Error())
-		}
-	}
-	return errs
-}
-
-type Result struct {
-	Duration   time.Duration
-	Iterations int
-	Error      error
-}
-
-func roundDurationMS(d time.Duration) time.Duration {
-	rounded := d.Round(time.Millisecond)
-	if rounded == 1<<63-1 {
-		return 0
-	}
-	return rounded
-}

+ 0 - 142
qyxy/src/mgoutil/go.mongodb.org/mongo-driver/benchmark/multi.go

@@ -1,142 +0,0 @@
-// Copyright (C) MongoDB, Inc. 2017-present.
-//
-// Licensed under the Apache License, Version 2.0 (the "License"); you may
-// not use this file except in compliance with the License. You may obtain
-// a copy of the License at http://www.apache.org/licenses/LICENSE-2.0
-
-package benchmark
-
-import (
-	"context"
-	"errors"
-
-	"go.mongodb.org/mongo-driver/x/bsonx"
-)
-
-func MultiFindMany(ctx context.Context, tm TimerManager, iters int) error {
-	ctx, cancel := context.WithCancel(ctx)
-	defer cancel()
-
-	db, err := getClientDB(ctx)
-	if err != nil {
-		return err
-	}
-	defer db.Client().Disconnect(ctx)
-
-	db = db.Client().Database("perftest")
-	if err = db.Drop(ctx); err != nil {
-		return err
-	}
-
-	doc, err := loadSourceDocument(getProjectRoot(), perfDataDir, singleAndMultiDataDir, tweetData)
-	if err != nil {
-		return err
-	}
-
-	coll := db.Collection("corpus")
-
-	payload := make([]interface{}, iters)
-	for idx := range payload {
-		payload[idx] = doc
-	}
-
-	if _, err = coll.InsertMany(ctx, payload); err != nil {
-		return err
-	}
-
-	tm.ResetTimer()
-
-	cursor, err := coll.Find(ctx, bsonx.Doc{})
-	if err != nil {
-		return err
-	}
-	defer cursor.Close(ctx)
-
-	counter := 0
-	for cursor.Next(ctx) {
-		err = cursor.Err()
-		if err != nil {
-			return err
-		}
-		if len(cursor.Current) == 0 {
-			return errors.New("error retrieving document")
-		}
-
-		counter++
-	}
-
-	if counter != iters {
-		return errors.New("problem iterating cursors")
-
-	}
-
-	tm.StopTimer()
-
-	if err = cursor.Close(ctx); err != nil {
-		return err
-	}
-
-	if err = db.Drop(ctx); err != nil {
-		return err
-	}
-
-	return nil
-}
-
-func multiInsertCase(ctx context.Context, tm TimerManager, iters int, data string) error {
-	ctx, cancel := context.WithCancel(ctx)
-	defer cancel()
-
-	db, err := getClientDB(ctx)
-	if err != nil {
-		return err
-	}
-	defer db.Client().Disconnect(ctx)
-
-	db = db.Client().Database("perftest")
-	if err = db.Drop(ctx); err != nil {
-		return err
-	}
-
-	doc, err := loadSourceDocument(getProjectRoot(), perfDataDir, singleAndMultiDataDir, data)
-	if err != nil {
-		return err
-	}
-
-	err = db.RunCommand(ctx, bsonx.Doc{{"create", bsonx.String("corpus")}}).Err()
-	if err != nil {
-		return err
-	}
-
-	payload := make([]interface{}, iters)
-	for idx := range payload {
-		payload[idx] = doc
-	}
-
-	coll := db.Collection("corpus")
-
-	tm.ResetTimer()
-	res, err := coll.InsertMany(ctx, payload)
-	if err != nil {
-		return err
-	}
-	tm.StopTimer()
-
-	if len(res.InsertedIDs) != iters {
-		return errors.New("bulk operation did not complete")
-	}
-
-	if err = db.Drop(ctx); err != nil {
-		return err
-	}
-
-	return nil
-}
-
-func MultiInsertSmallDocument(ctx context.Context, tm TimerManager, iters int) error {
-	return multiInsertCase(ctx, tm, iters, smallData)
-}
-
-func MultiInsertLargeDocument(ctx context.Context, tm TimerManager, iters int) error {
-	return multiInsertCase(ctx, tm, iters, largeData)
-}

+ 0 - 13
qyxy/src/mgoutil/go.mongodb.org/mongo-driver/benchmark/multi_test.go

@@ -1,13 +0,0 @@
-// Copyright (C) MongoDB, Inc. 2017-present.
-//
-// Licensed under the Apache License, Version 2.0 (the "License"); you may
-// not use this file except in compliance with the License. You may obtain
-// a copy of the License at http://www.apache.org/licenses/LICENSE-2.0
-
-package benchmark
-
-import "testing"
-
-func BenchmarkMultiFindMany(b *testing.B)            { WrapCase(MultiFindMany)(b) }
-func BenchmarkMultiInsertSmallDocument(b *testing.B) { WrapCase(MultiInsertSmallDocument)(b) }
-func BenchmarkMultiInsertLargeDocument(b *testing.B) { WrapCase(MultiInsertLargeDocument)(b) }

+ 0 - 174
qyxy/src/mgoutil/go.mongodb.org/mongo-driver/benchmark/single.go

@@ -1,174 +0,0 @@
-// Copyright (C) MongoDB, Inc. 2017-present.
-//
-// Licensed under the Apache License, Version 2.0 (the "License"); you may
-// not use this file except in compliance with the License. You may obtain
-// a copy of the License at http://www.apache.org/licenses/LICENSE-2.0
-
-package benchmark
-
-import (
-	"context"
-	"errors"
-
-	"go.mongodb.org/mongo-driver/internal/testutil"
-	"go.mongodb.org/mongo-driver/mongo"
-	"go.mongodb.org/mongo-driver/mongo/options"
-	"go.mongodb.org/mongo-driver/x/bsonx"
-)
-
-const (
-	singleAndMultiDataDir = "single_and_multi_document"
-	tweetData             = "tweet.json"
-	smallData             = "small_doc.json"
-	largeData             = "large_doc.json"
-)
-
-func getClientDB(ctx context.Context) (*mongo.Database, error) {
-	cs, err := testutil.GetConnString()
-	if err != nil {
-		return nil, err
-	}
-	client, err := mongo.NewClient(options.Client().ApplyURI(cs.String()))
-	if err != nil {
-		return nil, err
-	}
-	if err = client.Connect(ctx); err != nil {
-		return nil, err
-	}
-
-	db := client.Database(testutil.GetDBName(cs))
-	return db, nil
-}
-
-func SingleRunCommand(ctx context.Context, tm TimerManager, iters int) error {
-	ctx, cancel := context.WithCancel(ctx)
-	defer cancel()
-
-	db, err := getClientDB(ctx)
-	if err != nil {
-		return err
-	}
-	defer db.Client().Disconnect(ctx)
-
-	cmd := bsonx.Doc{{"ismaster", bsonx.Boolean(true)}}
-
-	tm.ResetTimer()
-	for i := 0; i < iters; i++ {
-		var doc bsonx.Doc
-		err := db.RunCommand(ctx, cmd).Decode(&doc)
-		if err != nil {
-			return err
-		}
-		// read the document and then throw it away to prevent
-		out, err := doc.MarshalBSON()
-		if len(out) == 0 {
-			return errors.New("output of ismaster is empty")
-		}
-	}
-	tm.StopTimer()
-
-	return nil
-}
-
-func SingleFindOneByID(ctx context.Context, tm TimerManager, iters int) error {
-	ctx, cancel := context.WithCancel(ctx)
-	defer cancel()
-
-	db, err := getClientDB(ctx)
-	if err != nil {
-		return err
-	}
-
-	db = db.Client().Database("perftest")
-	if err = db.Drop(ctx); err != nil {
-		return err
-	}
-
-	doc, err := loadSourceDocument(getProjectRoot(), perfDataDir, singleAndMultiDataDir, tweetData)
-	if err != nil {
-		return err
-	}
-	coll := db.Collection("corpus")
-	for i := 0; i < iters; i++ {
-		id := int32(i)
-		res, err := coll.InsertOne(ctx, doc.Set("_id", bsonx.Int32(id)))
-		if err != nil {
-			return err
-		}
-		if res.InsertedID == nil {
-			return errors.New("insert failed")
-		}
-	}
-
-	tm.ResetTimer()
-
-	for i := 0; i < iters; i++ {
-		res := coll.FindOne(ctx, bsonx.Doc{{"_id", bsonx.Int32(int32(i))}})
-		if res == nil {
-			return errors.New("find one query produced nil result")
-		}
-	}
-
-	tm.StopTimer()
-
-	if err = db.Drop(ctx); err != nil {
-		return err
-	}
-
-	return nil
-}
-
-func singleInsertCase(ctx context.Context, tm TimerManager, iters int, data string) error {
-	ctx, cancel := context.WithCancel(ctx)
-	defer cancel()
-
-	db, err := getClientDB(ctx)
-	if err != nil {
-		return err
-	}
-	defer db.Client().Disconnect(ctx)
-
-	db = db.Client().Database("perftest")
-	if err = db.Drop(ctx); err != nil {
-		return err
-	}
-
-	doc, err := loadSourceDocument(getProjectRoot(), perfDataDir, singleAndMultiDataDir, data)
-	if err != nil {
-		return err
-	}
-
-	err = db.RunCommand(ctx, bsonx.Doc{{"create", bsonx.String("corpus")}}).Err()
-	if err != nil {
-		return err
-	}
-
-	coll := db.Collection("corpus")
-
-	tm.ResetTimer()
-
-	for i := 0; i < iters; i++ {
-		if _, err = coll.InsertOne(ctx, doc); err != nil {
-			return err
-		}
-
-		// TODO: should be remove after resolving GODRIVER-468
-		_ = doc.Delete("_id")
-	}
-
-	tm.StopTimer()
-
-	if err = db.Drop(ctx); err != nil {
-		return err
-	}
-
-	return nil
-}
-
-func SingleInsertSmallDocument(ctx context.Context, tm TimerManager, iters int) error {
-	return singleInsertCase(ctx, tm, iters, smallData)
-}
-
-func SingleInsertLargeDocument(ctx context.Context, tm TimerManager, iters int) error {
-	return singleInsertCase(ctx, tm, iters, largeData)
-}

+ 0 - 14
qyxy/src/mgoutil/go.mongodb.org/mongo-driver/benchmark/single_test.go

@@ -1,14 +0,0 @@
-// Copyright (C) MongoDB, Inc. 2017-present.
-//
-// Licensed under the Apache License, Version 2.0 (the "License"); you may
-// not use this file except in compliance with the License. You may obtain
-// a copy of the License at http://www.apache.org/licenses/LICENSE-2.0
-
-package benchmark
-
-import "testing"
-
-func BenchmarkSingleRunCommand(b *testing.B)          { WrapCase(SingleRunCommand)(b) }
-func BenchmarkSingleFindOneByID(b *testing.B)         { WrapCase(SingleFindOneByID)(b) }
-func BenchmarkSingleInsertSmallDocument(b *testing.B) { WrapCase(SingleInsertSmallDocument)(b) }
-func BenchmarkSingleInsertLargeDocument(b *testing.B) { WrapCase(SingleInsertLargeDocument)(b) }

+ 0 - 134
qyxy/src/mgoutil/go.mongodb.org/mongo-driver/bson/benchmark_test.go

@@ -1,134 +0,0 @@
-// Copyright (C) MongoDB, Inc. 2017-present.
-//
-// Licensed under the Apache License, Version 2.0 (the "License"); you may
-// not use this file except in compliance with the License. You may obtain
-// a copy of the License at http://www.apache.org/licenses/LICENSE-2.0
-
-package bson
-
-import (
-	"testing"
-)
-
-type encodetest struct {
-	Field1String  string
-	Field1Int64   int64
-	Field1Float64 float64
-	Field2String  string
-	Field2Int64   int64
-	Field2Float64 float64
-	Field3String  string
-	Field3Int64   int64
-	Field3Float64 float64
-	Field4String  string
-	Field4Int64   int64
-	Field4Float64 float64
-}
-
-type nestedtest1 struct {
-	Nested nestedtest2
-}
-
-type nestedtest2 struct {
-	Nested nestedtest3
-}
-
-type nestedtest3 struct {
-	Nested nestedtest4
-}
-
-type nestedtest4 struct {
-	Nested nestedtest5
-}
-
-type nestedtest5 struct {
-	Nested nestedtest6
-}
-
-type nestedtest6 struct {
-	Nested nestedtest7
-}
-
-type nestedtest7 struct {
-	Nested nestedtest8
-}
-
-type nestedtest8 struct {
-	Nested nestedtest9
-}
-
-type nestedtest9 struct {
-	Nested nestedtest10
-}
-
-type nestedtest10 struct {
-	Nested nestedtest11
-}
-
-type nestedtest11 struct {
-	Nested encodetest
-}
-
-var encodetestInstance = encodetest{
-	Field1String:  "foo",
-	Field1Int64:   1,
-	Field1Float64: 3.0,
-	Field2String:  "bar",
-	Field2Int64:   2,
-	Field2Float64: 3.1,
-	Field3String:  "baz",
-	Field3Int64:   3,
-	Field3Float64: 3.14,
-	Field4String:  "qux",
-	Field4Int64:   4,
-	Field4Float64: 3.141,
-}
-
-var nestedInstance = nestedtest1{
-	nestedtest2{
-		nestedtest3{
-			nestedtest4{
-				nestedtest5{
-					nestedtest6{
-						nestedtest7{
-							nestedtest8{
-								nestedtest9{
-									nestedtest10{
-										nestedtest11{
-											encodetest{
-												Field1String:  "foo",
-												Field1Int64:   1,
-												Field1Float64: 3.0,
-												Field2String:  "bar",
-												Field2Int64:   2,
-												Field2Float64: 3.1,
-												Field3String:  "baz",
-												Field3Int64:   3,
-												Field3Float64: 3.14,
-												Field4String:  "qux",
-												Field4Int64:   4,
-												Field4Float64: 3.141,
-											},
-										},
-									},
-								},
-							},
-						},
-					},
-				},
-			},
-		},
-	},
-}
-
-func BenchmarkEncoding(b *testing.B) {
-	for i := 0; i < b.N; i++ {
-		_, _ = Marshal(encodetestInstance)
-	}
-}
-
-func BenchmarkEncodingNested(b *testing.B) {
-	for i := 0; i < b.N; i++ {
-		_, _ = Marshal(nestedInstance)
-	}
-}

+ 0 - 60
qyxy/src/mgoutil/go.mongodb.org/mongo-driver/bson/bson.go

@@ -1,60 +0,0 @@
-// Copyright (C) MongoDB, Inc. 2017-present.
-//
-// Licensed under the Apache License, Version 2.0 (the "License"); you may
-// not use this file except in compliance with the License. You may obtain
-// a copy of the License at http://www.apache.org/licenses/LICENSE-2.0
-//
-// Based on gopkg.in/mgo.v2/bson by Gustavo Niemeyer
-// See THIRD-PARTY-NOTICES for original license terms.
-
-// +build go1.9
-
-package bson // import "go.mongodb.org/mongo-driver/bson"
-
-import (
-	"go.mongodb.org/mongo-driver/bson/primitive"
-)
-
-// Zeroer allows custom struct types to implement a report of zero
-// state. All struct types that don't implement Zeroer or where IsZero
-// returns false are considered to be not zero.
-type Zeroer interface {
-	IsZero() bool
-}
-
-// D represents a BSON Document. This type can be used to represent BSON in a concise and readable
-// manner. It should generally be used when serializing to BSON. For deserializing, the Raw or
-// Document types should be used.
-//
-// Example usage:
-//
-// 		bson.D{{"foo", "bar"}, {"hello", "world"}, {"pi", 3.14159}}
-//
-// This type should be used in situations where order matters, such as MongoDB commands. If the
-// order is not important, a map is more comfortable and concise.
-type D = primitive.D
-
-// E represents a BSON element for a D. It is usually used inside a D.
-type E = primitive.E
-
-// M is an unordered, concise representation of a BSON Document. It should generally be used to
-// serialize BSON when the order of the elements of a BSON document do not matter. If the element
-// order matters, use a D instead.
-//
-// Example usage:
-//
-// 		bson.M{"foo": "bar", "hello": "world", "pi": 3.14159}
-//
-// This type is handled in the encoders as a regular map[string]interface{}. The elements will be
-// serialized in an undefined, random order, and the order will be different each time.
-type M = primitive.M
-
-// An A represents a BSON array. This type can be used to represent a BSON array in a concise and
-// readable manner. It should generally be used when serializing to BSON. For deserializing, the
-// RawArray or Array types should be used.
-//
-// Example usage:
-//
-// 		bson.A{"bar", "world", 3.14159, bson.D{{"qux", 12345}}}
-//
-type A = primitive.A

+ 0 - 91
qyxy/src/mgoutil/go.mongodb.org/mongo-driver/bson/bson_1_8.go

@@ -1,91 +0,0 @@
-// Copyright (C) MongoDB, Inc. 2017-present.
-//
-// Licensed under the Apache License, Version 2.0 (the "License"); you may
-// not use this file except in compliance with the License. You may obtain
-// a copy of the License at http://www.apache.org/licenses/LICENSE-2.0
-
-// +build !go1.9
-
-package bson // import "go.mongodb.org/mongo-driver/bson"
-
-import (
-	"math"
-	"strconv"
-	"strings"
-)
-
-// Zeroer allows custom struct types to implement a report of zero
-// state. All struct types that don't implement Zeroer or where IsZero
-// returns false are considered to be not zero.
-type Zeroer interface {
-	IsZero() bool
-}
-
-// D represents a BSON Document. This type can be used to represent BSON in a concise and readable
-// manner. It should generally be used when serializing to BSON. For deserializing, the Raw or
-// Document types should be used.
-//
-// Example usage:
-//
-// 		primitive.D{{"foo", "bar"}, {"hello", "world"}, {"pi", 3.14159}}
-//
-// This type should be used in situations where order matters, such as MongoDB commands. If the
-// order is not important, a map is more comfortable and concise.
-type D []E
-
-// Map creates a map from the elements of the D.
-func (d D) Map() M {
-	m := make(M, len(d))
-	for _, e := range d {
-		m[e.Key] = e.Value
-	}
-	return m
-}
-
-// E represents a BSON element for a D. It is usually used inside a D.
-type E struct {
-	Key   string
-	Value interface{}
-}
-
-// M is an unordered, concise representation of a BSON Document. It should generally be used to
-// serialize BSON when the order of the elements of a BSON document do not matter. If the element
-// order matters, use a D instead.
-//
-// Example usage:
-//
-// 		primitive.M{"foo": "bar", "hello": "world", "pi": 3.14159}
-//
-// This type is handled in the encoders as a regular map[string]interface{}. The elements will be
-// serialized in an undefined, random order, and the order will be different each time.
-type M map[string]interface{}
-
-// An A represents a BSON array. This type can be used to represent a BSON array in a concise and
-// readable manner. It should generally be used when serializing to BSON. For deserializing, the
-// RawArray or Array types should be used.
-//
-// Example usage:
-//
-// 		primitive.A{"bar", "world", 3.14159, primitive.D{{"qux", 12345}}}
-//
-type A []interface{}
-
-func formatDouble(f float64) string {
-	var s string
-	if math.IsInf(f, 1) {
-		s = "Infinity"
-	} else if math.IsInf(f, -1) {
-		s = "-Infinity"
-	} else if math.IsNaN(f) {
-		s = "NaN"
-	} else {
-		// Print exactly one decimalType place for integers; otherwise, print as many are necessary to
-		// perfectly represent it.
-		s = strconv.FormatFloat(f, 'G', -1, 64)
-		if !strings.ContainsRune(s, '.') {
-			s += ".0"
-		}
-	}
-
-	return s
-}

+ 0 - 371
qyxy/src/mgoutil/go.mongodb.org/mongo-driver/bson/bson_corpus_spec_test.go

@@ -1,371 +0,0 @@
-// Copyright (C) MongoDB, Inc. 2017-present.
-//
-// Licensed under the Apache License, Version 2.0 (the "License"); you may
-// not use this file except in compliance with the License. You may obtain
-// a copy of the License at http://www.apache.org/licenses/LICENSE-2.0
-
-package bson
-
-import (
-	"encoding/hex"
-	"encoding/json"
-	"fmt"
-	"io/ioutil"
-	"math"
-	"path"
-	"strconv"
-	"strings"
-	"testing"
-	"unicode"
-	"unicode/utf8"
-
-	"github.com/google/go-cmp/cmp"
-	"github.com/stretchr/testify/require"
-	"github.com/tidwall/pretty"
-	"go.mongodb.org/mongo-driver/bson/bsoncodec"
-	"go.mongodb.org/mongo-driver/bson/bsonrw"
-)
-
-type testCase struct {
-	Description  string                `json:"description"`
-	BsonType     string                `json:"bson_type"`
-	TestKey      *string               `json:"test_key"`
-	Valid        []validityTestCase    `json:"valid"`
-	DecodeErrors []decodeErrorTestCase `json:"decodeErrors"`
-	ParseErrors  []parseErrorTestCase  `json:"parseErrors"`
-	Deprecated   *bool                 `json:"deprecated"`
-}
-
-type validityTestCase struct {
-	Description       string  `json:"description"`
-	CanonicalBson     string  `json:"canonical_bson"`
-	CanonicalExtJSON  string  `json:"canonical_extjson"`
-	RelaxedExtJSON    *string `json:"relaxed_extjson"`
-	DegenerateBSON    *string `json:"degenerate_bson"`
-	DegenerateExtJSON *string `json:"degenerate_extjson"`
-	ConvertedBSON     *string `json:"converted_bson"`
-	ConvertedExtJSON  *string `json:"converted_extjson"`
-	Lossy             *bool   `json:"lossy"`
-}
-
-type decodeErrorTestCase struct {
-	Description string `json:"description"`
-	Bson        string `json:"bson"`
-}
-
-type parseErrorTestCase struct {
-	Description string `json:"description"`
-	String      string `json:"string"`
-}
-
-const dataDir = "../data"
-
-var dvd bsoncodec.DefaultValueDecoders
-var dve bsoncodec.DefaultValueEncoders
-
-var dc = bsoncodec.DecodeContext{Registry: NewRegistryBuilder().Build()}
-var ec = bsoncodec.EncodeContext{Registry: NewRegistryBuilder().Build()}
-
-func findJSONFilesInDir(t *testing.T, dir string) []string {
-	files := make([]string, 0)
-
-	entries, err := ioutil.ReadDir(dir)
-	require.NoError(t, err)
-
-	for _, entry := range entries {
-		if entry.IsDir() || path.Ext(entry.Name()) != ".json" {
-			continue
-		}
-
-		files = append(files, entry.Name())
-	}
-
-	return files
-}
-
-func needsEscapedUnicode(bsonType string) bool {
-	return bsonType == "0x02" || bsonType == "0x0D" || bsonType == "0x0E" || bsonType == "0x0F"
-}
-
-func unescapeUnicode(s, bsonType string) string {
-	if !needsEscapedUnicode(bsonType) {
-		return s
-	}
-
-	newS := ""
-
-	for i := 0; i < len(s); i++ {
-		c := s[i]
-		switch c {
-		case '\\':
-			switch s[i+1] {
-			case 'u':
-				us := s[i : i+6]
-				u, err := strconv.Unquote(strings.Replace(strconv.Quote(us), `\\u`, `\u`, 1))
-				if err != nil {
-					return ""
-				}
-				for _, r := range u {
-					if r < ' ' {
-						newS += fmt.Sprintf(`\u%04x`, r)
-					} else {
-						newS += string(r)
-					}
-				}
-				i += 5
-			default:
-				newS += string(c)
-			}
-		default:
-			if c > unicode.MaxASCII {
-				r, size := utf8.DecodeRune([]byte(s[i:]))
-				newS += string(r)
-				i += size - 1
-			} else {
-				newS += string(c)
-			}
-		}
-	}
-
-	return newS
-}
-
-func formatDouble(f float64) string {
-	var s string
-	if math.IsInf(f, 1) {
-		s = "Infinity"
-	} else if math.IsInf(f, -1) {
-		s = "-Infinity"
-	} else if math.IsNaN(f) {
-		s = "NaN"
-	} else {
-		// Print exactly one decimalType place for integers; otherwise, print as many are necessary to
-		// perfectly represent it.
-		s = strconv.FormatFloat(f, 'G', -1, 64)
-		if !strings.ContainsRune(s, 'E') && !strings.ContainsRune(s, '.') {
-			s += ".0"
-		}
-	}
-
-	return s
-}
-
-func normalizeCanonicalDouble(t *testing.T, key string, cEJ string) string {
-	// Unmarshal string into map
-	cEJMap := make(map[string]map[string]string)
-	err := json.Unmarshal([]byte(cEJ), &cEJMap)
-	require.NoError(t, err)
-
-	// Parse the float contained by the map.
-	expectedString := cEJMap[key]["$numberDouble"]
-	expectedFloat, err := strconv.ParseFloat(expectedString, 64)
-
-	// Normalize the string
-	return fmt.Sprintf(`{"%s":{"$numberDouble":"%s"}}`, key, formatDouble(expectedFloat))
-}
-
-func normalizeRelaxedDouble(t *testing.T, key string, rEJ string) string {
-	// Unmarshal string into map
-	rEJMap := make(map[string]float64)
-	err := json.Unmarshal([]byte(rEJ), &rEJMap)
-	if err != nil {
-		return normalizeCanonicalDouble(t, key, rEJ)
-	}
-
-	// Parse the float contained by the map.
-	expectedFloat := rEJMap[key]
-
-	// Normalize the string
-	return fmt.Sprintf(`{"%s":%s}`, key, formatDouble(expectedFloat))
-}
-
-// bsonToNative decodes the BSON bytes (b) into a native Document
-func bsonToNative(t *testing.T, b []byte, bType, testDesc string) D {
-	var doc D
-	err := Unmarshal(b, &doc)
-	expectNoError(t, err, fmt.Sprintf("%s: decoding %s BSON", testDesc, bType))
-	return doc
-}
-
-// nativeToBSON encodes the native Document (doc) into canonical BSON and compares it to the expected
-// canonical BSON (cB)
-func nativeToBSON(t *testing.T, cB []byte, doc D, testDesc, bType, docSrcDesc string) {
-	actual, err := Marshal(doc)
-	expectNoError(t, err, fmt.Sprintf("%s: encoding %s BSON", testDesc, bType))
-
-	if diff := cmp.Diff(cB, actual); diff != "" {
-		t.Errorf("%s: 'native_to_bson(%s) = cB' failed (-want, +got):\n-%v\n+%v\n",
-			testDesc, docSrcDesc, cB, actual)
-		t.FailNow()
-	}
-}
-
-// jsonToNative decodes the extended JSON string (ej) into a native Document
-func jsonToNative(t *testing.T, ej, ejType, testDesc string) D {
-	var doc D
-	err := UnmarshalExtJSON([]byte(ej), ejType != "relaxed", &doc)
-	expectNoError(t, err, fmt.Sprintf("%s: decoding %s extended JSON", testDesc, ejType))
-	return doc
-}
-
-// nativeToJSON encodes the native Document (doc) into an extended JSON string
-func nativeToJSON(t *testing.T, ej string, doc D, testDesc, ejType, ejShortName, docSrcDesc string) {
-	actualEJ, err := MarshalExtJSON(doc, ejType != "relaxed", true)
-	expectNoError(t, err, fmt.Sprintf("%s: encoding %s extended JSON", testDesc, ejType))
-
-	if diff := cmp.Diff(ej, string(actualEJ)); diff != "" {
-		t.Errorf("%s: 'native_to_%s_extended_json(%s) = %s' failed (-want, +got):\n%s\n",
-			testDesc, ejType, docSrcDesc, ejShortName, diff)
-		t.FailNow()
-	}
-}
-
-func runTest(t *testing.T, file string) {
-	filepath := path.Join(dataDir, file)
-	content, err := ioutil.ReadFile(filepath)
-	require.NoError(t, err)
-
-	// Remove ".json" from filename.
-	file = file[:len(file)-5]
-	testName := "bson_corpus--" + file
-
-	t.Run(testName, func(t *testing.T) {
-		var test testCase
-		require.NoError(t, json.Unmarshal(content, &test))
-
-		for _, v := range test.Valid {
-			// get canonical BSON
-			cB, err := hex.DecodeString(v.CanonicalBson)
-			expectNoError(t, err, fmt.Sprintf("%s: reading canonical BSON", v.Description))
-
-			// get canonical extended JSON
-			cEJ := unescapeUnicode(string(pretty.Ugly([]byte(v.CanonicalExtJSON))), test.BsonType)
-			if test.BsonType == "0x01" {
-				cEJ = normalizeCanonicalDouble(t, *test.TestKey, cEJ)
-			}
-
-			/*** canonical BSON round-trip tests ***/
-			doc := bsonToNative(t, cB, "canonical", v.Description)
-
-			// native_to_bson(bson_to_native(cB)) = cB
-			nativeToBSON(t, cB, doc, v.Description, "canonical", "bson_to_native(cB)")
-
-			// native_to_canonical_extended_json(bson_to_native(cB)) = cEJ
-			nativeToJSON(t, cEJ, doc, v.Description, "canonical", "cEJ", "bson_to_native(cB)")
-
-			// native_to_relaxed_extended_json(bson_to_native(cB)) = rEJ (if rEJ exists)
-			if v.RelaxedExtJSON != nil {
-				rEJ := unescapeUnicode(string(pretty.Ugly([]byte(*v.RelaxedExtJSON))), test.BsonType)
-				if test.BsonType == "0x01" {
-					rEJ = normalizeRelaxedDouble(t, *test.TestKey, rEJ)
-				}
-
-				nativeToJSON(t, rEJ, doc, v.Description, "relaxed", "rEJ", "bson_to_native(cB)")
-
-				/*** relaxed extended JSON round-trip tests (if exists) ***/
-				doc = jsonToNative(t, rEJ, "relaxed", v.Description)
-
-				// native_to_relaxed_extended_json(json_to_native(rEJ)) = rEJ
-				nativeToJSON(t, rEJ, doc, v.Description, "relaxed", "eJR", "json_to_native(rEJ)")
-			}
-
-			/*** canonical extended JSON round-trip tests ***/
-			doc = jsonToNative(t, cEJ, "canonical", v.Description)
-
-			// native_to_canonical_extended_json(json_to_native(cEJ)) = cEJ
-			nativeToJSON(t, cEJ, doc, v.Description, "canonical", "cEJ", "json_to_native(cEJ)")
-
-			// native_to_bson(json_to_native(cEJ)) = cb (unless lossy)
-			if v.Lossy == nil || !*v.Lossy {
-				nativeToBSON(t, cB, doc, v.Description, "canonical", "json_to_native(cEJ)")
-			}
-
-			/*** degenerate BSON round-trip tests (if exists) ***/
-			if v.DegenerateBSON != nil {
-				dB, err := hex.DecodeString(*v.DegenerateBSON)
-				expectNoError(t, err, fmt.Sprintf("%s: reading degenerate BSON", v.Description))
-
-				doc = bsonToNative(t, dB, "degenerate", v.Description)
-
-				// native_to_bson(bson_to_native(dB)) = cB
-				nativeToBSON(t, cB, doc, v.Description, "degenerate", "bson_to_native(dB)")
-			}
-
-			/*** degenerate JSON round-trip tests (if exists) ***/
-			if v.DegenerateExtJSON != nil {
-				dEJ := unescapeUnicode(string(pretty.Ugly([]byte(*v.DegenerateExtJSON))), test.BsonType)
-				if test.BsonType == "0x01" {
-					dEJ = normalizeCanonicalDouble(t, *test.TestKey, dEJ)
-				}
-
-				doc = jsonToNative(t, dEJ, "degenerate canonical", v.Description)
-
-				// native_to_canonical_extended_json(json_to_native(dEJ)) = cEJ
-				nativeToJSON(t, cEJ, doc, v.Description, "degenerate canonical", "cEJ", "json_to_native(dEJ)")
-
-				// native_to_bson(json_to_native(dEJ)) = cB (unless lossy)
-				if v.Lossy == nil || !*v.Lossy {
-					nativeToBSON(t, cB, doc, v.Description, "canonical", "json_to_native(dEJ)")
-				}
-			}
-		}
-
-		for _, d := range test.DecodeErrors {
-			b, err := hex.DecodeString(d.Bson)
-			expectNoError(t, err, d.Description)
-
-			var doc D
-			err = Unmarshal(b, &doc)
-			expectError(t, err, fmt.Sprintf("%s: expected decode error", d.Description))
-		}
-
-		for _, p := range test.ParseErrors {
-			// skip DBRef tests
-			if strings.Contains(p.Description, "Bad DBRef") {
-				continue
-			}
-
-			s := unescapeUnicode(p.String, test.BsonType)
-			if test.BsonType == "0x13" {
-				s = fmt.Sprintf(`{"$numberDecimal": "%s"}`, s)
-			}
-
-			switch test.BsonType {
-			case "0x00":
-				var doc D
-				err := UnmarshalExtJSON([]byte(s), true, &doc)
-				expectError(t, err, fmt.Sprintf("%s: expected parse error", p.Description))
-			case "0x13":
-				ejvr, err := bsonrw.NewExtJSONValueReader(strings.NewReader(s), true)
-				expectNoError(t, err, fmt.Sprintf("error creating value reader: %s", err))
-				_, err = ejvr.ReadDecimal128()
-				expectError(t, err, fmt.Sprintf("%s: expected parse error", p.Description))
-			default:
-				t.Errorf("Update test to check for parse errors for type %s", test.BsonType)
-				t.Fail()
-			}
-		}
-	})
-}
-
-func Test_BsonCorpus(t *testing.T) {
-	for _, file := range findJSONFilesInDir(t, dataDir) {
-		runTest(t, file)
-	}
-}
-
-func expectNoError(t *testing.T, err error, desc string) {
-	if err != nil {
-		t.Helper()
-		t.Errorf("%s: Unepexted error: %v", desc, err)
-		t.FailNow()
-	}
-}
-
-func expectError(t *testing.T, err error, desc string) {
-	if err == nil {
-		t.Helper()
-		t.Errorf("%s: Expected error", desc)
-		t.FailNow()
-	}
-}

+ 0 - 113
qyxy/src/mgoutil/go.mongodb.org/mongo-driver/bson/bson_test.go

@@ -1,113 +0,0 @@
-// Copyright (C) MongoDB, Inc. 2017-present.
-//
-// Licensed under the Apache License, Version 2.0 (the "License"); you may
-// not use this file except in compliance with the License. You may obtain
-// a copy of the License at http://www.apache.org/licenses/LICENSE-2.0
-
-package bson
-
-import (
-	"bytes"
-	"testing"
-	"time"
-
-	"github.com/google/go-cmp/cmp"
-	"github.com/stretchr/testify/require"
-	"go.mongodb.org/mongo-driver/x/bsonx/bsoncore"
-)
-
-func noerr(t *testing.T, err error) {
-	if err != nil {
-		t.Helper()
-		t.Errorf("Unexpected error: (%T)%v", err, err)
-		t.FailNow()
-	}
-}
-
-func requireErrEqual(t *testing.T, err1 error, err2 error) { require.True(t, compareErrors(err1, err2)) }
-
-func TestTimeRoundTrip(t *testing.T) {
-	val := struct {
-		Value time.Time
-		ID    string
-	}{
-		ID: "time-rt-test",
-	}
-
-	if !val.Value.IsZero() {
-		t.Errorf("Did not get zero time as expected.")
-	}
-
-	bsonOut, err := Marshal(val)
-	noerr(t, err)
-	rtval := struct {
-		Value time.Time
-		ID    string
-	}{}
-
-	err = Unmarshal(bsonOut, &rtval)
-	noerr(t, err)
-	if !cmp.Equal(val, rtval) {
-		t.Errorf("Did not round trip properly. got %v; want %v", val, rtval)
-	}
-	if !rtval.Value.IsZero() {
-		t.Errorf("Did not get zero time as expected.")
-	}
-}
-
-func TestNonNullTimeRoundTrip(t *testing.T) {
-	now := time.Now()
-	now = time.Unix(now.Unix(), 0)
-	val := struct {
-		Value time.Time
-		ID    string
-	}{
-		ID:    "time-rt-test",
-		Value: now,
-	}
-
-	bsonOut, err := Marshal(val)
-	noerr(t, err)
-	rtval := struct {
-		Value time.Time
-		ID    string
-	}{}
-
-	err = Unmarshal(bsonOut, &rtval)
-	noerr(t, err)
-	if !cmp.Equal(val, rtval) {
-		t.Errorf("Did not round trip properly. got %v; want %v", val, rtval)
-	}
-}
-
-func TestD(t *testing.T) {
-	t.Run("can marshal", func(t *testing.T) {
-		d := D{{"foo", "bar"}, {"hello", "world"}, {"pi", 3.14159}}
-		idx, want := bsoncore.AppendDocumentStart(nil)
-		want = bsoncore.AppendStringElement(want, "foo", "bar")
-		want = bsoncore.AppendStringElement(want, "hello", "world")
-		want = bsoncore.AppendDoubleElement(want, "pi", 3.14159)
-		want, err := bsoncore.AppendDocumentEnd(want, idx)
-		noerr(t, err)
-		got, err := Marshal(d)
-		noerr(t, err)
-		if !bytes.Equal(got, want) {
-			t.Errorf("Marshaled documents do not match. got %v; want %v", Raw(got), Raw(want))
-		}
-	})
-	t.Run("can unmarshal", func(t *testing.T) {
-		want := D{{"foo", "bar"}, {"hello", "world"}, {"pi", 3.14159}}
-		idx, doc := bsoncore.AppendDocumentStart(nil)
-		doc = bsoncore.AppendStringElement(doc, "foo", "bar")
-		doc = bsoncore.AppendStringElement(doc, "hello", "world")
-		doc = bsoncore.AppendDoubleElement(doc, "pi", 3.14159)
-		doc, err := bsoncore.AppendDocumentEnd(doc, idx)
-		noerr(t, err)
-		var got D
-		err = Unmarshal(doc, &got)
-		noerr(t, err)
-		if !cmp.Equal(got, want) {
-			t.Errorf("Unmarshaled documents do not match. got %v; want %v", got, want)
-		}
-	})
-}

+ 0 - 163
qyxy/src/mgoutil/go.mongodb.org/mongo-driver/bson/bsoncodec/bsoncodec.go

@@ -1,163 +0,0 @@
-// Copyright (C) MongoDB, Inc. 2017-present.
-//
-// Licensed under the Apache License, Version 2.0 (the "License"); you may
-// not use this file except in compliance with the License. You may obtain
-// a copy of the License at http://www.apache.org/licenses/LICENSE-2.0
-
-package bsoncodec // import "go.mongodb.org/mongo-driver/bson/bsoncodec"
-
-import (
-	"fmt"
-	"reflect"
-	"strings"
-
-	"go.mongodb.org/mongo-driver/bson/bsonrw"
-	"go.mongodb.org/mongo-driver/bson/bsontype"
-)
-
-// Marshaler is an interface implemented by types that can marshal themselves
-// into a BSON document represented as bytes. The bytes returned must be a valid
-// BSON document if the error is nil.
-type Marshaler interface {
-	MarshalBSON() ([]byte, error)
-}
-
-// ValueMarshaler is an interface implemented by types that can marshal
-// themselves into a BSON value as bytes. The type must be the valid type for
-// the bytes returned. The bytes and byte type together must be valid if the
-// error is nil.
-type ValueMarshaler interface {
-	MarshalBSONValue() (bsontype.Type, []byte, error)
-}
-
-// Unmarshaler is an interface implemented by types that can unmarshal a BSON
-// document representation of themselves. The BSON bytes can be assumed to be
-// valid. UnmarshalBSON must copy the BSON bytes if it wishes to retain the data
-// after returning.
-type Unmarshaler interface {
-	UnmarshalBSON([]byte) error
-}
-
-// ValueUnmarshaler is an interface implemented by types that can unmarshal a
-// BSON value representaiton of themselves. The BSON bytes and type can be
-// assumed to be valid. UnmarshalBSONValue must copy the BSON value bytes if it
-// wishes to retain the data after returning.
-type ValueUnmarshaler interface {
-	UnmarshalBSONValue(bsontype.Type, []byte) error
-}
-
-// ValueEncoderError is an error returned from a ValueEncoder when the provided value can't be
-// encoded by the ValueEncoder.
-type ValueEncoderError struct {
-	Name     string
-	Types    []reflect.Type
-	Kinds    []reflect.Kind
-	Received reflect.Value
-}
-
-func (vee ValueEncoderError) Error() string {
-	typeKinds := make([]string, 0, len(vee.Types)+len(vee.Kinds))
-	for _, t := range vee.Types {
-		typeKinds = append(typeKinds, t.String())
-	}
-	for _, k := range vee.Kinds {
-		if k == reflect.Map {
-			typeKinds = append(typeKinds, "map[string]*")
-			continue
-		}
-		typeKinds = append(typeKinds, k.String())
-	}
-	received := vee.Received.Kind().String()
-	if vee.Received.IsValid() {
-		received = vee.Received.Type().String()
-	}
-	return fmt.Sprintf("%s can only encode valid %s, but got %s", vee.Name, strings.Join(typeKinds, ", "), received)
-}
-
-// ValueDecoderError is an error returned from a ValueDecoder when the provided value can't be
-// decoded by the ValueDecoder.
-type ValueDecoderError struct {
-	Name     string
-	Types    []reflect.Type
-	Kinds    []reflect.Kind
-	Received reflect.Value
-}
-
-func (vde ValueDecoderError) Error() string {
-	typeKinds := make([]string, 0, len(vde.Types)+len(vde.Kinds))
-	for _, t := range vde.Types {
-		typeKinds = append(typeKinds, t.String())
-	}
-	for _, k := range vde.Kinds {
-		if k == reflect.Map {
-			typeKinds = append(typeKinds, "map[string]*")
-			continue
-		}
-		typeKinds = append(typeKinds, k.String())
-	}
-	received := vde.Received.Kind().String()
-	if vde.Received.IsValid() {
-		received = vde.Received.Type().String()
-	}
-	return fmt.Sprintf("%s can only decode valid and settable %s, but got %s", vde.Name, strings.Join(typeKinds, ", "), received)
-}
-
-// EncodeContext is the contextual information required for a Codec to encode a
-// value.
-type EncodeContext struct {
-	*Registry
-	MinSize bool
-}
-
-// DecodeContext is the contextual information required for a Codec to decode a
-// value.
-type DecodeContext struct {
-	*Registry
-	Truncate bool
-	// Ancestor is the type of a containing document. This is mainly used to determine what type
-	// should be used when decoding an embedded document into an empty interface. For example, if
-	// Ancestor is a bson.M, BSON embedded document values being decoded into an empty interface
-	// will be decoded into a bson.M.
-	Ancestor reflect.Type
-}
-
-// ValueCodec is the interface that groups the methods to encode and decode
-// values.
-type ValueCodec interface {
-	ValueEncoder
-	ValueDecoder
-}
-
-// ValueEncoder is the interface implemented by types that can handle the encoding of a value.
-type ValueEncoder interface {
-	EncodeValue(EncodeContext, bsonrw.ValueWriter, reflect.Value) error
-}
-
-// ValueEncoderFunc is an adapter function that allows a function with the correct signature to be
-// used as a ValueEncoder.
-type ValueEncoderFunc func(EncodeContext, bsonrw.ValueWriter, reflect.Value) error
-
-// EncodeValue implements the ValueEncoder interface.
-func (fn ValueEncoderFunc) EncodeValue(ec EncodeContext, vw bsonrw.ValueWriter, val reflect.Value) error {
-	return fn(ec, vw, val)
-}
-
-// ValueDecoder is the interface implemented by types that can handle the decoding of a value.
-type ValueDecoder interface {
-	DecodeValue(DecodeContext, bsonrw.ValueReader, reflect.Value) error
-}
-
-// ValueDecoderFunc is an adapter function that allows a function with the correct signature to be
-// used as a ValueDecoder.
-type ValueDecoderFunc func(DecodeContext, bsonrw.ValueReader, reflect.Value) error
-
-// DecodeValue implements the ValueDecoder interface.
-func (fn ValueDecoderFunc) DecodeValue(dc DecodeContext, vr bsonrw.ValueReader, val reflect.Value) error {
-	return fn(dc, vr, val)
-}
-
-// CodecZeroer is the interface implemented by Codecs that can also determine if
-// a value of the type that would be encoded is zero.
-type CodecZeroer interface {
-	IsTypeZero(interface{}) bool
-}

+ 0 - 145
qyxy/src/mgoutil/go.mongodb.org/mongo-driver/bson/bsoncodec/bsoncodec_test.go

@@ -1,145 +0,0 @@
-// Copyright (C) MongoDB, Inc. 2017-present.
-//
-// Licensed under the Apache License, Version 2.0 (the "License"); you may
-// not use this file except in compliance with the License. You may obtain
-// a copy of the License at http://www.apache.org/licenses/LICENSE-2.0
-
-package bsoncodec
-
-import (
-	"fmt"
-	"reflect"
-	"testing"
-	"time"
-
-	"go.mongodb.org/mongo-driver/bson/bsonrw"
-	"go.mongodb.org/mongo-driver/bson/bsontype"
-	"go.mongodb.org/mongo-driver/bson/primitive"
-)
-
-func ExampleValueEncoder() {
-	var _ ValueEncoderFunc = func(ec EncodeContext, vw bsonrw.ValueWriter, val reflect.Value) error {
-		if val.Kind() != reflect.String {
-			return ValueEncoderError{Name: "StringEncodeValue", Kinds: []reflect.Kind{reflect.String}, Received: val}
-		}
-
-		return vw.WriteString(val.String())
-	}
-}
-
-func ExampleValueDecoder() {
-	var _ ValueDecoderFunc = func(dc DecodeContext, vr bsonrw.ValueReader, val reflect.Value) error {
-		if !val.CanSet() || val.Kind() != reflect.String {
-			return ValueDecoderError{Name: "StringDecodeValue", Kinds: []reflect.Kind{reflect.String}, Received: val}
-		}
-
-		if vr.Type() != bsontype.String {
-			return fmt.Errorf("cannot decode %v into a string type", vr.Type())
-		}
-
-		str, err := vr.ReadString()
-		if err != nil {
-			return err
-		}
-		val.SetString(str)
-		return nil
-	}
-}
-
-func noerr(t *testing.T, err error) {
-	if err != nil {
-		t.Helper()
-		t.Errorf("Unexpected error: (%T)%v", err, err)
-		t.FailNow()
-	}
-}
-
-func compareTime(t1, t2 time.Time) bool {
-	if t1.Location() != t2.Location() {
-		return false
-	}
-	return t1.Equal(t2)
-}
-
-func compareErrors(err1, err2 error) bool {
-	if err1 == nil && err2 == nil {
-		return true
-	}
-
-	if err1 == nil || err2 == nil {
-		return false
-	}
-
-	if err1.Error() != err2.Error() {
-		return false
-	}
-
-	return true
-}
-
-func compareDecimal128(d1, d2 primitive.Decimal128) bool {
-	d1H, d1L := d1.GetBytes()
-	d2H, d2L := d2.GetBytes()
-
-	if d1H != d2H {
-		return false
-	}
-
-	if d1L != d2L {
-		return false
-	}
-
-	return true
-}
-
-func compareStrings(s1, s2 string) bool { return s1 == s2 }
-
-type noPrivateFields struct {
-	a string
-}
-
-func compareNoPrivateFields(npf1, npf2 noPrivateFields) bool {
-	return npf1.a != npf2.a // We don't want these to be equal
-}
-
-type zeroTest struct {
-	reportZero bool
-}
-
-func (z zeroTest) IsZero() bool { return z.reportZero }
-
-func compareZeroTest(_, _ zeroTest) bool { return true }
-
-type nonZeroer struct {
-	value bool
-}
-
-type llCodec struct {
-	t         *testing.T
-	decodeval interface{}
-	encodeval interface{}
-	err       error
-}
-
-func (llc *llCodec) EncodeValue(_ EncodeContext, _ bsonrw.ValueWriter, i interface{}) error {
-	if llc.err != nil {
-		return llc.err
-	}
-
-	llc.encodeval = i
-	return nil
-}
-
-func (llc *llCodec) DecodeValue(_ DecodeContext, _ bsonrw.ValueReader, val reflect.Value) error {
-	if llc.err != nil {
-		return llc.err
-	}
-
-	if !reflect.TypeOf(llc.decodeval).AssignableTo(val.Type()) {
-		llc.t.Errorf("decodeval must be assignable to val provided to DecodeValue, but is not. decodeval %T; val %T", llc.decodeval, val)
-		return nil
-	}
-
-	val.Set(reflect.ValueOf(llc.decodeval))
-	return nil
-}

+ 0 - 1014
qyxy/src/mgoutil/go.mongodb.org/mongo-driver/bson/bsoncodec/default_value_decoders.go

@@ -1,1014 +0,0 @@
-// Copyright (C) MongoDB, Inc. 2017-present.
-//
-// Licensed under the Apache License, Version 2.0 (the "License"); you may
-// not use this file except in compliance with the License. You may obtain
-// a copy of the License at http://www.apache.org/licenses/LICENSE-2.0
-
-package bsoncodec
-
-import (
-	"encoding/json"
-	"errors"
-	"fmt"
-	"math"
-	"net/url"
-	"reflect"
-	"strconv"
-	"time"
-
-	"go.mongodb.org/mongo-driver/bson/bsonrw"
-	"go.mongodb.org/mongo-driver/bson/bsontype"
-	"go.mongodb.org/mongo-driver/bson/primitive"
-	"go.mongodb.org/mongo-driver/x/bsonx/bsoncore"
-)
-
-var defaultValueDecoders DefaultValueDecoders
-
-// DefaultValueDecoders is a namespace type for the default ValueDecoders used
-// when creating a registry.
-type DefaultValueDecoders struct{}
-
-// RegisterDefaultDecoders will register the decoder methods attached to DefaultValueDecoders with
-// the provided RegistryBuilder.
-//
-// There is no support for decoding map[string]interface{} becuase there is no decoder for
-// interface{}, so users must either register this decoder themselves or use the
-// EmptyInterfaceDecoder avaialble in the bson package.
-func (dvd DefaultValueDecoders) RegisterDefaultDecoders(rb *RegistryBuilder) {
-	if rb == nil {
-		panic(errors.New("argument to RegisterDefaultDecoders must not be nil"))
-	}
-
-	rb.
-		RegisterDecoder(tBinary, ValueDecoderFunc(dvd.BinaryDecodeValue)).
-		RegisterDecoder(tUndefined, ValueDecoderFunc(dvd.UndefinedDecodeValue)).
-		RegisterDecoder(tDateTime, ValueDecoderFunc(dvd.DateTimeDecodeValue)).
-		RegisterDecoder(tNull, ValueDecoderFunc(dvd.NullDecodeValue)).
-		RegisterDecoder(tRegex, ValueDecoderFunc(dvd.RegexDecodeValue)).
-		RegisterDecoder(tDBPointer, ValueDecoderFunc(dvd.DBPointerDecodeValue)).
-		RegisterDecoder(tTimestamp, ValueDecoderFunc(dvd.TimestampDecodeValue)).
-		RegisterDecoder(tMinKey, ValueDecoderFunc(dvd.MinKeyDecodeValue)).
-		RegisterDecoder(tMaxKey, ValueDecoderFunc(dvd.MaxKeyDecodeValue)).
-		RegisterDecoder(tJavaScript, ValueDecoderFunc(dvd.JavaScriptDecodeValue)).
-		RegisterDecoder(tSymbol, ValueDecoderFunc(dvd.SymbolDecodeValue)).
-		RegisterDecoder(tByteSlice, ValueDecoderFunc(dvd.ByteSliceDecodeValue)).
-		RegisterDecoder(tTime, ValueDecoderFunc(dvd.TimeDecodeValue)).
-		RegisterDecoder(tEmpty, ValueDecoderFunc(dvd.EmptyInterfaceDecodeValue)).
-		RegisterDecoder(tOID, ValueDecoderFunc(dvd.ObjectIDDecodeValue)).
-		RegisterDecoder(tDecimal, ValueDecoderFunc(dvd.Decimal128DecodeValue)).
-		RegisterDecoder(tJSONNumber, ValueDecoderFunc(dvd.JSONNumberDecodeValue)).
-		RegisterDecoder(tURL, ValueDecoderFunc(dvd.URLDecodeValue)).
-		RegisterDecoder(tValueUnmarshaler, ValueDecoderFunc(dvd.ValueUnmarshalerDecodeValue)).
-		RegisterDecoder(tUnmarshaler, ValueDecoderFunc(dvd.UnmarshalerDecodeValue)).
-		RegisterDecoder(tCoreDocument, ValueDecoderFunc(dvd.CoreDocumentDecodeValue)).
-		RegisterDecoder(tCodeWithScope, ValueDecoderFunc(dvd.CodeWithScopeDecodeValue)).
-		RegisterDefaultDecoder(reflect.Bool, ValueDecoderFunc(dvd.BooleanDecodeValue)).
-		RegisterDefaultDecoder(reflect.Int, ValueDecoderFunc(dvd.IntDecodeValue)).
-		RegisterDefaultDecoder(reflect.Int8, ValueDecoderFunc(dvd.IntDecodeValue)).
-		RegisterDefaultDecoder(reflect.Int16, ValueDecoderFunc(dvd.IntDecodeValue)).
-		RegisterDefaultDecoder(reflect.Int32, ValueDecoderFunc(dvd.IntDecodeValue)).
-		RegisterDefaultDecoder(reflect.Int64, ValueDecoderFunc(dvd.IntDecodeValue)).
-		RegisterDefaultDecoder(reflect.Uint, ValueDecoderFunc(dvd.UintDecodeValue)).
-		RegisterDefaultDecoder(reflect.Uint8, ValueDecoderFunc(dvd.UintDecodeValue)).
-		RegisterDefaultDecoder(reflect.Uint16, ValueDecoderFunc(dvd.UintDecodeValue)).
-		RegisterDefaultDecoder(reflect.Uint32, ValueDecoderFunc(dvd.UintDecodeValue)).
-		RegisterDefaultDecoder(reflect.Uint64, ValueDecoderFunc(dvd.UintDecodeValue)).
-		RegisterDefaultDecoder(reflect.Float32, ValueDecoderFunc(dvd.FloatDecodeValue)).
-		RegisterDefaultDecoder(reflect.Float64, ValueDecoderFunc(dvd.FloatDecodeValue)).
-		RegisterDefaultDecoder(reflect.Array, ValueDecoderFunc(dvd.ArrayDecodeValue)).
-		RegisterDefaultDecoder(reflect.Map, ValueDecoderFunc(dvd.MapDecodeValue)).
-		RegisterDefaultDecoder(reflect.Slice, ValueDecoderFunc(dvd.SliceDecodeValue)).
-		RegisterDefaultDecoder(reflect.String, ValueDecoderFunc(dvd.StringDecodeValue)).
-		RegisterDefaultDecoder(reflect.Struct, &StructCodec{cache: make(map[reflect.Type]*structDescription), parser: DefaultStructTagParser}).
-		RegisterDefaultDecoder(reflect.Ptr, NewPointerCodec()).
-		RegisterTypeMapEntry(bsontype.Double, tFloat64).
-		RegisterTypeMapEntry(bsontype.String, tString).
-		RegisterTypeMapEntry(bsontype.Array, tA).
-		RegisterTypeMapEntry(bsontype.Binary, tBinary).
-		RegisterTypeMapEntry(bsontype.Undefined, tUndefined).
-		RegisterTypeMapEntry(bsontype.ObjectID, tOID).
-		RegisterTypeMapEntry(bsontype.Boolean, tBool).
-		RegisterTypeMapEntry(bsontype.DateTime, tDateTime).
-		RegisterTypeMapEntry(bsontype.Regex, tRegex).
-		RegisterTypeMapEntry(bsontype.DBPointer, tDBPointer).
-		RegisterTypeMapEntry(bsontype.JavaScript, tJavaScript).
-		RegisterTypeMapEntry(bsontype.Symbol, tSymbol).
-		RegisterTypeMapEntry(bsontype.CodeWithScope, tCodeWithScope).
-		RegisterTypeMapEntry(bsontype.Int32, tInt32).
-		RegisterTypeMapEntry(bsontype.Int64, tInt64).
-		RegisterTypeMapEntry(bsontype.Timestamp, tTimestamp).
-		RegisterTypeMapEntry(bsontype.Decimal128, tDecimal).
-		RegisterTypeMapEntry(bsontype.MinKey, tMinKey).
-		RegisterTypeMapEntry(bsontype.MaxKey, tMaxKey).
-		RegisterTypeMapEntry(bsontype.Type(0), tD)
-}
-
-// BooleanDecodeValue is the ValueDecoderFunc for bool types.
-func (dvd DefaultValueDecoders) BooleanDecodeValue(dctx DecodeContext, vr bsonrw.ValueReader, val reflect.Value) error {
-	if vr.Type() != bsontype.Boolean {
-		return fmt.Errorf("cannot decode %v into a boolean", vr.Type())
-	}
-	if !val.IsValid() || !val.CanSet() || val.Kind() != reflect.Bool {
-		return ValueDecoderError{Name: "BooleanDecodeValue", Kinds: []reflect.Kind{reflect.Bool}, Received: val}
-	}
-
-	b, err := vr.ReadBoolean()
-	val.SetBool(b)
-	return err
-}
-
-// IntDecodeValue is the ValueDecoderFunc for bool types.
-func (dvd DefaultValueDecoders) IntDecodeValue(dc DecodeContext, vr bsonrw.ValueReader, val reflect.Value) error {
-	var i64 int64
-	var err error
-	switch vr.Type() {
-	case bsontype.Int32:
-		i32, err := vr.ReadInt32()
-		if err != nil {
-			return err
-		}
-		i64 = int64(i32)
-	case bsontype.Int64:
-		i64, err = vr.ReadInt64()
-		if err != nil {
-			return err
-		}
-	case bsontype.Double:
-		f64, err := vr.ReadDouble()
-		if err != nil {
-			return err
-		}
-		if !dc.Truncate && math.Floor(f64) != f64 {
-			return errors.New("IntDecodeValue can only truncate float64 to an integer type when truncation is enabled")
-		}
-		if f64 > float64(math.MaxInt64) {
-			return fmt.Errorf("%g overflows int64", f64)
-		}
-		i64 = int64(f64)
-	default:
-		return fmt.Errorf("cannot decode %v into an integer type", vr.Type())
-	}
-
-	if !val.CanSet() {
-		return ValueDecoderError{
-			Name:     "IntDecodeValue",
-			Kinds:    []reflect.Kind{reflect.Int8, reflect.Int16, reflect.Int32, reflect.Int64, reflect.Int},
-			Received: val,
-		}
-	}
-
-	switch val.Kind() {
-	case reflect.Int8:
-		if i64 < math.MinInt8 || i64 > math.MaxInt8 {
-			return fmt.Errorf("%d overflows int8", i64)
-		}
-	case reflect.Int16:
-		if i64 < math.MinInt16 || i64 > math.MaxInt16 {
-			return fmt.Errorf("%d overflows int16", i64)
-		}
-	case reflect.Int32:
-		if i64 < math.MinInt32 || i64 > math.MaxInt32 {
-			return fmt.Errorf("%d overflows int32", i64)
-		}
-	case reflect.Int64:
-	case reflect.Int:
-		if int64(int(i64)) != i64 { // Can we fit this inside of an int
-			return fmt.Errorf("%d overflows int", i64)
-		}
-	default:
-		return ValueDecoderError{
-			Name:     "IntDecodeValue",
-			Kinds:    []reflect.Kind{reflect.Int8, reflect.Int16, reflect.Int32, reflect.Int64, reflect.Int},
-			Received: val,
-		}
-	}
-
-	val.SetInt(i64)
-	return nil
-}
-
-// UintDecodeValue is the ValueDecoderFunc for uint types.
-func (dvd DefaultValueDecoders) UintDecodeValue(dc DecodeContext, vr bsonrw.ValueReader, val reflect.Value) error {
-	var i64 int64
-	var err error
-	switch vr.Type() {
-	case bsontype.Int32:
-		i32, err := vr.ReadInt32()
-		if err != nil {
-			return err
-		}
-		i64 = int64(i32)
-	case bsontype.Int64:
-		i64, err = vr.ReadInt64()
-		if err != nil {
-			return err
-		}
-	case bsontype.Double:
-		f64, err := vr.ReadDouble()
-		if err != nil {
-			return err
-		}
-		if !dc.Truncate && math.Floor(f64) != f64 {
-			return errors.New("UintDecodeValue can only truncate float64 to an integer type when truncation is enabled")
-		}
-		if f64 > float64(math.MaxInt64) {
-			return fmt.Errorf("%g overflows int64", f64)
-		}
-		i64 = int64(f64)
-	default:
-		return fmt.Errorf("cannot decode %v into an integer type", vr.Type())
-	}
-
-	if !val.CanSet() {
-		return ValueDecoderError{
-			Name:     "UintDecodeValue",
-			Kinds:    []reflect.Kind{reflect.Uint8, reflect.Uint16, reflect.Uint32, reflect.Uint64, reflect.Uint},
-			Received: val,
-		}
-	}
-
-	switch val.Kind() {
-	case reflect.Uint8:
-		if i64 < 0 || i64 > math.MaxUint8 {
-			return fmt.Errorf("%d overflows uint8", i64)
-		}
-	case reflect.Uint16:
-		if i64 < 0 || i64 > math.MaxUint16 {
-			return fmt.Errorf("%d overflows uint16", i64)
-		}
-	case reflect.Uint32:
-		if i64 < 0 || i64 > math.MaxUint32 {
-			return fmt.Errorf("%d overflows uint32", i64)
-		}
-	case reflect.Uint64:
-		if i64 < 0 {
-			return fmt.Errorf("%d overflows uint64", i64)
-		}
-	case reflect.Uint:
-		if i64 < 0 || int64(uint(i64)) != i64 { // Can we fit this inside of an uint
-			return fmt.Errorf("%d overflows uint", i64)
-		}
-	default:
-		return ValueDecoderError{
-			Name:     "UintDecodeValue",
-			Kinds:    []reflect.Kind{reflect.Uint8, reflect.Uint16, reflect.Uint32, reflect.Uint64, reflect.Uint},
-			Received: val,
-		}
-	}
-
-	val.SetUint(uint64(i64))
-	return nil
-}
-
-// FloatDecodeValue is the ValueDecoderFunc for float types.
-func (dvd DefaultValueDecoders) FloatDecodeValue(ec DecodeContext, vr bsonrw.ValueReader, val reflect.Value) error {
-	var f float64
-	var err error
-	switch vr.Type() {
-	case bsontype.Int32:
-		i32, err := vr.ReadInt32()
-		if err != nil {
-			return err
-		}
-		f = float64(i32)
-	case bsontype.Int64:
-		i64, err := vr.ReadInt64()
-		if err != nil {
-			return err
-		}
-		f = float64(i64)
-	case bsontype.Double:
-		f, err = vr.ReadDouble()
-		if err != nil {
-			return err
-		}
-	default:
-		return fmt.Errorf("cannot decode %v into a float32 or float64 type", vr.Type())
-	}
-
-	if !val.CanSet() {
-		return ValueDecoderError{Name: "FloatDecodeValue", Kinds: []reflect.Kind{reflect.Float32, reflect.Float64}, Received: val}
-	}
-
-	switch val.Kind() {
-	case reflect.Float32:
-		if !ec.Truncate && float64(float32(f)) != f {
-			return errors.New("FloatDecodeValue can only convert float64 to float32 when truncation is allowed")
-		}
-	case reflect.Float64:
-	default:
-		return ValueDecoderError{Name: "FloatDecodeValue", Kinds: []reflect.Kind{reflect.Float32, reflect.Float64}, Received: val}
-	}
-
-	val.SetFloat(f)
-	return nil
-}
-
-// StringDecodeValue is the ValueDecoderFunc for string types.
-func (dvd DefaultValueDecoders) StringDecodeValue(dctx DecodeContext, vr bsonrw.ValueReader, val reflect.Value) error {
-	var str string
-	var err error
-	switch vr.Type() {
-	// TODO(GODRIVER-577): Handle JavaScript and Symbol BSON types when allowed.
-	case bsontype.String:
-		str, err = vr.ReadString()
-		if err != nil {
-			return err
-		}
-	default:
-		return fmt.Errorf("cannot decode %v into a string type", vr.Type())
-	}
-	if !val.CanSet() || val.Kind() != reflect.String {
-		return ValueDecoderError{Name: "StringDecodeValue", Kinds: []reflect.Kind{reflect.String}, Received: val}
-	}
-
-	val.SetString(str)
-	return nil
-}
-
-// JavaScriptDecodeValue is the ValueDecoderFunc for the primitive.JavaScript type.
-func (DefaultValueDecoders) JavaScriptDecodeValue(dctx DecodeContext, vr bsonrw.ValueReader, val reflect.Value) error {
-	if !val.CanSet() || val.Type() != tJavaScript {
-		return ValueDecoderError{Name: "BinaryDecodeValue", Types: []reflect.Type{tJavaScript}, Received: val}
-	}
-
-	if vr.Type() != bsontype.JavaScript {
-		return fmt.Errorf("cannot decode %v into a primitive.JavaScript", vr.Type())
-	}
-
-	js, err := vr.ReadJavascript()
-	if err != nil {
-		return err
-	}
-
-	val.SetString(js)
-	return nil
-}
-
-// SymbolDecodeValue is the ValueDecoderFunc for the primitive.Symbol type.
-func (DefaultValueDecoders) SymbolDecodeValue(dctx DecodeContext, vr bsonrw.ValueReader, val reflect.Value) error {
-	if !val.CanSet() || val.Type() != tSymbol {
-		return ValueDecoderError{Name: "BinaryDecodeValue", Types: []reflect.Type{tSymbol}, Received: val}
-	}
-
-	if vr.Type() != bsontype.Symbol {
-		return fmt.Errorf("cannot decode %v into a primitive.Symbol", vr.Type())
-	}
-
-	symbol, err := vr.ReadSymbol()
-	if err != nil {
-		return err
-	}
-
-	val.SetString(symbol)
-	return nil
-}
-
-// BinaryDecodeValue is the ValueDecoderFunc for Binary.
-func (DefaultValueDecoders) BinaryDecodeValue(dc DecodeContext, vr bsonrw.ValueReader, val reflect.Value) error {
-	if !val.CanSet() || val.Type() != tBinary {
-		return ValueDecoderError{Name: "BinaryDecodeValue", Types: []reflect.Type{tBinary}, Received: val}
-	}
-
-	if vr.Type() != bsontype.Binary {
-		return fmt.Errorf("cannot decode %v into a Binary", vr.Type())
-	}
-
-	data, subtype, err := vr.ReadBinary()
-	if err != nil {
-		return err
-	}
-
-	val.Set(reflect.ValueOf(primitive.Binary{Subtype: subtype, Data: data}))
-	return nil
-}
-
-// UndefinedDecodeValue is the ValueDecoderFunc for Undefined.
-func (DefaultValueDecoders) UndefinedDecodeValue(dc DecodeContext, vr bsonrw.ValueReader, val reflect.Value) error {
-	if !val.CanSet() || val.Type() != tUndefined {
-		return ValueDecoderError{Name: "UndefinedDecodeValue", Types: []reflect.Type{tUndefined}, Received: val}
-	}
-
-	if vr.Type() != bsontype.Undefined {
-		return fmt.Errorf("cannot decode %v into an Undefined", vr.Type())
-	}
-
-	val.Set(reflect.ValueOf(primitive.Undefined{}))
-	return vr.ReadUndefined()
-}
-
-// ObjectIDDecodeValue is the ValueDecoderFunc for primitive.ObjectID.
-func (dvd DefaultValueDecoders) ObjectIDDecodeValue(dc DecodeContext, vr bsonrw.ValueReader, val reflect.Value) error {
-	if !val.CanSet() || val.Type() != tOID {
-		return ValueDecoderError{Name: "ObjectIDDecodeValue", Types: []reflect.Type{tOID}, Received: val}
-	}
-
-	if vr.Type() != bsontype.ObjectID {
-		return fmt.Errorf("cannot decode %v into an ObjectID", vr.Type())
-	}
-	oid, err := vr.ReadObjectID()
-	val.Set(reflect.ValueOf(oid))
-	return err
-}
-
-// DateTimeDecodeValue is the ValueDecoderFunc for DateTime.
-func (DefaultValueDecoders) DateTimeDecodeValue(dc DecodeContext, vr bsonrw.ValueReader, val reflect.Value) error {
-	if !val.CanSet() || val.Type() != tDateTime {
-		return ValueDecoderError{Name: "DateTimeDecodeValue", Types: []reflect.Type{tDateTime}, Received: val}
-	}
-
-	if vr.Type() != bsontype.DateTime {
-		return fmt.Errorf("cannot decode %v into a DateTime", vr.Type())
-	}
-
-	dt, err := vr.ReadDateTime()
-	if err != nil {
-		return err
-	}
-
-	val.Set(reflect.ValueOf(primitive.DateTime(dt)))
-	return nil
-}
-
-// NullDecodeValue is the ValueDecoderFunc for Null.
-func (DefaultValueDecoders) NullDecodeValue(dc DecodeContext, vr bsonrw.ValueReader, val reflect.Value) error {
-	if !val.CanSet() || val.Type() != tNull {
-		return ValueDecoderError{Name: "NullDecodeValue", Types: []reflect.Type{tNull}, Received: val}
-	}
-
-	if vr.Type() != bsontype.Null {
-		return fmt.Errorf("cannot decode %v into a Null", vr.Type())
-	}
-
-	val.Set(reflect.ValueOf(primitive.Null{}))
-	return vr.ReadNull()
-}
-
-// RegexDecodeValue is the ValueDecoderFunc for Regex.
-func (DefaultValueDecoders) RegexDecodeValue(dc DecodeContext, vr bsonrw.ValueReader, val reflect.Value) error {
-	if !val.CanSet() || val.Type() != tRegex {
-		return ValueDecoderError{Name: "RegexDecodeValue", Types: []reflect.Type{tRegex}, Received: val}
-	}
-
-	if vr.Type() != bsontype.Regex {
-		return fmt.Errorf("cannot decode %v into a Regex", vr.Type())
-	}
-
-	pattern, options, err := vr.ReadRegex()
-	if err != nil {
-		return err
-	}
-
-	val.Set(reflect.ValueOf(primitive.Regex{Pattern: pattern, Options: options}))
-	return nil
-}
-
-// DBPointerDecodeValue is the ValueDecoderFunc for DBPointer.
-func (DefaultValueDecoders) DBPointerDecodeValue(dc DecodeContext, vr bsonrw.ValueReader, val reflect.Value) error {
-	if !val.CanSet() || val.Type() != tDBPointer {
-		return ValueDecoderError{Name: "DBPointerDecodeValue", Types: []reflect.Type{tDBPointer}, Received: val}
-	}
-
-	if vr.Type() != bsontype.DBPointer {
-		return fmt.Errorf("cannot decode %v into a DBPointer", vr.Type())
-	}
-
-	ns, pointer, err := vr.ReadDBPointer()
-	if err != nil {
-		return err
-	}
-
-	val.Set(reflect.ValueOf(primitive.DBPointer{DB: ns, Pointer: pointer}))
-	return nil
-}
-
-// TimestampDecodeValue is the ValueDecoderFunc for Timestamp.
-func (DefaultValueDecoders) TimestampDecodeValue(dc DecodeContext, vr bsonrw.ValueReader, val reflect.Value) error {
-	if !val.CanSet() || val.Type() != tTimestamp {
-		return ValueDecoderError{Name: "TimestampDecodeValue", Types: []reflect.Type{tTimestamp}, Received: val}
-	}
-
-	if vr.Type() != bsontype.Timestamp {
-		return fmt.Errorf("cannot decode %v into a Timestamp", vr.Type())
-	}
-
-	t, incr, err := vr.ReadTimestamp()
-	if err != nil {
-		return err
-	}
-
-	val.Set(reflect.ValueOf(primitive.Timestamp{T: t, I: incr}))
-	return nil
-}
-
-// MinKeyDecodeValue is the ValueDecoderFunc for MinKey.
-func (DefaultValueDecoders) MinKeyDecodeValue(dc DecodeContext, vr bsonrw.ValueReader, val reflect.Value) error {
-	if !val.CanSet() || val.Type() != tMinKey {
-		return ValueDecoderError{Name: "MinKeyDecodeValue", Types: []reflect.Type{tMinKey}, Received: val}
-	}
-
-	if vr.Type() != bsontype.MinKey {
-		return fmt.Errorf("cannot decode %v into a MinKey", vr.Type())
-	}
-
-	val.Set(reflect.ValueOf(primitive.MinKey{}))
-	return vr.ReadMinKey()
-}
-
-// MaxKeyDecodeValue is the ValueDecoderFunc for MaxKey.
-func (DefaultValueDecoders) MaxKeyDecodeValue(dc DecodeContext, vr bsonrw.ValueReader, val reflect.Value) error {
-	if !val.CanSet() || val.Type() != tMaxKey {
-		return ValueDecoderError{Name: "MaxKeyDecodeValue", Types: []reflect.Type{tMaxKey}, Received: val}
-	}
-
-	if vr.Type() != bsontype.MaxKey {
-		return fmt.Errorf("cannot decode %v into a MaxKey", vr.Type())
-	}
-
-	val.Set(reflect.ValueOf(primitive.MaxKey{}))
-	return vr.ReadMaxKey()
-}
-
-// Decimal128DecodeValue is the ValueDecoderFunc for primitive.Decimal128.
-func (dvd DefaultValueDecoders) Decimal128DecodeValue(dctx DecodeContext, vr bsonrw.ValueReader, val reflect.Value) error {
-	if vr.Type() != bsontype.Decimal128 {
-		return fmt.Errorf("cannot decode %v into a primitive.Decimal128", vr.Type())
-	}
-
-	if !val.CanSet() || val.Type() != tDecimal {
-		return ValueDecoderError{Name: "Decimal128DecodeValue", Types: []reflect.Type{tDecimal}, Received: val}
-	}
-	d128, err := vr.ReadDecimal128()
-	val.Set(reflect.ValueOf(d128))
-	return err
-}
-
-// JSONNumberDecodeValue is the ValueDecoderFunc for json.Number.
-func (dvd DefaultValueDecoders) JSONNumberDecodeValue(dc DecodeContext, vr bsonrw.ValueReader, val reflect.Value) error {
-	if !val.CanSet() || val.Type() != tJSONNumber {
-		return ValueDecoderError{Name: "JSONNumberDecodeValue", Types: []reflect.Type{tJSONNumber}, Received: val}
-	}
-
-	switch vr.Type() {
-	case bsontype.Double:
-		f64, err := vr.ReadDouble()
-		if err != nil {
-			return err
-		}
-		val.Set(reflect.ValueOf(json.Number(strconv.FormatFloat(f64, 'g', -1, 64))))
-	case bsontype.Int32:
-		i32, err := vr.ReadInt32()
-		if err != nil {
-			return err
-		}
-		val.Set(reflect.ValueOf(json.Number(strconv.FormatInt(int64(i32), 10))))
-	case bsontype.Int64:
-		i64, err := vr.ReadInt64()
-		if err != nil {
-			return err
-		}
-		val.Set(reflect.ValueOf(json.Number(strconv.FormatInt(i64, 10))))
-	default:
-		return fmt.Errorf("cannot decode %v into a json.Number", vr.Type())
-	}
-
-	return nil
-}
-
-// URLDecodeValue is the ValueDecoderFunc for url.URL.
-func (dvd DefaultValueDecoders) URLDecodeValue(dc DecodeContext, vr bsonrw.ValueReader, val reflect.Value) error {
-	if vr.Type() != bsontype.String {
-		return fmt.Errorf("cannot decode %v into a *url.URL", vr.Type())
-	}
-
-	str, err := vr.ReadString()
-	if err != nil {
-		return err
-	}
-
-	u, err := url.Parse(str)
-	if err != nil {
-		return err
-	}
-
-	if !val.CanSet() || val.Type() != tURL {
-		return ValueDecoderError{Name: "URLDecodeValue", Types: []reflect.Type{tURL}, Received: val}
-	}
-
-	val.Set(reflect.ValueOf(u).Elem())
-	return nil
-}
-
-// TimeDecodeValue is the ValueDecoderFunc for time.Time.
-func (dvd DefaultValueDecoders) TimeDecodeValue(dc DecodeContext, vr bsonrw.ValueReader, val reflect.Value) error {
-	if vr.Type() != bsontype.DateTime {
-		return fmt.Errorf("cannot decode %v into a time.Time", vr.Type())
-	}
-
-	dt, err := vr.ReadDateTime()
-	if err != nil {
-		return err
-	}
-
-	if !val.CanSet() || val.Type() != tTime {
-		return ValueDecoderError{Name: "TimeDecodeValue", Types: []reflect.Type{tTime}, Received: val}
-	}
-
-	val.Set(reflect.ValueOf(time.Unix(dt/1000, dt%1000*1000000).UTC()))
-	return nil
-}
-
-// ByteSliceDecodeValue is the ValueDecoderFunc for []byte.
-func (dvd DefaultValueDecoders) ByteSliceDecodeValue(dc DecodeContext, vr bsonrw.ValueReader, val reflect.Value) error {
-	if vr.Type() != bsontype.Binary && vr.Type() != bsontype.Null {
-		return fmt.Errorf("cannot decode %v into a []byte", vr.Type())
-	}
-
-	if !val.CanSet() || val.Type() != tByteSlice {
-		return ValueDecoderError{Name: "ByteSliceDecodeValue", Types: []reflect.Type{tByteSlice}, Received: val}
-	}
-
-	if vr.Type() == bsontype.Null {
-		val.Set(reflect.Zero(val.Type()))
-		return vr.ReadNull()
-	}
-
-	data, subtype, err := vr.ReadBinary()
-	if err != nil {
-		return err
-	}
-	if subtype != 0x00 {
-		return fmt.Errorf("ByteSliceDecodeValue can only be used to decode subtype 0x00 for %s, got %v", bsontype.Binary, subtype)
-	}
-
-	val.Set(reflect.ValueOf(data))
-	return nil
-}
-
-// MapDecodeValue is the ValueDecoderFunc for map[string]* types.
-func (dvd DefaultValueDecoders) MapDecodeValue(dc DecodeContext, vr bsonrw.ValueReader, val reflect.Value) error {
-	if !val.CanSet() || val.Kind() != reflect.Map || val.Type().Key().Kind() != reflect.String {
-		return ValueDecoderError{Name: "MapDecodeValue", Kinds: []reflect.Kind{reflect.Map}, Received: val}
-	}
-
-	switch vr.Type() {
-	case bsontype.Type(0), bsontype.EmbeddedDocument:
-	case bsontype.Null:
-		val.Set(reflect.Zero(val.Type()))
-		return vr.ReadNull()
-	default:
-		return fmt.Errorf("cannot decode %v into a %s", vr.Type(), val.Type())
-	}
-
-	dr, err := vr.ReadDocument()
-	if err != nil {
-		return err
-	}
-
-	if val.IsNil() {
-		val.Set(reflect.MakeMap(val.Type()))
-	}
-
-	eType := val.Type().Elem()
-	decoder, err := dc.LookupDecoder(eType)
-	if err != nil {
-		return err
-	}
-
-	if eType == tEmpty {
-		dc.Ancestor = val.Type()
-	}
-
-	keyType := val.Type().Key()
-	for {
-		key, vr, err := dr.ReadElement()
-		if err == bsonrw.ErrEOD {
-			break
-		}
-		if err != nil {
-			return err
-		}
-
-		elem := reflect.New(eType).Elem()
-
-		err = decoder.DecodeValue(dc, vr, elem)
-		if err != nil {
-			return err
-		}
-
-		val.SetMapIndex(reflect.ValueOf(key).Convert(keyType), elem)
-	}
-	return nil
-}
-
-// ArrayDecodeValue is the ValueDecoderFunc for array types.
-func (dvd DefaultValueDecoders) ArrayDecodeValue(dc DecodeContext, vr bsonrw.ValueReader, val reflect.Value) error {
-	if !val.IsValid() || val.Kind() != reflect.Array {
-		return ValueDecoderError{Name: "ArrayDecodeValue", Kinds: []reflect.Kind{reflect.Array}, Received: val}
-	}
-
-	switch vr.Type() {
-	case bsontype.Array:
-	case bsontype.Type(0), bsontype.EmbeddedDocument:
-		if val.Type().Elem() != tE {
-			return fmt.Errorf("cannot decode document into %s", val.Type())
-		}
-	default:
-		return fmt.Errorf("cannot decode %v into an array", vr.Type())
-	}
-
-	var elemsFunc func(DecodeContext, bsonrw.ValueReader, reflect.Value) ([]reflect.Value, error)
-	switch val.Type().Elem() {
-	case tE:
-		elemsFunc = dvd.decodeD
-	default:
-		elemsFunc = dvd.decodeDefault
-	}
-
-	elems, err := elemsFunc(dc, vr, val)
-	if err != nil {
-		return err
-	}
-
-	if len(elems) > val.Len() {
-		return fmt.Errorf("more elements returned in array than can fit inside %s", val.Type())
-	}
-
-	for idx, elem := range elems {
-		val.Index(idx).Set(elem)
-	}
-
-	return nil
-}
-
-// SliceDecodeValue is the ValueDecoderFunc for slice types.
-func (dvd DefaultValueDecoders) SliceDecodeValue(dc DecodeContext, vr bsonrw.ValueReader, val reflect.Value) error {
-	if !val.CanSet() || val.Kind() != reflect.Slice {
-		return ValueDecoderError{Name: "SliceDecodeValue", Kinds: []reflect.Kind{reflect.Slice}, Received: val}
-	}
-
-	switch vr.Type() {
-	case bsontype.Array:
-	case bsontype.Null:
-		val.Set(reflect.Zero(val.Type()))
-		return vr.ReadNull()
-	case bsontype.Type(0), bsontype.EmbeddedDocument:
-		if val.Type().Elem() != tE {
-			return fmt.Errorf("cannot decode document into %s", val.Type())
-		}
-	default:
-		return fmt.Errorf("cannot decode %v into a slice", vr.Type())
-	}
-
-	var elemsFunc func(DecodeContext, bsonrw.ValueReader, reflect.Value) ([]reflect.Value, error)
-	switch val.Type().Elem() {
-	case tE:
-		dc.Ancestor = val.Type()
-		elemsFunc = dvd.decodeD
-	default:
-		elemsFunc = dvd.decodeDefault
-	}
-
-	elems, err := elemsFunc(dc, vr, val)
-	if err != nil {
-		return err
-	}
-
-	if val.IsNil() {
-		val.Set(reflect.MakeSlice(val.Type(), 0, len(elems)))
-	}
-
-	val.SetLen(0)
-	val.Set(reflect.Append(val, elems...))
-
-	return nil
-}
-
-// ValueUnmarshalerDecodeValue is the ValueDecoderFunc for ValueUnmarshaler implementations.
-func (dvd DefaultValueDecoders) ValueUnmarshalerDecodeValue(dc DecodeContext, vr bsonrw.ValueReader, val reflect.Value) error {
-	if !val.IsValid() || (!val.Type().Implements(tValueUnmarshaler) && !reflect.PtrTo(val.Type()).Implements(tValueUnmarshaler)) {
-		return ValueDecoderError{Name: "ValueUnmarshalerDecodeValue", Types: []reflect.Type{tValueUnmarshaler}, Received: val}
-	}
-
-	if val.Kind() == reflect.Ptr && val.IsNil() {
-		if !val.CanSet() {
-			return ValueDecoderError{Name: "ValueUnmarshalerDecodeValue", Types: []reflect.Type{tValueUnmarshaler}, Received: val}
-		}
-		val.Set(reflect.New(val.Type().Elem()))
-	}
-
-	if !val.Type().Implements(tValueUnmarshaler) {
-		if !val.CanAddr() {
-			return ValueDecoderError{Name: "ValueUnmarshalerDecodeValue", Types: []reflect.Type{tValueUnmarshaler}, Received: val}
-		}
-		val = val.Addr() // If they type doesn't implement the interface, a pointer to it must.
-	}
-
-	t, src, err := bsonrw.Copier{}.CopyValueToBytes(vr)
-	if err != nil {
-		return err
-	}
-
-	fn := val.Convert(tValueUnmarshaler).MethodByName("UnmarshalBSONValue")
-	errVal := fn.Call([]reflect.Value{reflect.ValueOf(t), reflect.ValueOf(src)})[0]
-	if !errVal.IsNil() {
-		return errVal.Interface().(error)
-	}
-	return nil
-}
-
-// UnmarshalerDecodeValue is the ValueDecoderFunc for Unmarshaler implementations.
-func (dvd DefaultValueDecoders) UnmarshalerDecodeValue(dc DecodeContext, vr bsonrw.ValueReader, val reflect.Value) error {
-	if !val.IsValid() || (!val.Type().Implements(tUnmarshaler) && !reflect.PtrTo(val.Type()).Implements(tUnmarshaler)) {
-		return ValueDecoderError{Name: "UnmarshalerDecodeValue", Types: []reflect.Type{tUnmarshaler}, Received: val}
-	}
-
-	if val.Kind() == reflect.Ptr && val.IsNil() {
-		if !val.CanSet() {
-			return ValueDecoderError{Name: "UnmarshalerDecodeValue", Types: []reflect.Type{tUnmarshaler}, Received: val}
-		}
-		val.Set(reflect.New(val.Type().Elem()))
-	}
-
-	if !val.Type().Implements(tUnmarshaler) {
-		if !val.CanAddr() {
-			return ValueDecoderError{Name: "UnmarshalerDecodeValue", Types: []reflect.Type{tUnmarshaler}, Received: val}
-		}
-		val = val.Addr() // If they type doesn't implement the interface, a pointer to it must.
-	}
-
-	_, src, err := bsonrw.Copier{}.CopyValueToBytes(vr)
-	if err != nil {
-		return err
-	}
-
-	fn := val.Convert(tUnmarshaler).MethodByName("UnmarshalBSON")
-	errVal := fn.Call([]reflect.Value{reflect.ValueOf(src)})[0]
-	if !errVal.IsNil() {
-		return errVal.Interface().(error)
-	}
-	return nil
-}
-
-// EmptyInterfaceDecodeValue is the ValueDecoderFunc for interface{}.
-func (dvd DefaultValueDecoders) EmptyInterfaceDecodeValue(dc DecodeContext, vr bsonrw.ValueReader, val reflect.Value) error {
-	if !val.CanSet() || val.Type() != tEmpty {
-		return ValueDecoderError{Name: "EmptyInterfaceDecodeValue", Types: []reflect.Type{tEmpty}, Received: val}
-	}
-
-	rtype, err := dc.LookupTypeMapEntry(vr.Type())
-	if err != nil {
-		switch vr.Type() {
-		case bsontype.EmbeddedDocument:
-			if dc.Ancestor != nil {
-				rtype = dc.Ancestor
-				break
-			}
-			rtype = tD
-		case bsontype.Null:
-			val.Set(reflect.Zero(val.Type()))
-			return vr.ReadNull()
-		default:
-			return err
-		}
-	}
-
-	decoder, err := dc.LookupDecoder(rtype)
-	if err != nil {
-		return err
-	}
-
-	elem := reflect.New(rtype).Elem()
-	err = decoder.DecodeValue(dc, vr, elem)
-	if err != nil {
-		return err
-	}
-
-	val.Set(elem)
-	return nil
-}
-
-// CoreDocumentDecodeValue is the ValueDecoderFunc for bsoncore.Document.
-func (DefaultValueDecoders) CoreDocumentDecodeValue(dc DecodeContext, vr bsonrw.ValueReader, val reflect.Value) error {
-	if !val.CanSet() || val.Type() != tCoreDocument {
-		return ValueDecoderError{Name: "CoreDocumentDecodeValue", Types: []reflect.Type{tCoreDocument}, Received: val}
-	}
-
-	if val.IsNil() {
-		val.Set(reflect.MakeSlice(val.Type(), 0, 0))
-	}
-
-	val.SetLen(0)
-
-	cdoc, err := bsonrw.Copier{}.AppendDocumentBytes(val.Interface().(bsoncore.Document), vr)
-	val.Set(reflect.ValueOf(cdoc))
-	return err
-}
-
-func (dvd DefaultValueDecoders) decodeDefault(dc DecodeContext, vr bsonrw.ValueReader, val reflect.Value) ([]reflect.Value, error) {
-	elems := make([]reflect.Value, 0)
-
-	ar, err := vr.ReadArray()
-	if err != nil {
-		return nil, err
-	}
-
-	eType := val.Type().Elem()
-
-	decoder, err := dc.LookupDecoder(eType)
-	if err != nil {
-		return nil, err
-	}
-
-	for {
-		vr, err := ar.ReadValue()
-		if err == bsonrw.ErrEOA {
-			break
-		}
-		if err != nil {
-			return nil, err
-		}
-
-		elem := reflect.New(eType).Elem()
-
-		err = decoder.DecodeValue(dc, vr, elem)
-		if err != nil {
-			return nil, err
-		}
-		elems = append(elems, elem)
-	}
-
-	return elems, nil
-}
-
-// CodeWithScopeDecodeValue is the ValueDecoderFunc for CodeWithScope.
-func (dvd DefaultValueDecoders) CodeWithScopeDecodeValue(dc DecodeContext, vr bsonrw.ValueReader, val reflect.Value) error {
-	if !val.CanSet() || val.Type() != tCodeWithScope {
-		return ValueDecoderError{Name: "CodeWithScopeDecodeValue", Types: []reflect.Type{tCodeWithScope}, Received: val}
-	}
-
-	if vr.Type() != bsontype.CodeWithScope {
-		return fmt.Errorf("cannot decode %v into a primitive.CodeWithScope", vr.Type())
-	}
-
-	code, dr, err := vr.ReadCodeWithScope()
-	if err != nil {
-		return err
-	}
-
-	scope := reflect.New(tD).Elem()
-
-	elems, err := dvd.decodeElemsFromDocumentReader(dc, dr)
-	if err != nil {
-		return err
-	}
-
-	scope.Set(reflect.MakeSlice(tD, 0, len(elems)))
-	scope.Set(reflect.Append(scope, elems...))
-
-	val.Set(reflect.ValueOf(primitive.CodeWithScope{Code: primitive.JavaScript(code), Scope: scope.Interface().(primitive.D)}))
-	return nil
-}
-
-func (dvd DefaultValueDecoders) decodeD(dc DecodeContext, vr bsonrw.ValueReader, _ reflect.Value) ([]reflect.Value, error) {
-	switch vr.Type() {
-	case bsontype.Type(0), bsontype.EmbeddedDocument:
-	default:
-		return nil, fmt.Errorf("cannot decode %v into a D", vr.Type())
-	}
-
-	dr, err := vr.ReadDocument()
-	if err != nil {
-		return nil, err
-	}
-
-	return dvd.decodeElemsFromDocumentReader(dc, dr)
-}
-
-func (DefaultValueDecoders) decodeElemsFromDocumentReader(dc DecodeContext, dr bsonrw.DocumentReader) ([]reflect.Value, error) {
-	decoder, err := dc.LookupDecoder(tEmpty)
-	if err != nil {
-		return nil, err
-	}
-
-	elems := make([]reflect.Value, 0)
-	for {
-		key, vr, err := dr.ReadElement()
-		if err == bsonrw.ErrEOD {
-			break
-		}
-		if err != nil {
-			return nil, err
-		}
-
-		val := reflect.New(tEmpty).Elem()
-		err = decoder.DecodeValue(dc, vr, val)
-		if err != nil {
-			return nil, err
-		}
-
-		elems = append(elems, reflect.ValueOf(primitive.E{Key: key, Value: val.Interface()}))
-	}
-
-	return elems, nil
-}

+ 0 - 2870
qyxy/src/mgoutil/go.mongodb.org/mongo-driver/bson/bsoncodec/default_value_decoders_test.go

@@ -1,2870 +0,0 @@
-// Copyright (C) MongoDB, Inc. 2017-present.
-//
-// Licensed under the Apache License, Version 2.0 (the "License"); you may
-// not use this file except in compliance with the License. You may obtain
-// a copy of the License at http://www.apache.org/licenses/LICENSE-2.0
-
-package bsoncodec
-
-import (
-	"bytes"
-	"encoding/json"
-	"errors"
-	"fmt"
-	"math"
-	"net/url"
-	"reflect"
-	"testing"
-	"time"
-
-	"github.com/google/go-cmp/cmp"
-	"go.mongodb.org/mongo-driver/bson/bsonrw"
-	"go.mongodb.org/mongo-driver/bson/bsonrw/bsonrwtest"
-	"go.mongodb.org/mongo-driver/bson/bsontype"
-	"go.mongodb.org/mongo-driver/bson/primitive"
-	"go.mongodb.org/mongo-driver/x/bsonx/bsoncore"
-)
-
-func TestDefaultValueDecoders(t *testing.T) {
-	var dvd DefaultValueDecoders
-	var wrong = func(string, string) string { return "wrong" }
-
-	type mybool bool
-	type myint8 int8
-	type myint16 int16
-	type myint32 int32
-	type myint64 int64
-	type myint int
-	type myuint8 uint8
-	type myuint16 uint16
-	type myuint32 uint32
-	type myuint64 uint64
-	type myuint uint
-	type myfloat32 float32
-	type myfloat64 float64
-	type mystring string
-
-	const cansetreflectiontest = "cansetreflectiontest"
-	const cansettest = "cansettest"
-
-	now := time.Now().Truncate(time.Millisecond)
-	d128 := primitive.NewDecimal128(12345, 67890)
-	var pbool = func(b bool) *bool { return &b }
-	var pi32 = func(i32 int32) *int32 { return &i32 }
-	var pi64 = func(i64 int64) *int64 { return &i64 }
-
-	type subtest struct {
-		name   string
-		val    interface{}
-		dctx   *DecodeContext
-		llvrw  *bsonrwtest.ValueReaderWriter
-		invoke bsonrwtest.Invoked
-		err    error
-	}
-
-	testCases := []struct {
-		name     string
-		vd       ValueDecoder
-		subtests []subtest
-	}{
-		{
-			"BooleanDecodeValue",
-			ValueDecoderFunc(dvd.BooleanDecodeValue),
-			[]subtest{
-				{
-					"wrong type",
-					wrong,
-					nil,
-					&bsonrwtest.ValueReaderWriter{BSONType: bsontype.Boolean},
-					bsonrwtest.Nothing,
-					ValueDecoderError{Name: "BooleanDecodeValue", Kinds: []reflect.Kind{reflect.Bool}, Received: reflect.ValueOf(wrong)},
-				},
-				{
-					"type not boolean",
-					bool(false),
-					nil,
-					&bsonrwtest.ValueReaderWriter{BSONType: bsontype.String},
-					bsonrwtest.Nothing,
-					fmt.Errorf("cannot decode %v into a boolean", bsontype.String),
-				},
-				{
-					"fast path",
-					bool(true),
-					nil,
-					&bsonrwtest.ValueReaderWriter{BSONType: bsontype.Boolean, Return: bool(true)},
-					bsonrwtest.ReadBoolean,
-					nil,
-				},
-				{
-					"reflection path",
-					mybool(true),
-					nil,
-					&bsonrwtest.ValueReaderWriter{BSONType: bsontype.Boolean, Return: bool(true)},
-					bsonrwtest.ReadBoolean,
-					nil,
-				},
-				{
-					"reflection path error",
-					mybool(true),
-					nil,
-					&bsonrwtest.ValueReaderWriter{BSONType: bsontype.Boolean, Return: bool(true), Err: errors.New("ReadBoolean Error"), ErrAfter: bsonrwtest.ReadBoolean},
-					bsonrwtest.ReadBoolean, errors.New("ReadBoolean Error"),
-				},
-				{
-					"can set false",
-					cansettest,
-					nil,
-					&bsonrwtest.ValueReaderWriter{BSONType: bsontype.Boolean},
-					bsonrwtest.Nothing,
-					ValueDecoderError{Name: "BooleanDecodeValue", Kinds: []reflect.Kind{reflect.Bool}},
-				},
-			},
-		},
-		{
-			"IntDecodeValue",
-			ValueDecoderFunc(dvd.IntDecodeValue),
-			[]subtest{
-				{
-					"wrong type",
-					wrong,
-					nil,
-					&bsonrwtest.ValueReaderWriter{BSONType: bsontype.Int32, Return: int32(0)},
-					bsonrwtest.ReadInt32,
-					ValueDecoderError{
-						Name:     "IntDecodeValue",
-						Kinds:    []reflect.Kind{reflect.Int8, reflect.Int16, reflect.Int32, reflect.Int64, reflect.Int},
-						Received: reflect.ValueOf(wrong),
-					},
-				},
-				{
-					"type not int32/int64",
-					0,
-					nil,
-					&bsonrwtest.ValueReaderWriter{BSONType: bsontype.String},
-					bsonrwtest.Nothing,
-					fmt.Errorf("cannot decode %v into an integer type", bsontype.String),
-				},
-				{
-					"ReadInt32 error",
-					0,
-					nil,
-					&bsonrwtest.ValueReaderWriter{BSONType: bsontype.Int32, Return: int32(0), Err: errors.New("ReadInt32 error"), ErrAfter: bsonrwtest.ReadInt32},
-					bsonrwtest.ReadInt32,
-					errors.New("ReadInt32 error"),
-				},
-				{
-					"ReadInt64 error",
-					0,
-					nil,
-					&bsonrwtest.ValueReaderWriter{BSONType: bsontype.Int64, Return: int64(0), Err: errors.New("ReadInt64 error"), ErrAfter: bsonrwtest.ReadInt64},
-					bsonrwtest.ReadInt64,
-					errors.New("ReadInt64 error"),
-				},
-				{
-					"ReadDouble error",
-					0,
-					nil,
-					&bsonrwtest.ValueReaderWriter{BSONType: bsontype.Double, Return: float64(0), Err: errors.New("ReadDouble error"), ErrAfter: bsonrwtest.ReadDouble},
-					bsonrwtest.ReadDouble,
-					errors.New("ReadDouble error"),
-				},
-				{
-					"ReadDouble", int64(3), &DecodeContext{},
-					&bsonrwtest.ValueReaderWriter{BSONType: bsontype.Double, Return: float64(3.00)}, bsonrwtest.ReadDouble,
-					nil,
-				},
-				{
-					"ReadDouble (truncate)", int64(3), &DecodeContext{Truncate: true},
-					&bsonrwtest.ValueReaderWriter{BSONType: bsontype.Double, Return: float64(3.14)}, bsonrwtest.ReadDouble,
-					nil,
-				},
-				{
-					"ReadDouble (no truncate)", int64(0), nil,
-					&bsonrwtest.ValueReaderWriter{BSONType: bsontype.Double, Return: float64(3.14)}, bsonrwtest.ReadDouble,
-					errors.New("IntDecodeValue can only truncate float64 to an integer type when truncation is enabled"),
-				},
-				{
-					"ReadDouble overflows int64", int64(0), nil,
-					&bsonrwtest.ValueReaderWriter{BSONType: bsontype.Double, Return: math.MaxFloat64}, bsonrwtest.ReadDouble,
-					fmt.Errorf("%g overflows int64", math.MaxFloat64),
-				},
-				{"int8/fast path", int8(127), nil, &bsonrwtest.ValueReaderWriter{BSONType: bsontype.Int32, Return: int32(127)}, bsonrwtest.ReadInt32, nil},
-				{"int16/fast path", int16(32676), nil, &bsonrwtest.ValueReaderWriter{BSONType: bsontype.Int32, Return: int32(32676)}, bsonrwtest.ReadInt32, nil},
-				{"int32/fast path", int32(1234), nil, &bsonrwtest.ValueReaderWriter{BSONType: bsontype.Int32, Return: int32(1234)}, bsonrwtest.ReadInt32, nil},
-				{"int64/fast path", int64(1234), nil, &bsonrwtest.ValueReaderWriter{BSONType: bsontype.Int64, Return: int64(1234)}, bsonrwtest.ReadInt64, nil},
-				{"int/fast path", int(1234), nil, &bsonrwtest.ValueReaderWriter{BSONType: bsontype.Int64, Return: int64(1234)}, bsonrwtest.ReadInt64, nil},
-				{
-					"int8/fast path - nil", (*int8)(nil), nil,
-					&bsonrwtest.ValueReaderWriter{BSONType: bsontype.Int32, Return: int32(0)}, bsonrwtest.ReadInt32,
-					ValueDecoderError{
-						Name:     "IntDecodeValue",
-						Kinds:    []reflect.Kind{reflect.Int8, reflect.Int16, reflect.Int32, reflect.Int64, reflect.Int},
-						Received: reflect.ValueOf((*int8)(nil)),
-					},
-				},
-				{
-					"int16/fast path - nil", (*int16)(nil), nil,
-					&bsonrwtest.ValueReaderWriter{BSONType: bsontype.Int32, Return: int32(0)}, bsonrwtest.ReadInt32,
-					ValueDecoderError{
-						Name:     "IntDecodeValue",
-						Kinds:    []reflect.Kind{reflect.Int8, reflect.Int16, reflect.Int32, reflect.Int64, reflect.Int},
-						Received: reflect.ValueOf((*int16)(nil)),
-					},
-				},
-				{
-					"int32/fast path - nil", (*int32)(nil), nil,
-					&bsonrwtest.ValueReaderWriter{BSONType: bsontype.Int32, Return: int32(0)}, bsonrwtest.ReadInt32,
-					ValueDecoderError{
-						Name:     "IntDecodeValue",
-						Kinds:    []reflect.Kind{reflect.Int8, reflect.Int16, reflect.Int32, reflect.Int64, reflect.Int},
-						Received: reflect.ValueOf((*int32)(nil)),
-					},
-				},
-				{
-					"int64/fast path - nil", (*int64)(nil), nil,
-					&bsonrwtest.ValueReaderWriter{BSONType: bsontype.Int32, Return: int32(0)}, bsonrwtest.ReadInt32,
-					ValueDecoderError{
-						Name:     "IntDecodeValue",
-						Kinds:    []reflect.Kind{reflect.Int8, reflect.Int16, reflect.Int32, reflect.Int64, reflect.Int},
-						Received: reflect.ValueOf((*int64)(nil)),
-					},
-				},
-				{
-					"int/fast path - nil", (*int)(nil), nil,
-					&bsonrwtest.ValueReaderWriter{BSONType: bsontype.Int32, Return: int32(0)}, bsonrwtest.ReadInt32,
-					ValueDecoderError{
-						Name:     "IntDecodeValue",
-						Kinds:    []reflect.Kind{reflect.Int8, reflect.Int16, reflect.Int32, reflect.Int64, reflect.Int},
-						Received: reflect.ValueOf((*int)(nil)),
-					},
-				},
-				{
-					"int8/fast path - overflow", int8(0), nil,
-					&bsonrwtest.ValueReaderWriter{BSONType: bsontype.Int32, Return: int32(129)}, bsonrwtest.ReadInt32,
-					fmt.Errorf("%d overflows int8", 129),
-				},
-				{
-					"int16/fast path - overflow", int16(0), nil,
-					&bsonrwtest.ValueReaderWriter{BSONType: bsontype.Int32, Return: int32(32768)}, bsonrwtest.ReadInt32,
-					fmt.Errorf("%d overflows int16", 32768),
-				},
-				{
-					"int32/fast path - overflow", int32(0), nil,
-					&bsonrwtest.ValueReaderWriter{BSONType: bsontype.Int64, Return: int64(2147483648)}, bsonrwtest.ReadInt64,
-					fmt.Errorf("%d overflows int32", 2147483648),
-				},
-				{
-					"int8/fast path - overflow (negative)", int8(0), nil,
-					&bsonrwtest.ValueReaderWriter{BSONType: bsontype.Int32, Return: int32(-129)}, bsonrwtest.ReadInt32,
-					fmt.Errorf("%d overflows int8", -129),
-				},
-				{
-					"int16/fast path - overflow (negative)", int16(0), nil,
-					&bsonrwtest.ValueReaderWriter{BSONType: bsontype.Int32, Return: int32(-32769)}, bsonrwtest.ReadInt32,
-					fmt.Errorf("%d overflows int16", -32769),
-				},
-				{
-					"int32/fast path - overflow (negative)", int32(0), nil,
-					&bsonrwtest.ValueReaderWriter{BSONType: bsontype.Int64, Return: int64(-2147483649)}, bsonrwtest.ReadInt64,
-					fmt.Errorf("%d overflows int32", -2147483649),
-				},
-				{
-					"int8/reflection path", myint8(127), nil,
-					&bsonrwtest.ValueReaderWriter{BSONType: bsontype.Int32, Return: int32(127)}, bsonrwtest.ReadInt32,
-					nil,
-				},
-				{
-					"int16/reflection path", myint16(255), nil,
-					&bsonrwtest.ValueReaderWriter{BSONType: bsontype.Int32, Return: int32(255)}, bsonrwtest.ReadInt32,
-					nil,
-				},
-				{
-					"int32/reflection path", myint32(511), nil,
-					&bsonrwtest.ValueReaderWriter{BSONType: bsontype.Int32, Return: int32(511)}, bsonrwtest.ReadInt32,
-					nil,
-				},
-				{
-					"int64/reflection path", myint64(1023), nil,
-					&bsonrwtest.ValueReaderWriter{BSONType: bsontype.Int32, Return: int32(1023)}, bsonrwtest.ReadInt32,
-					nil,
-				},
-				{
-					"int/reflection path", myint(2047), nil,
-					&bsonrwtest.ValueReaderWriter{BSONType: bsontype.Int32, Return: int32(2047)}, bsonrwtest.ReadInt32,
-					nil,
-				},
-				{
-					"int8/reflection path - overflow", myint8(0), nil,
-					&bsonrwtest.ValueReaderWriter{BSONType: bsontype.Int32, Return: int32(129)}, bsonrwtest.ReadInt32,
-					fmt.Errorf("%d overflows int8", 129),
-				},
-				{
-					"int16/reflection path - overflow", myint16(0), nil,
-					&bsonrwtest.ValueReaderWriter{BSONType: bsontype.Int32, Return: int32(32768)}, bsonrwtest.ReadInt32,
-					fmt.Errorf("%d overflows int16", 32768),
-				},
-				{
-					"int32/reflection path - overflow", myint32(0), nil,
-					&bsonrwtest.ValueReaderWriter{BSONType: bsontype.Int64, Return: int64(2147483648)}, bsonrwtest.ReadInt64,
-					fmt.Errorf("%d overflows int32", 2147483648),
-				},
-				{
-					"int8/reflection path - overflow (negative)", myint8(0), nil,
-					&bsonrwtest.ValueReaderWriter{BSONType: bsontype.Int32, Return: int32(-129)}, bsonrwtest.ReadInt32,
-					fmt.Errorf("%d overflows int8", -129),
-				},
-				{
-					"int16/reflection path - overflow (negative)", myint16(0), nil,
-					&bsonrwtest.ValueReaderWriter{BSONType: bsontype.Int32, Return: int32(-32769)}, bsonrwtest.ReadInt32,
-					fmt.Errorf("%d overflows int16", -32769),
-				},
-				{
-					"int32/reflection path - overflow (negative)", myint32(0), nil,
-					&bsonrwtest.ValueReaderWriter{BSONType: bsontype.Int64, Return: int64(-2147483649)}, bsonrwtest.ReadInt64,
-					fmt.Errorf("%d overflows int32", -2147483649),
-				},
-				{
-					"can set false",
-					cansettest,
-					nil,
-					&bsonrwtest.ValueReaderWriter{BSONType: bsontype.Int32, Return: int32(0)},
-					bsonrwtest.Nothing,
-					ValueDecoderError{
-						Name:  "IntDecodeValue",
-						Kinds: []reflect.Kind{reflect.Int8, reflect.Int16, reflect.Int32, reflect.Int64, reflect.Int},
-					},
-				},
-			},
-		},
-		{
-			"UintDecodeValue",
-			ValueDecoderFunc(dvd.UintDecodeValue),
-			[]subtest{
-				{
-					"wrong type",
-					wrong,
-					nil,
-					&bsonrwtest.ValueReaderWriter{BSONType: bsontype.Int32, Return: int32(0)},
-					bsonrwtest.ReadInt32,
-					ValueDecoderError{
-						Name:     "UintDecodeValue",
-						Kinds:    []reflect.Kind{reflect.Uint8, reflect.Uint16, reflect.Uint32, reflect.Uint64, reflect.Uint},
-						Received: reflect.ValueOf(wrong),
-					},
-				},
-				{
-					"type not int32/int64",
-					0,
-					nil,
-					&bsonrwtest.ValueReaderWriter{BSONType: bsontype.String},
-					bsonrwtest.Nothing,
-					fmt.Errorf("cannot decode %v into an integer type", bsontype.String),
-				},
-				{
-					"ReadInt32 error",
-					uint(0),
-					nil,
-					&bsonrwtest.ValueReaderWriter{BSONType: bsontype.Int32, Return: int32(0), Err: errors.New("ReadInt32 error"), ErrAfter: bsonrwtest.ReadInt32},
-					bsonrwtest.ReadInt32,
-					errors.New("ReadInt32 error"),
-				},
-				{
-					"ReadInt64 error",
-					uint(0),
-					nil,
-					&bsonrwtest.ValueReaderWriter{BSONType: bsontype.Int64, Return: int64(0), Err: errors.New("ReadInt64 error"), ErrAfter: bsonrwtest.ReadInt64},
-					bsonrwtest.ReadInt64,
-					errors.New("ReadInt64 error"),
-				},
-				{
-					"ReadDouble error",
-					0,
-					nil,
-					&bsonrwtest.ValueReaderWriter{BSONType: bsontype.Double, Return: float64(0), Err: errors.New("ReadDouble error"), ErrAfter: bsonrwtest.ReadDouble},
-					bsonrwtest.ReadDouble,
-					errors.New("ReadDouble error"),
-				},
-				{
-					"ReadDouble", uint64(3), &DecodeContext{},
-					&bsonrwtest.ValueReaderWriter{BSONType: bsontype.Double, Return: float64(3.00)}, bsonrwtest.ReadDouble,
-					nil,
-				},
-				{
-					"ReadDouble (truncate)", uint64(3), &DecodeContext{Truncate: true},
-					&bsonrwtest.ValueReaderWriter{BSONType: bsontype.Double, Return: float64(3.14)}, bsonrwtest.ReadDouble,
-					nil,
-				},
-				{
-					"ReadDouble (no truncate)", uint64(0), nil,
-					&bsonrwtest.ValueReaderWriter{BSONType: bsontype.Double, Return: float64(3.14)}, bsonrwtest.ReadDouble,
-					errors.New("UintDecodeValue can only truncate float64 to an integer type when truncation is enabled"),
-				},
-				{
-					"ReadDouble overflows int64", uint64(0), nil,
-					&bsonrwtest.ValueReaderWriter{BSONType: bsontype.Double, Return: math.MaxFloat64}, bsonrwtest.ReadDouble,
-					fmt.Errorf("%g overflows int64", math.MaxFloat64),
-				},
-				{"uint8/fast path", uint8(127), nil, &bsonrwtest.ValueReaderWriter{BSONType: bsontype.Int32, Return: int32(127)}, bsonrwtest.ReadInt32, nil},
-				{"uint16/fast path", uint16(255), nil, &bsonrwtest.ValueReaderWriter{BSONType: bsontype.Int32, Return: int32(255)}, bsonrwtest.ReadInt32, nil},
-				{"uint32/fast path", uint32(1234), nil, &bsonrwtest.ValueReaderWriter{BSONType: bsontype.Int32, Return: int32(1234)}, bsonrwtest.ReadInt32, nil},
-				{"uint64/fast path", uint64(1234), nil, &bsonrwtest.ValueReaderWriter{BSONType: bsontype.Int64, Return: int64(1234)}, bsonrwtest.ReadInt64, nil},
-				{"uint/fast path", uint(1234), nil, &bsonrwtest.ValueReaderWriter{BSONType: bsontype.Int64, Return: int64(1234)}, bsonrwtest.ReadInt64, nil},
-				{
-					"uint8/fast path - nil", (*uint8)(nil), nil,
-					&bsonrwtest.ValueReaderWriter{BSONType: bsontype.Int32, Return: int32(0)}, bsonrwtest.ReadInt32,
-					ValueDecoderError{
-						Name:     "UintDecodeValue",
-						Kinds:    []reflect.Kind{reflect.Uint8, reflect.Uint16, reflect.Uint32, reflect.Uint64, reflect.Uint},
-						Received: reflect.ValueOf((*uint8)(nil)),
-					},
-				},
-				{
-					"uint16/fast path - nil", (*uint16)(nil), nil,
-					&bsonrwtest.ValueReaderWriter{BSONType: bsontype.Int32, Return: int32(0)}, bsonrwtest.ReadInt32,
-					ValueDecoderError{
-						Name:     "UintDecodeValue",
-						Kinds:    []reflect.Kind{reflect.Uint8, reflect.Uint16, reflect.Uint32, reflect.Uint64, reflect.Uint},
-						Received: reflect.ValueOf((*uint16)(nil)),
-					},
-				},
-				{
-					"uint32/fast path - nil", (*uint32)(nil), nil,
-					&bsonrwtest.ValueReaderWriter{BSONType: bsontype.Int32, Return: int32(0)}, bsonrwtest.ReadInt32,
-					ValueDecoderError{
-						Name:     "UintDecodeValue",
-						Kinds:    []reflect.Kind{reflect.Uint8, reflect.Uint16, reflect.Uint32, reflect.Uint64, reflect.Uint},
-						Received: reflect.ValueOf((*uint32)(nil)),
-					},
-				},
-				{
-					"uint64/fast path - nil", (*uint64)(nil), nil,
-					&bsonrwtest.ValueReaderWriter{BSONType: bsontype.Int32, Return: int32(0)}, bsonrwtest.ReadInt32,
-					ValueDecoderError{
-						Name:     "UintDecodeValue",
-						Kinds:    []reflect.Kind{reflect.Uint8, reflect.Uint16, reflect.Uint32, reflect.Uint64, reflect.Uint},
-						Received: reflect.ValueOf((*uint64)(nil)),
-					},
-				},
-				{
-					"uint/fast path - nil", (*uint)(nil), nil,
-					&bsonrwtest.ValueReaderWriter{BSONType: bsontype.Int32, Return: int32(0)}, bsonrwtest.ReadInt32,
-					ValueDecoderError{
-						Name:     "UintDecodeValue",
-						Kinds:    []reflect.Kind{reflect.Uint8, reflect.Uint16, reflect.Uint32, reflect.Uint64, reflect.Uint},
-						Received: reflect.ValueOf((*uint)(nil)),
-					},
-				},
-				{
-					"uint8/fast path - overflow", uint8(0), nil,
-					&bsonrwtest.ValueReaderWriter{BSONType: bsontype.Int32, Return: int32(1 << 8)}, bsonrwtest.ReadInt32,
-					fmt.Errorf("%d overflows uint8", 1<<8),
-				},
-				{
-					"uint16/fast path - overflow", uint16(0), nil,
-					&bsonrwtest.ValueReaderWriter{BSONType: bsontype.Int32, Return: int32(1 << 16)}, bsonrwtest.ReadInt32,
-					fmt.Errorf("%d overflows uint16", 1<<16),
-				},
-				{
-					"uint32/fast path - overflow", uint32(0), nil,
-					&bsonrwtest.ValueReaderWriter{BSONType: bsontype.Int64, Return: int64(1 << 32)}, bsonrwtest.ReadInt64,
-					fmt.Errorf("%d overflows uint32", 1<<32),
-				},
-				{
-					"uint8/fast path - overflow (negative)", uint8(0), nil,
-					&bsonrwtest.ValueReaderWriter{BSONType: bsontype.Int32, Return: int32(-1)}, bsonrwtest.ReadInt32,
-					fmt.Errorf("%d overflows uint8", -1),
-				},
-				{
-					"uint16/fast path - overflow (negative)", uint16(0), nil,
-					&bsonrwtest.ValueReaderWriter{BSONType: bsontype.Int32, Return: int32(-1)}, bsonrwtest.ReadInt32,
-					fmt.Errorf("%d overflows uint16", -1),
-				},
-				{
-					"uint32/fast path - overflow (negative)", uint32(0), nil,
-					&bsonrwtest.ValueReaderWriter{BSONType: bsontype.Int64, Return: int64(-1)}, bsonrwtest.ReadInt64,
-					fmt.Errorf("%d overflows uint32", -1),
-				},
-				{
-					"uint64/fast path - overflow (negative)", uint64(0), nil,
-					&bsonrwtest.ValueReaderWriter{BSONType: bsontype.Int64, Return: int64(-1)}, bsonrwtest.ReadInt64,
-					fmt.Errorf("%d overflows uint64", -1),
-				},
-				{
-					"uint/fast path - overflow (negative)", uint(0), nil,
-					&bsonrwtest.ValueReaderWriter{BSONType: bsontype.Int64, Return: int64(-1)}, bsonrwtest.ReadInt64,
-					fmt.Errorf("%d overflows uint", -1),
-				},
-				{
-					"uint8/reflection path", myuint8(127), nil,
-					&bsonrwtest.ValueReaderWriter{BSONType: bsontype.Int32, Return: int32(127)}, bsonrwtest.ReadInt32,
-					nil,
-				},
-				{
-					"uint16/reflection path", myuint16(255), nil,
-					&bsonrwtest.ValueReaderWriter{BSONType: bsontype.Int32, Return: int32(255)}, bsonrwtest.ReadInt32,
-					nil,
-				},
-				{
-					"uint32/reflection path", myuint32(511), nil,
-					&bsonrwtest.ValueReaderWriter{BSONType: bsontype.Int32, Return: int32(511)}, bsonrwtest.ReadInt32,
-					nil,
-				},
-				{
-					"uint64/reflection path", myuint64(1023), nil,
-					&bsonrwtest.ValueReaderWriter{BSONType: bsontype.Int32, Return: int32(1023)}, bsonrwtest.ReadInt32,
-					nil,
-				},
-				{
-					"uint/reflection path", myuint(2047), nil,
-					&bsonrwtest.ValueReaderWriter{BSONType: bsontype.Int32, Return: int32(2047)}, bsonrwtest.ReadInt32,
-					nil,
-				},
-				{
-					"uint8/reflection path - overflow", myuint8(0), nil,
-					&bsonrwtest.ValueReaderWriter{BSONType: bsontype.Int32, Return: int32(1 << 8)}, bsonrwtest.ReadInt32,
-					fmt.Errorf("%d overflows uint8", 1<<8),
-				},
-				{
-					"uint16/reflection path - overflow", myuint16(0), nil,
-					&bsonrwtest.ValueReaderWriter{BSONType: bsontype.Int32, Return: int32(1 << 16)}, bsonrwtest.ReadInt32,
-					fmt.Errorf("%d overflows uint16", 1<<16),
-				},
-				{
-					"uint32/reflection path - overflow", myuint32(0), nil,
-					&bsonrwtest.ValueReaderWriter{BSONType: bsontype.Int64, Return: int64(1 << 32)}, bsonrwtest.ReadInt64,
-					fmt.Errorf("%d overflows uint32", 1<<32),
-				},
-				{
-					"uint8/reflection path - overflow (negative)", myuint8(0), nil,
-					&bsonrwtest.ValueReaderWriter{BSONType: bsontype.Int32, Return: int32(-1)}, bsonrwtest.ReadInt32,
-					fmt.Errorf("%d overflows uint8", -1),
-				},
-				{
-					"uint16/reflection path - overflow (negative)", myuint16(0), nil,
-					&bsonrwtest.ValueReaderWriter{BSONType: bsontype.Int32, Return: int32(-1)}, bsonrwtest.ReadInt32,
-					fmt.Errorf("%d overflows uint16", -1),
-				},
-				{
-					"uint32/reflection path - overflow (negative)", myuint32(0), nil,
-					&bsonrwtest.ValueReaderWriter{BSONType: bsontype.Int64, Return: int64(-1)}, bsonrwtest.ReadInt64,
-					fmt.Errorf("%d overflows uint32", -1),
-				},
-				{
-					"uint64/reflection path - overflow (negative)", myuint64(0), nil,
-					&bsonrwtest.ValueReaderWriter{BSONType: bsontype.Int64, Return: int64(-1)}, bsonrwtest.ReadInt64,
-					fmt.Errorf("%d overflows uint64", -1),
-				},
-				{
-					"uint/reflection path - overflow (negative)", myuint(0), nil,
-					&bsonrwtest.ValueReaderWriter{BSONType: bsontype.Int64, Return: int64(-1)}, bsonrwtest.ReadInt64,
-					fmt.Errorf("%d overflows uint", -1),
-				},
-				{
-					"can set false",
-					cansettest,
-					nil,
-					&bsonrwtest.ValueReaderWriter{BSONType: bsontype.Int32, Return: int32(0)},
-					bsonrwtest.Nothing,
-					ValueDecoderError{
-						Name:  "UintDecodeValue",
-						Kinds: []reflect.Kind{reflect.Uint8, reflect.Uint16, reflect.Uint32, reflect.Uint64, reflect.Uint},
-					},
-				},
-			},
-		},
-		{
-			"FloatDecodeValue",
-			ValueDecoderFunc(dvd.FloatDecodeValue),
-			[]subtest{
-				{
-					"wrong type",
-					wrong,
-					nil,
-					&bsonrwtest.ValueReaderWriter{BSONType: bsontype.Double, Return: float64(0)},
-					bsonrwtest.ReadDouble,
-					ValueDecoderError{
-						Name:     "FloatDecodeValue",
-						Kinds:    []reflect.Kind{reflect.Float32, reflect.Float64},
-						Received: reflect.ValueOf(wrong),
-					},
-				},
-				{
-					"type not double",
-					0,
-					nil,
-					&bsonrwtest.ValueReaderWriter{BSONType: bsontype.String},
-					bsonrwtest.Nothing,
-					fmt.Errorf("cannot decode %v into a float32 or float64 type", bsontype.String),
-				},
-				{
-					"ReadDouble error",
-					float64(0),
-					nil,
-					&bsonrwtest.ValueReaderWriter{BSONType: bsontype.Double, Return: float64(0), Err: errors.New("ReadDouble error"), ErrAfter: bsonrwtest.ReadDouble},
-					bsonrwtest.ReadDouble,
-					errors.New("ReadDouble error"),
-				},
-				{
-					"ReadInt32 error",
-					float64(0),
-					nil,
-					&bsonrwtest.ValueReaderWriter{BSONType: bsontype.Int32, Return: int32(0), Err: errors.New("ReadInt32 error"), ErrAfter: bsonrwtest.ReadInt32},
-					bsonrwtest.ReadInt32,
-					errors.New("ReadInt32 error"),
-				},
-				{
-					"ReadInt64 error",
-					float64(0),
-					nil,
-					&bsonrwtest.ValueReaderWriter{BSONType: bsontype.Int64, Return: int64(0), Err: errors.New("ReadInt64 error"), ErrAfter: bsonrwtest.ReadInt64},
-					bsonrwtest.ReadInt64,
-					errors.New("ReadInt64 error"),
-				},
-				{
-					"float64/int32", float32(32.0), nil,
-					&bsonrwtest.ValueReaderWriter{BSONType: bsontype.Int32, Return: int32(32)}, bsonrwtest.ReadInt32,
-					nil,
-				},
-				{
-					"float64/int64", float32(64.0), nil,
-					&bsonrwtest.ValueReaderWriter{BSONType: bsontype.Int64, Return: int64(64)}, bsonrwtest.ReadInt64,
-					nil,
-				},
-				{
-					"float32/fast path (equal)", float32(3.0), nil,
-					&bsonrwtest.ValueReaderWriter{BSONType: bsontype.Double, Return: float64(3.0)}, bsonrwtest.ReadDouble,
-					nil,
-				},
-				{
-					"float64/fast path", float64(3.14159), nil,
-					&bsonrwtest.ValueReaderWriter{BSONType: bsontype.Double, Return: float64(3.14159)}, bsonrwtest.ReadDouble,
-					nil,
-				},
-				{
-					"float32/fast path (truncate)", float32(3.14), &DecodeContext{Truncate: true},
-					&bsonrwtest.ValueReaderWriter{BSONType: bsontype.Double, Return: float64(3.14)}, bsonrwtest.ReadDouble,
-					nil,
-				},
-				{
-					"float32/fast path (no truncate)", float32(0), nil,
-					&bsonrwtest.ValueReaderWriter{BSONType: bsontype.Double, Return: float64(3.14)}, bsonrwtest.ReadDouble,
-					errors.New("FloatDecodeValue can only convert float64 to float32 when truncation is allowed"),
-				},
-				{
-					"float32/fast path - nil", (*float32)(nil), nil,
-					&bsonrwtest.ValueReaderWriter{BSONType: bsontype.Double, Return: float64(0)}, bsonrwtest.ReadDouble,
-					ValueDecoderError{
-						Name:     "FloatDecodeValue",
-						Kinds:    []reflect.Kind{reflect.Float32, reflect.Float64},
-						Received: reflect.ValueOf((*float32)(nil)),
-					},
-				},
-				{
-					"float64/fast path - nil", (*float64)(nil), nil,
-					&bsonrwtest.ValueReaderWriter{BSONType: bsontype.Double, Return: float64(0)}, bsonrwtest.ReadDouble,
-					ValueDecoderError{
-						Name:     "FloatDecodeValue",
-						Kinds:    []reflect.Kind{reflect.Float32, reflect.Float64},
-						Received: reflect.ValueOf((*float64)(nil)),
-					},
-				},
-				{
-					"float32/reflection path (equal)", myfloat32(3.0), nil,
-					&bsonrwtest.ValueReaderWriter{BSONType: bsontype.Double, Return: float64(3.0)}, bsonrwtest.ReadDouble,
-					nil,
-				},
-				{
-					"float64/reflection path", myfloat64(3.14159), nil,
-					&bsonrwtest.ValueReaderWriter{BSONType: bsontype.Double, Return: float64(3.14159)}, bsonrwtest.ReadDouble,
-					nil,
-				},
-				{
-					"float32/reflection path (truncate)", myfloat32(3.14), &DecodeContext{Truncate: true},
-					&bsonrwtest.ValueReaderWriter{BSONType: bsontype.Double, Return: float64(3.14)}, bsonrwtest.ReadDouble,
-					nil,
-				},
-				{
-					"float32/reflection path (no truncate)", myfloat32(0), nil,
-					&bsonrwtest.ValueReaderWriter{BSONType: bsontype.Double, Return: float64(3.14)}, bsonrwtest.ReadDouble,
-					errors.New("FloatDecodeValue can only convert float64 to float32 when truncation is allowed"),
-				},
-				{
-					"can set false",
-					cansettest,
-					nil,
-					&bsonrwtest.ValueReaderWriter{BSONType: bsontype.Double, Return: float64(0)},
-					bsonrwtest.Nothing,
-					ValueDecoderError{
-						Name:  "FloatDecodeValue",
-						Kinds: []reflect.Kind{reflect.Float32, reflect.Float64},
-					},
-				},
-			},
-		},
-		{
-			"TimeDecodeValue",
-			ValueDecoderFunc(dvd.TimeDecodeValue),
-			[]subtest{
-				{
-					"wrong type",
-					wrong,
-					nil,
-					&bsonrwtest.ValueReaderWriter{BSONType: bsontype.DateTime, Return: int64(0)},
-					bsonrwtest.ReadDateTime,
-					ValueDecoderError{Name: "TimeDecodeValue", Types: []reflect.Type{tTime}, Received: reflect.ValueOf(wrong)},
-				},
-				{
-					"ReadDateTime error",
-					time.Time{},
-					nil,
-					&bsonrwtest.ValueReaderWriter{BSONType: bsontype.DateTime, Return: int64(0), Err: errors.New("ReadDateTime error"), ErrAfter: bsonrwtest.ReadDateTime},
-					bsonrwtest.ReadDateTime,
-					errors.New("ReadDateTime error"),
-				},
-				{
-					"time.Time",
-					now,
-					nil,
-					&bsonrwtest.ValueReaderWriter{BSONType: bsontype.DateTime, Return: int64(now.UnixNano() / int64(time.Millisecond))},
-					bsonrwtest.ReadDateTime,
-					nil,
-				},
-				{
-					"can set false",
-					cansettest,
-					nil,
-					&bsonrwtest.ValueReaderWriter{BSONType: bsontype.DateTime, Return: int64(0)},
-					bsonrwtest.Nothing,
-					ValueDecoderError{Name: "TimeDecodeValue", Types: []reflect.Type{tTime}},
-				},
-			},
-		},
-		{
-			"MapDecodeValue",
-			ValueDecoderFunc(dvd.MapDecodeValue),
-			[]subtest{
-				{
-					"wrong kind",
-					wrong,
-					nil,
-					&bsonrwtest.ValueReaderWriter{},
-					bsonrwtest.Nothing,
-					ValueDecoderError{Name: "MapDecodeValue", Kinds: []reflect.Kind{reflect.Map}, Received: reflect.ValueOf(wrong)},
-				},
-				{
-					"wrong kind (non-string key)",
-					map[int]interface{}{},
-					nil,
-					&bsonrwtest.ValueReaderWriter{},
-					bsonrwtest.Nothing,
-					ValueDecoderError{
-						Name:     "MapDecodeValue",
-						Kinds:    []reflect.Kind{reflect.Map},
-						Received: reflect.ValueOf(map[int]interface{}{}),
-					},
-				},
-				{
-					"ReadDocument Error",
-					make(map[string]interface{}),
-					nil,
-					&bsonrwtest.ValueReaderWriter{Err: errors.New("rd error"), ErrAfter: bsonrwtest.ReadDocument},
-					bsonrwtest.ReadDocument,
-					errors.New("rd error"),
-				},
-				{
-					"Lookup Error",
-					map[string]string{},
-					&DecodeContext{Registry: NewRegistryBuilder().Build()},
-					&bsonrwtest.ValueReaderWriter{},
-					bsonrwtest.ReadDocument,
-					ErrNoDecoder{Type: reflect.TypeOf(string(""))},
-				},
-				{
-					"ReadElement Error",
-					make(map[string]interface{}),
-					&DecodeContext{Registry: buildDefaultRegistry()},
-					&bsonrwtest.ValueReaderWriter{Err: errors.New("re error"), ErrAfter: bsonrwtest.ReadElement},
-					bsonrwtest.ReadElement,
-					errors.New("re error"),
-				},
-				{
-					"can set false",
-					cansettest,
-					nil,
-					&bsonrwtest.ValueReaderWriter{},
-					bsonrwtest.Nothing,
-					ValueDecoderError{Name: "MapDecodeValue", Kinds: []reflect.Kind{reflect.Map}},
-				},
-				{
-					"wrong BSON type",
-					map[string]interface{}{},
-					nil,
-					&bsonrwtest.ValueReaderWriter{BSONType: bsontype.String},
-					bsonrwtest.Nothing,
-					errors.New("cannot decode string into a map[string]interface {}"),
-				},
-			},
-		},
-		{
-			"ArrayDecodeValue",
-			ValueDecoderFunc(dvd.ArrayDecodeValue),
-			[]subtest{
-				{
-					"wrong kind",
-					wrong,
-					nil,
-					&bsonrwtest.ValueReaderWriter{},
-					bsonrwtest.Nothing,
-					ValueDecoderError{Name: "ArrayDecodeValue", Kinds: []reflect.Kind{reflect.Array}, Received: reflect.ValueOf(wrong)},
-				},
-				{
-					"can set false",
-					cansettest,
-					nil,
-					&bsonrwtest.ValueReaderWriter{},
-					bsonrwtest.Nothing,
-					ValueDecoderError{Name: "ArrayDecodeValue", Kinds: []reflect.Kind{reflect.Array}},
-				},
-				{
-					"Not Type Array",
-					[1]interface{}{},
-					nil,
-					&bsonrwtest.ValueReaderWriter{BSONType: bsontype.String},
-					bsonrwtest.Nothing,
-					errors.New("cannot decode string into an array"),
-				},
-				{
-					"ReadArray Error",
-					[1]interface{}{},
-					nil,
-					&bsonrwtest.ValueReaderWriter{Err: errors.New("ra error"), ErrAfter: bsonrwtest.ReadArray, BSONType: bsontype.Array},
-					bsonrwtest.ReadArray,
-					errors.New("ra error"),
-				},
-				{
-					"Lookup Error",
-					[1]string{},
-					&DecodeContext{Registry: NewRegistryBuilder().Build()},
-					&bsonrwtest.ValueReaderWriter{BSONType: bsontype.Array},
-					bsonrwtest.ReadArray,
-					ErrNoDecoder{Type: reflect.TypeOf(string(""))},
-				},
-				{
-					"ReadValue Error",
-					[1]string{},
-					&DecodeContext{Registry: buildDefaultRegistry()},
-					&bsonrwtest.ValueReaderWriter{Err: errors.New("rv error"), ErrAfter: bsonrwtest.ReadValue, BSONType: bsontype.Array},
-					bsonrwtest.ReadValue,
-					errors.New("rv error"),
-				},
-				{
-					"DecodeValue Error",
-					[1]string{},
-					&DecodeContext{Registry: buildDefaultRegistry()},
-					&bsonrwtest.ValueReaderWriter{BSONType: bsontype.Array},
-					bsonrwtest.ReadValue,
-					errors.New("cannot decode array into a string type"),
-				},
-				{
-					"Document but not D",
-					[1]string{},
-					nil,
-					&bsonrwtest.ValueReaderWriter{BSONType: bsontype.Type(0)},
-					bsonrwtest.Nothing,
-					errors.New("cannot decode document into [1]string"),
-				},
-				{
-					"EmbeddedDocument but not D",
-					[1]string{},
-					nil,
-					&bsonrwtest.ValueReaderWriter{BSONType: bsontype.EmbeddedDocument},
-					bsonrwtest.Nothing,
-					errors.New("cannot decode document into [1]string"),
-				},
-			},
-		},
-		{
-			"SliceDecodeValue",
-			ValueDecoderFunc(dvd.SliceDecodeValue),
-			[]subtest{
-				{
-					"wrong kind",
-					wrong,
-					nil,
-					&bsonrwtest.ValueReaderWriter{},
-					bsonrwtest.Nothing,
-					ValueDecoderError{Name: "SliceDecodeValue", Kinds: []reflect.Kind{reflect.Slice}, Received: reflect.ValueOf(wrong)},
-				},
-				{
-					"can set false",
-					cansettest,
-					nil,
-					&bsonrwtest.ValueReaderWriter{},
-					bsonrwtest.Nothing,
-					ValueDecoderError{Name: "SliceDecodeValue", Kinds: []reflect.Kind{reflect.Slice}},
-				},
-				{
-					"Not Type Array",
-					[]interface{}{},
-					nil,
-					&bsonrwtest.ValueReaderWriter{BSONType: bsontype.String},
-					bsonrwtest.Nothing,
-					errors.New("cannot decode string into a slice"),
-				},
-				{
-					"ReadArray Error",
-					[]interface{}{},
-					nil,
-					&bsonrwtest.ValueReaderWriter{Err: errors.New("ra error"), ErrAfter: bsonrwtest.ReadArray, BSONType: bsontype.Array},
-					bsonrwtest.ReadArray,
-					errors.New("ra error"),
-				},
-				{
-					"Lookup Error",
-					[]string{},
-					&DecodeContext{Registry: NewRegistryBuilder().Build()},
-					&bsonrwtest.ValueReaderWriter{BSONType: bsontype.Array},
-					bsonrwtest.ReadArray,
-					ErrNoDecoder{Type: reflect.TypeOf(string(""))},
-				},
-				{
-					"ReadValue Error",
-					[]string{},
-					&DecodeContext{Registry: buildDefaultRegistry()},
-					&bsonrwtest.ValueReaderWriter{Err: errors.New("rv error"), ErrAfter: bsonrwtest.ReadValue, BSONType: bsontype.Array},
-					bsonrwtest.ReadValue,
-					errors.New("rv error"),
-				},
-				{
-					"DecodeValue Error",
-					[]string{},
-					&DecodeContext{Registry: buildDefaultRegistry()},
-					&bsonrwtest.ValueReaderWriter{BSONType: bsontype.Array},
-					bsonrwtest.ReadValue,
-					errors.New("cannot decode array into a string type"),
-				},
-				{
-					"Document but not D",
-					[]string{},
-					nil,
-					&bsonrwtest.ValueReaderWriter{BSONType: bsontype.Type(0)},
-					bsonrwtest.Nothing,
-					errors.New("cannot decode document into []string"),
-				},
-				{
-					"EmbeddedDocument but not D",
-					[]string{},
-					nil,
-					&bsonrwtest.ValueReaderWriter{BSONType: bsontype.EmbeddedDocument},
-					bsonrwtest.Nothing,
-					errors.New("cannot decode document into []string"),
-				},
-			},
-		},
-		{
-			"ObjectIDDecodeValue",
-			ValueDecoderFunc(dvd.ObjectIDDecodeValue),
-			[]subtest{
-				{
-					"wrong type",
-					wrong,
-					nil,
-					&bsonrwtest.ValueReaderWriter{BSONType: bsontype.ObjectID},
-					bsonrwtest.Nothing,
-					ValueDecoderError{Name: "ObjectIDDecodeValue", Types: []reflect.Type{tOID}, Received: reflect.ValueOf(wrong)},
-				},
-				{
-					"type not objectID",
-					primitive.ObjectID{},
-					nil,
-					&bsonrwtest.ValueReaderWriter{BSONType: bsontype.String},
-					bsonrwtest.Nothing,
-					fmt.Errorf("cannot decode %v into an ObjectID", bsontype.String),
-				},
-				{
-					"ReadObjectID Error",
-					primitive.ObjectID{},
-					nil,
-					&bsonrwtest.ValueReaderWriter{BSONType: bsontype.ObjectID, Err: errors.New("roid error"), ErrAfter: bsonrwtest.ReadObjectID},
-					bsonrwtest.ReadObjectID,
-					errors.New("roid error"),
-				},
-				{
-					"can set false",
-					cansettest,
-					nil,
-					&bsonrwtest.ValueReaderWriter{BSONType: bsontype.ObjectID, Return: primitive.ObjectID{}},
-					bsonrwtest.Nothing,
-					ValueDecoderError{Name: "ObjectIDDecodeValue", Types: []reflect.Type{tOID}},
-				},
-				{
-					"success",
-					primitive.ObjectID{0x01, 0x02, 0x03, 0x04, 0x05, 0x06, 0x07, 0x08, 0x09, 0x0A, 0x0B, 0x0C},
-					nil,
-					&bsonrwtest.ValueReaderWriter{
-						BSONType: bsontype.ObjectID,
-						Return:   primitive.ObjectID{0x01, 0x02, 0x03, 0x04, 0x05, 0x06, 0x07, 0x08, 0x09, 0x0A, 0x0B, 0x0C},
-					},
-					bsonrwtest.ReadObjectID,
-					nil,
-				},
-			},
-		},
-		{
-			"Decimal128DecodeValue",
-			ValueDecoderFunc(dvd.Decimal128DecodeValue),
-			[]subtest{
-				{
-					"wrong type",
-					wrong,
-					nil,
-					&bsonrwtest.ValueReaderWriter{BSONType: bsontype.Decimal128},
-					bsonrwtest.Nothing,
-					ValueDecoderError{Name: "Decimal128DecodeValue", Types: []reflect.Type{tDecimal}, Received: reflect.ValueOf(wrong)},
-				},
-				{
-					"type not decimal128",
-					primitive.Decimal128{},
-					nil,
-					&bsonrwtest.ValueReaderWriter{BSONType: bsontype.String},
-					bsonrwtest.Nothing,
-					fmt.Errorf("cannot decode %v into a primitive.Decimal128", bsontype.String),
-				},
-				{
-					"ReadDecimal128 Error",
-					primitive.Decimal128{},
-					nil,
-					&bsonrwtest.ValueReaderWriter{BSONType: bsontype.Decimal128, Err: errors.New("rd128 error"), ErrAfter: bsonrwtest.ReadDecimal128},
-					bsonrwtest.ReadDecimal128,
-					errors.New("rd128 error"),
-				},
-				{
-					"can set false",
-					cansettest,
-					nil,
-					&bsonrwtest.ValueReaderWriter{BSONType: bsontype.Decimal128, Return: d128},
-					bsonrwtest.Nothing,
-					ValueDecoderError{Name: "Decimal128DecodeValue", Types: []reflect.Type{tDecimal}},
-				},
-				{
-					"success",
-					d128,
-					nil,
-					&bsonrwtest.ValueReaderWriter{BSONType: bsontype.Decimal128, Return: d128},
-					bsonrwtest.ReadDecimal128,
-					nil,
-				},
-			},
-		},
-		{
-			"JSONNumberDecodeValue",
-			ValueDecoderFunc(dvd.JSONNumberDecodeValue),
-			[]subtest{
-				{
-					"wrong type",
-					wrong,
-					nil,
-					&bsonrwtest.ValueReaderWriter{BSONType: bsontype.ObjectID},
-					bsonrwtest.Nothing,
-					ValueDecoderError{Name: "JSONNumberDecodeValue", Types: []reflect.Type{tJSONNumber}, Received: reflect.ValueOf(wrong)},
-				},
-				{
-					"type not double/int32/int64",
-					json.Number(""),
-					nil,
-					&bsonrwtest.ValueReaderWriter{BSONType: bsontype.String},
-					bsonrwtest.Nothing,
-					fmt.Errorf("cannot decode %v into a json.Number", bsontype.String),
-				},
-				{
-					"ReadDouble Error",
-					json.Number(""),
-					nil,
-					&bsonrwtest.ValueReaderWriter{BSONType: bsontype.Double, Err: errors.New("rd error"), ErrAfter: bsonrwtest.ReadDouble},
-					bsonrwtest.ReadDouble,
-					errors.New("rd error"),
-				},
-				{
-					"ReadInt32 Error",
-					json.Number(""),
-					nil,
-					&bsonrwtest.ValueReaderWriter{BSONType: bsontype.Int32, Err: errors.New("ri32 error"), ErrAfter: bsonrwtest.ReadInt32},
-					bsonrwtest.ReadInt32,
-					errors.New("ri32 error"),
-				},
-				{
-					"ReadInt64 Error",
-					json.Number(""),
-					nil,
-					&bsonrwtest.ValueReaderWriter{BSONType: bsontype.Int64, Err: errors.New("ri64 error"), ErrAfter: bsonrwtest.ReadInt64},
-					bsonrwtest.ReadInt64,
-					errors.New("ri64 error"),
-				},
-				{
-					"can set false",
-					cansettest,
-					nil,
-					&bsonrwtest.ValueReaderWriter{BSONType: bsontype.ObjectID, Return: primitive.ObjectID{}},
-					bsonrwtest.Nothing,
-					ValueDecoderError{Name: "JSONNumberDecodeValue", Types: []reflect.Type{tJSONNumber}},
-				},
-				{
-					"success/double",
-					json.Number("3.14159"),
-					nil,
-					&bsonrwtest.ValueReaderWriter{BSONType: bsontype.Double, Return: float64(3.14159)},
-					bsonrwtest.ReadDouble,
-					nil,
-				},
-				{
-					"success/int32",
-					json.Number("12345"),
-					nil,
-					&bsonrwtest.ValueReaderWriter{BSONType: bsontype.Int32, Return: int32(12345)},
-					bsonrwtest.ReadInt32,
-					nil,
-				},
-				{
-					"success/int64",
-					json.Number("1234567890"),
-					nil,
-					&bsonrwtest.ValueReaderWriter{BSONType: bsontype.Int64, Return: int64(1234567890)},
-					bsonrwtest.ReadInt64,
-					nil,
-				},
-			},
-		},
-		{
-			"URLDecodeValue",
-			ValueDecoderFunc(dvd.URLDecodeValue),
-			[]subtest{
-				{
-					"wrong type",
-					wrong,
-					nil,
-					&bsonrwtest.ValueReaderWriter{BSONType: bsontype.Int32},
-					bsonrwtest.Nothing,
-					fmt.Errorf("cannot decode %v into a *url.URL", bsontype.Int32),
-				},
-				{
-					"type not *url.URL",
-					int64(0),
-					nil,
-					&bsonrwtest.ValueReaderWriter{BSONType: bsontype.String, Return: string("http://example.com")},
-					bsonrwtest.ReadString,
-					ValueDecoderError{Name: "URLDecodeValue", Types: []reflect.Type{tURL}, Received: reflect.ValueOf(int64(0))},
-				},
-				{
-					"ReadString error",
-					url.URL{},
-					nil,
-					&bsonrwtest.ValueReaderWriter{BSONType: bsontype.String, Err: errors.New("rs error"), ErrAfter: bsonrwtest.ReadString},
-					bsonrwtest.ReadString,
-					errors.New("rs error"),
-				},
-				{
-					"url.Parse error",
-					url.URL{},
-					nil,
-					&bsonrwtest.ValueReaderWriter{BSONType: bsontype.String, Return: string("not-valid-%%%%://")},
-					bsonrwtest.ReadString,
-					errors.New("parse not-valid-%%%%://: first path segment in URL cannot contain colon"),
-				},
-				{
-					"can set false",
-					cansettest,
-					nil,
-					&bsonrwtest.ValueReaderWriter{BSONType: bsontype.String, Return: string("http://example.com")},
-					bsonrwtest.Nothing,
-					ValueDecoderError{Name: "URLDecodeValue", Types: []reflect.Type{tURL}},
-				},
-				{
-					"url.URL",
-					url.URL{Scheme: "http", Host: "example.com"},
-					nil,
-					&bsonrwtest.ValueReaderWriter{BSONType: bsontype.String, Return: string("http://example.com")},
-					bsonrwtest.ReadString,
-					nil,
-				},
-			},
-		},
-		{
-			"ByteSliceDecodeValue",
-			ValueDecoderFunc(dvd.ByteSliceDecodeValue),
-			[]subtest{
-				{
-					"wrong type",
-					wrong,
-					nil,
-					&bsonrwtest.ValueReaderWriter{BSONType: bsontype.Int32},
-					bsonrwtest.Nothing,
-					fmt.Errorf("cannot decode %v into a []byte", bsontype.Int32),
-				},
-				{
-					"type not []byte",
-					int64(0),
-					nil,
-					&bsonrwtest.ValueReaderWriter{BSONType: bsontype.Binary, Return: bsoncore.Value{Type: bsontype.Binary}},
-					bsonrwtest.Nothing,
-					ValueDecoderError{Name: "ByteSliceDecodeValue", Types: []reflect.Type{tByteSlice}, Received: reflect.ValueOf(int64(0))},
-				},
-				{
-					"ReadBinary error",
-					[]byte{},
-					nil,
-					&bsonrwtest.ValueReaderWriter{BSONType: bsontype.Binary, Err: errors.New("rb error"), ErrAfter: bsonrwtest.ReadBinary},
-					bsonrwtest.ReadBinary,
-					errors.New("rb error"),
-				},
-				{
-					"incorrect subtype",
-					[]byte{},
-					nil,
-					&bsonrwtest.ValueReaderWriter{
-						BSONType: bsontype.Binary,
-						Return: bsoncore.Value{
-							Type: bsontype.Binary,
-							Data: bsoncore.AppendBinary(nil, 0xFF, []byte{0x01, 0x02, 0x03}),
-						},
-					},
-					bsonrwtest.ReadBinary,
-					fmt.Errorf("ByteSliceDecodeValue can only be used to decode subtype 0x00 for %s, got %v", bsontype.Binary, byte(0xFF)),
-				},
-				{
-					"can set false",
-					cansettest,
-					nil,
-					&bsonrwtest.ValueReaderWriter{BSONType: bsontype.Binary, Return: bsoncore.AppendBinary(nil, 0x00, []byte{0x01, 0x02, 0x03})},
-					bsonrwtest.Nothing,
-					ValueDecoderError{Name: "ByteSliceDecodeValue", Types: []reflect.Type{tByteSlice}},
-				},
-			},
-		},
-		{
-			"ValueUnmarshalerDecodeValue",
-			ValueDecoderFunc(dvd.ValueUnmarshalerDecodeValue),
-			[]subtest{
-				{
-					"wrong type",
-					wrong,
-					nil,
-					nil,
-					bsonrwtest.Nothing,
-					ValueDecoderError{
-						Name:     "ValueUnmarshalerDecodeValue",
-						Types:    []reflect.Type{tValueUnmarshaler},
-						Received: reflect.ValueOf(wrong),
-					},
-				},
-				{
-					"copy error",
-					&testValueUnmarshaler{},
-					nil,
-					&bsonrwtest.ValueReaderWriter{BSONType: bsontype.String, Err: errors.New("copy error"), ErrAfter: bsonrwtest.ReadString},
-					bsonrwtest.ReadString,
-					errors.New("copy error"),
-				},
-				{
-					"ValueUnmarshaler",
-					&testValueUnmarshaler{t: bsontype.String, val: bsoncore.AppendString(nil, "hello, world")},
-					nil,
-					&bsonrwtest.ValueReaderWriter{BSONType: bsontype.String, Return: string("hello, world")},
-					bsonrwtest.ReadString,
-					nil,
-				},
-			},
-		},
-		{
-			"UnmarshalerDecodeValue",
-			ValueDecoderFunc(dvd.UnmarshalerDecodeValue),
-			[]subtest{
-				{
-					"wrong type",
-					wrong,
-					nil,
-					nil,
-					bsonrwtest.Nothing,
-					ValueDecoderError{Name: "UnmarshalerDecodeValue", Types: []reflect.Type{tUnmarshaler}, Received: reflect.ValueOf(wrong)},
-				},
-				{
-					"copy error",
-					&testUnmarshaler{},
-					nil,
-					&bsonrwtest.ValueReaderWriter{BSONType: bsontype.String, Err: errors.New("copy error"), ErrAfter: bsonrwtest.ReadString},
-					bsonrwtest.ReadString,
-					errors.New("copy error"),
-				},
-				{
-					"Unmarshaler",
-					testUnmarshaler{Val: bsoncore.AppendDouble(nil, 3.14159)},
-					nil,
-					&bsonrwtest.ValueReaderWriter{BSONType: bsontype.Double, Return: float64(3.14159)},
-					bsonrwtest.ReadDouble,
-					nil,
-				},
-			},
-		},
-		{
-			"PointerCodec.DecodeValue",
-			NewPointerCodec(),
-			[]subtest{
-				{
-					"not valid", nil, nil, nil, bsonrwtest.Nothing,
-					ValueDecoderError{Name: "PointerCodec.DecodeValue", Kinds: []reflect.Kind{reflect.Ptr}, Received: reflect.Value{}},
-				},
-				{
-					"can set", cansettest, nil, nil, bsonrwtest.Nothing,
-					ValueDecoderError{Name: "PointerCodec.DecodeValue", Kinds: []reflect.Kind{reflect.Ptr}},
-				},
-				{
-					"No Decoder", &wrong, &DecodeContext{Registry: buildDefaultRegistry()}, nil, bsonrwtest.Nothing,
-					ErrNoDecoder{Type: reflect.TypeOf(wrong)},
-				},
-			},
-		},
-		{
-			"BinaryDecodeValue",
-			ValueDecoderFunc(dvd.BinaryDecodeValue),
-			[]subtest{
-				{
-					"wrong type",
-					wrong,
-					nil,
-					&bsonrwtest.ValueReaderWriter{},
-					bsonrwtest.Nothing,
-					ValueDecoderError{Name: "BinaryDecodeValue", Types: []reflect.Type{tBinary}, Received: reflect.ValueOf(wrong)},
-				},
-				{
-					"type not binary",
-					primitive.Binary{},
-					nil,
-					&bsonrwtest.ValueReaderWriter{BSONType: bsontype.String},
-					bsonrwtest.Nothing,
-					fmt.Errorf("cannot decode %v into a Binary", bsontype.String),
-				},
-				{
-					"ReadBinary Error",
-					primitive.Binary{},
-					nil,
-					&bsonrwtest.ValueReaderWriter{BSONType: bsontype.Binary, Err: errors.New("rb error"), ErrAfter: bsonrwtest.ReadBinary},
-					bsonrwtest.ReadBinary,
-					errors.New("rb error"),
-				},
-				{
-					"Binary/success",
-					primitive.Binary{Data: []byte{0x01, 0x02, 0x03}, Subtype: 0xFF},
-					nil,
-					&bsonrwtest.ValueReaderWriter{
-						BSONType: bsontype.Binary,
-						Return: bsoncore.Value{
-							Type: bsontype.Binary,
-							Data: bsoncore.AppendBinary(nil, 0xFF, []byte{0x01, 0x02, 0x03}),
-						},
-					},
-					bsonrwtest.ReadBinary,
-					nil,
-				},
-			},
-		},
-		{
-			"UndefinedDecodeValue",
-			ValueDecoderFunc(dvd.UndefinedDecodeValue),
-			[]subtest{
-				{
-					"wrong type",
-					wrong,
-					nil,
-					&bsonrwtest.ValueReaderWriter{BSONType: bsontype.Undefined},
-					bsonrwtest.Nothing,
-					ValueDecoderError{Name: "UndefinedDecodeValue", Types: []reflect.Type{tUndefined}, Received: reflect.ValueOf(wrong)},
-				},
-				{
-					"type not undefined",
-					primitive.Undefined{},
-					nil,
-					&bsonrwtest.ValueReaderWriter{BSONType: bsontype.String},
-					bsonrwtest.Nothing,
-					fmt.Errorf("cannot decode %v into an Undefined", bsontype.String),
-				},
-				{
-					"ReadUndefined Error",
-					primitive.Undefined{},
-					nil,
-					&bsonrwtest.ValueReaderWriter{BSONType: bsontype.Undefined, Err: errors.New("ru error"), ErrAfter: bsonrwtest.ReadUndefined},
-					bsonrwtest.ReadUndefined,
-					errors.New("ru error"),
-				},
-				{
-					"ReadUndefined/success",
-					primitive.Undefined{},
-					nil,
-					&bsonrwtest.ValueReaderWriter{BSONType: bsontype.Undefined},
-					bsonrwtest.ReadUndefined,
-					nil,
-				},
-			},
-		},
-		{
-			"DateTimeDecodeValue",
-			ValueDecoderFunc(dvd.DateTimeDecodeValue),
-			[]subtest{
-				{
-					"wrong type",
-					wrong,
-					nil,
-					&bsonrwtest.ValueReaderWriter{BSONType: bsontype.DateTime},
-					bsonrwtest.Nothing,
-					ValueDecoderError{Name: "DateTimeDecodeValue", Types: []reflect.Type{tDateTime}, Received: reflect.ValueOf(wrong)},
-				},
-				{
-					"type not datetime",
-					primitive.DateTime(0),
-					nil,
-					&bsonrwtest.ValueReaderWriter{BSONType: bsontype.String},
-					bsonrwtest.Nothing,
-					fmt.Errorf("cannot decode %v into a DateTime", bsontype.String),
-				},
-				{
-					"ReadDateTime Error",
-					primitive.DateTime(0),
-					nil,
-					&bsonrwtest.ValueReaderWriter{BSONType: bsontype.DateTime, Err: errors.New("rdt error"), ErrAfter: bsonrwtest.ReadDateTime},
-					bsonrwtest.ReadDateTime,
-					errors.New("rdt error"),
-				},
-				{
-					"success",
-					primitive.DateTime(1234567890),
-					nil,
-					&bsonrwtest.ValueReaderWriter{BSONType: bsontype.DateTime, Return: int64(1234567890)},
-					bsonrwtest.ReadDateTime,
-					nil,
-				},
-			},
-		},
-		{
-			"NullDecodeValue",
-			ValueDecoderFunc(dvd.NullDecodeValue),
-			[]subtest{
-				{
-					"wrong type",
-					wrong,
-					nil,
-					&bsonrwtest.ValueReaderWriter{BSONType: bsontype.Null},
-					bsonrwtest.Nothing,
-					ValueDecoderError{Name: "NullDecodeValue", Types: []reflect.Type{tNull}, Received: reflect.ValueOf(wrong)},
-				},
-				{
-					"type not null",
-					primitive.Null{},
-					nil,
-					&bsonrwtest.ValueReaderWriter{BSONType: bsontype.String},
-					bsonrwtest.Nothing,
-					fmt.Errorf("cannot decode %v into a Null", bsontype.String),
-				},
-				{
-					"ReadNull Error",
-					primitive.Null{},
-					nil,
-					&bsonrwtest.ValueReaderWriter{BSONType: bsontype.Null, Err: errors.New("rn error"), ErrAfter: bsonrwtest.ReadNull},
-					bsonrwtest.ReadNull,
-					errors.New("rn error"),
-				},
-				{
-					"success",
-					primitive.Null{},
-					nil,
-					&bsonrwtest.ValueReaderWriter{BSONType: bsontype.Null},
-					bsonrwtest.ReadNull,
-					nil,
-				},
-			},
-		},
-		{
-			"RegexDecodeValue",
-			ValueDecoderFunc(dvd.RegexDecodeValue),
-			[]subtest{
-				{
-					"wrong type",
-					wrong,
-					nil,
-					&bsonrwtest.ValueReaderWriter{BSONType: bsontype.Regex},
-					bsonrwtest.Nothing,
-					ValueDecoderError{Name: "RegexDecodeValue", Types: []reflect.Type{tRegex}, Received: reflect.ValueOf(wrong)},
-				},
-				{
-					"type not regex",
-					primitive.Regex{},
-					nil,
-					&bsonrwtest.ValueReaderWriter{BSONType: bsontype.String},
-					bsonrwtest.Nothing,
-					fmt.Errorf("cannot decode %v into a Regex", bsontype.String),
-				},
-				{
-					"ReadRegex Error",
-					primitive.Regex{},
-					nil,
-					&bsonrwtest.ValueReaderWriter{BSONType: bsontype.Regex, Err: errors.New("rr error"), ErrAfter: bsonrwtest.ReadRegex},
-					bsonrwtest.ReadRegex,
-					errors.New("rr error"),
-				},
-				{
-					"success",
-					primitive.Regex{Pattern: "foo", Options: "bar"},
-					nil,
-					&bsonrwtest.ValueReaderWriter{
-						BSONType: bsontype.Regex,
-						Return: bsoncore.Value{
-							Type: bsontype.Regex,
-							Data: bsoncore.AppendRegex(nil, "foo", "bar"),
-						},
-					},
-					bsonrwtest.ReadRegex,
-					nil,
-				},
-			},
-		},
-		{
-			"DBPointerDecodeValue",
-			ValueDecoderFunc(dvd.DBPointerDecodeValue),
-			[]subtest{
-				{
-					"wrong type",
-					wrong,
-					nil,
-					&bsonrwtest.ValueReaderWriter{BSONType: bsontype.DBPointer},
-					bsonrwtest.Nothing,
-					ValueDecoderError{Name: "DBPointerDecodeValue", Types: []reflect.Type{tDBPointer}, Received: reflect.ValueOf(wrong)},
-				},
-				{
-					"type not dbpointer",
-					primitive.DBPointer{},
-					nil,
-					&bsonrwtest.ValueReaderWriter{BSONType: bsontype.String},
-					bsonrwtest.Nothing,
-					fmt.Errorf("cannot decode %v into a DBPointer", bsontype.String),
-				},
-				{
-					"ReadDBPointer Error",
-					primitive.DBPointer{},
-					nil,
-					&bsonrwtest.ValueReaderWriter{BSONType: bsontype.DBPointer, Err: errors.New("rdbp error"), ErrAfter: bsonrwtest.ReadDBPointer},
-					bsonrwtest.ReadDBPointer,
-					errors.New("rdbp error"),
-				},
-				{
-					"success",
-					primitive.DBPointer{
-						DB:      "foobar",
-						Pointer: primitive.ObjectID{0x01, 0x02, 0x03, 0x04, 0x05, 0x06, 0x07, 0x08, 0x09, 0x0A, 0x0B, 0x0C},
-					},
-					nil,
-					&bsonrwtest.ValueReaderWriter{
-						BSONType: bsontype.DBPointer,
-						Return: bsoncore.Value{
-							Type: bsontype.DBPointer,
-							Data: bsoncore.AppendDBPointer(
-								nil, "foobar", primitive.ObjectID{0x01, 0x02, 0x03, 0x04, 0x05, 0x06, 0x07, 0x08, 0x09, 0x0A, 0x0B, 0x0C},
-							),
-						},
-					},
-					bsonrwtest.ReadDBPointer,
-					nil,
-				},
-			},
-		},
-		{
-			"TimestampDecodeValue",
-			ValueDecoderFunc(dvd.TimestampDecodeValue),
-			[]subtest{
-				{
-					"wrong type",
-					wrong,
-					nil,
-					&bsonrwtest.ValueReaderWriter{BSONType: bsontype.Timestamp},
-					bsonrwtest.Nothing,
-					ValueDecoderError{Name: "TimestampDecodeValue", Types: []reflect.Type{tTimestamp}, Received: reflect.ValueOf(wrong)},
-				},
-				{
-					"type not timestamp",
-					primitive.Timestamp{},
-					nil,
-					&bsonrwtest.ValueReaderWriter{BSONType: bsontype.String},
-					bsonrwtest.Nothing,
-					fmt.Errorf("cannot decode %v into a Timestamp", bsontype.String),
-				},
-				{
-					"ReadTimestamp Error",
-					primitive.Timestamp{},
-					nil,
-					&bsonrwtest.ValueReaderWriter{BSONType: bsontype.Timestamp, Err: errors.New("rt error"), ErrAfter: bsonrwtest.ReadTimestamp},
-					bsonrwtest.ReadTimestamp,
-					errors.New("rt error"),
-				},
-				{
-					"success",
-					primitive.Timestamp{T: 12345, I: 67890},
-					nil,
-					&bsonrwtest.ValueReaderWriter{
-						BSONType: bsontype.Timestamp,
-						Return: bsoncore.Value{
-							Type: bsontype.Timestamp,
-							Data: bsoncore.AppendTimestamp(nil, 12345, 67890),
-						},
-					},
-					bsonrwtest.ReadTimestamp,
-					nil,
-				},
-			},
-		},
-		{
-			"MinKeyDecodeValue",
-			ValueDecoderFunc(dvd.MinKeyDecodeValue),
-			[]subtest{
-				{
-					"wrong type",
-					wrong,
-					nil,
-					&bsonrwtest.ValueReaderWriter{BSONType: bsontype.MinKey},
-					bsonrwtest.Nothing,
-					ValueDecoderError{Name: "MinKeyDecodeValue", Types: []reflect.Type{tMinKey}, Received: reflect.ValueOf(wrong)},
-				},
-				{
-					"type not null",
-					primitive.MinKey{},
-					nil,
-					&bsonrwtest.ValueReaderWriter{BSONType: bsontype.String},
-					bsonrwtest.Nothing,
-					fmt.Errorf("cannot decode %v into a MinKey", bsontype.String),
-				},
-				{
-					"ReadMinKey Error",
-					primitive.MinKey{},
-					nil,
-					&bsonrwtest.ValueReaderWriter{BSONType: bsontype.MinKey, Err: errors.New("rn error"), ErrAfter: bsonrwtest.ReadMinKey},
-					bsonrwtest.ReadMinKey,
-					errors.New("rn error"),
-				},
-				{
-					"success",
-					primitive.MinKey{},
-					nil,
-					&bsonrwtest.ValueReaderWriter{BSONType: bsontype.MinKey},
-					bsonrwtest.ReadMinKey,
-					nil,
-				},
-			},
-		},
-		{
-			"MaxKeyDecodeValue",
-			ValueDecoderFunc(dvd.MaxKeyDecodeValue),
-			[]subtest{
-				{
-					"wrong type",
-					wrong,
-					nil,
-					&bsonrwtest.ValueReaderWriter{BSONType: bsontype.MaxKey},
-					bsonrwtest.Nothing,
-					ValueDecoderError{Name: "MaxKeyDecodeValue", Types: []reflect.Type{tMaxKey}, Received: reflect.ValueOf(wrong)},
-				},
-				{
-					"type not null",
-					primitive.MaxKey{},
-					nil,
-					&bsonrwtest.ValueReaderWriter{BSONType: bsontype.String},
-					bsonrwtest.Nothing,
-					fmt.Errorf("cannot decode %v into a MaxKey", bsontype.String),
-				},
-				{
-					"ReadMaxKey Error",
-					primitive.MaxKey{},
-					nil,
-					&bsonrwtest.ValueReaderWriter{BSONType: bsontype.MaxKey, Err: errors.New("rn error"), ErrAfter: bsonrwtest.ReadMaxKey},
-					bsonrwtest.ReadMaxKey,
-					errors.New("rn error"),
-				},
-				{
-					"success",
-					primitive.MaxKey{},
-					nil,
-					&bsonrwtest.ValueReaderWriter{BSONType: bsontype.MaxKey},
-					bsonrwtest.ReadMaxKey,
-					nil,
-				},
-			},
-		},
-		{
-			"JavaScriptDecodeValue",
-			ValueDecoderFunc(dvd.JavaScriptDecodeValue),
-			[]subtest{
-				{
-					"wrong type",
-					wrong,
-					nil,
-					&bsonrwtest.ValueReaderWriter{BSONType: bsontype.JavaScript, Return: ""},
-					bsonrwtest.Nothing,
-					ValueDecoderError{Name: "BinaryDecodeValue", Types: []reflect.Type{tJavaScript}, Received: reflect.ValueOf(wrong)},
-				},
-				{
-					"type not Javascript",
-					primitive.JavaScript(""),
-					nil,
-					&bsonrwtest.ValueReaderWriter{BSONType: bsontype.String},
-					bsonrwtest.Nothing,
-					fmt.Errorf("cannot decode %v into a primitive.JavaScript", bsontype.String),
-				},
-				{
-					"ReadJavascript Error",
-					primitive.JavaScript(""),
-					nil,
-					&bsonrwtest.ValueReaderWriter{BSONType: bsontype.JavaScript, Err: errors.New("rjs error"), ErrAfter: bsonrwtest.ReadJavascript},
-					bsonrwtest.ReadJavascript,
-					errors.New("rjs error"),
-				},
-				{
-					"JavaScript/success",
-					primitive.JavaScript("var hello = 'world';"),
-					nil,
-					&bsonrwtest.ValueReaderWriter{BSONType: bsontype.JavaScript, Return: "var hello = 'world';"},
-					bsonrwtest.ReadJavascript,
-					nil,
-				},
-			},
-		},
-		{
-			"SymbolDecodeValue",
-			ValueDecoderFunc(dvd.SymbolDecodeValue),
-			[]subtest{
-				{
-					"wrong type",
-					wrong,
-					nil,
-					&bsonrwtest.ValueReaderWriter{BSONType: bsontype.Symbol, Return: ""},
-					bsonrwtest.Nothing,
-					ValueDecoderError{Name: "BinaryDecodeValue", Types: []reflect.Type{tSymbol}, Received: reflect.ValueOf(wrong)},
-				},
-				{
-					"type not Symbol",
-					primitive.Symbol(""),
-					nil,
-					&bsonrwtest.ValueReaderWriter{BSONType: bsontype.String},
-					bsonrwtest.Nothing,
-					fmt.Errorf("cannot decode %v into a primitive.Symbol", bsontype.String),
-				},
-				{
-					"ReadSymbol Error",
-					primitive.Symbol(""),
-					nil,
-					&bsonrwtest.ValueReaderWriter{BSONType: bsontype.Symbol, Err: errors.New("rjs error"), ErrAfter: bsonrwtest.ReadSymbol},
-					bsonrwtest.ReadSymbol,
-					errors.New("rjs error"),
-				},
-				{
-					"Symbol/success",
-					primitive.Symbol("var hello = 'world';"),
-					nil,
-					&bsonrwtest.ValueReaderWriter{BSONType: bsontype.Symbol, Return: "var hello = 'world';"},
-					bsonrwtest.ReadSymbol,
-					nil,
-				},
-			},
-		},
-		{
-			"CoreDocumentDecodeValue",
-			ValueDecoderFunc(dvd.CoreDocumentDecodeValue),
-			[]subtest{
-				{
-					"wrong type",
-					wrong,
-					nil,
-					&bsonrwtest.ValueReaderWriter{},
-					bsonrwtest.Nothing,
-					ValueDecoderError{
-						Name:     "CoreDocumentDecodeValue",
-						Types:    []reflect.Type{tCoreDocument},
-						Received: reflect.ValueOf(wrong),
-					},
-				},
-				{
-					"*bsoncore.Document is nil",
-					(*bsoncore.Document)(nil),
-					nil,
-					nil,
-					bsonrwtest.Nothing,
-					ValueDecoderError{
-						Name:     "CoreDocumentDecodeValue",
-						Types:    []reflect.Type{tCoreDocument},
-						Received: reflect.ValueOf((*bsoncore.Document)(nil)),
-					},
-				},
-				{
-					"Copy error",
-					bsoncore.Document{},
-					nil,
-					&bsonrwtest.ValueReaderWriter{Err: errors.New("copy error"), ErrAfter: bsonrwtest.ReadDocument},
-					bsonrwtest.ReadDocument,
-					errors.New("copy error"),
-				},
-			},
-		},
-		{
-			"StructCodec.DecodeValue",
-			defaultStructCodec,
-			[]subtest{
-				{
-					"Not struct",
-					reflect.New(reflect.TypeOf(struct{ Foo string }{})).Elem().Interface(),
-					nil,
-					&bsonrwtest.ValueReaderWriter{BSONType: bsontype.String},
-					bsonrwtest.Nothing,
-					errors.New("cannot decode string into a struct { Foo string }"),
-				},
-			},
-		},
-		{
-			"CodeWithScopeDecodeValue",
-			ValueDecoderFunc(dvd.CodeWithScopeDecodeValue),
-			[]subtest{
-				{
-					"wrong type",
-					wrong,
-					nil,
-					&bsonrwtest.ValueReaderWriter{BSONType: bsontype.CodeWithScope},
-					bsonrwtest.Nothing,
-					ValueDecoderError{
-						Name:     "CodeWithScopeDecodeValue",
-						Types:    []reflect.Type{tCodeWithScope},
-						Received: reflect.ValueOf(wrong),
-					},
-				},
-				{
-					"type not codewithscope",
-					primitive.CodeWithScope{},
-					nil,
-					&bsonrwtest.ValueReaderWriter{BSONType: bsontype.String},
-					bsonrwtest.Nothing,
-					fmt.Errorf("cannot decode %v into a primitive.CodeWithScope", bsontype.String),
-				},
-				{
-					"ReadCodeWithScope Error",
-					primitive.CodeWithScope{},
-					nil,
-					&bsonrwtest.ValueReaderWriter{BSONType: bsontype.CodeWithScope, Err: errors.New("rcws error"), ErrAfter: bsonrwtest.ReadCodeWithScope},
-					bsonrwtest.ReadCodeWithScope,
-					errors.New("rcws error"),
-				},
-				{
-					"decodeDocument Error",
-					primitive.CodeWithScope{
-						Code:  "var hello = 'world';",
-						Scope: primitive.D{{"foo", nil}},
-					},
-					&DecodeContext{Registry: buildDefaultRegistry()},
-					&bsonrwtest.ValueReaderWriter{BSONType: bsontype.CodeWithScope, Err: errors.New("dd error"), ErrAfter: bsonrwtest.ReadElement},
-					bsonrwtest.ReadElement,
-					errors.New("dd error"),
-				},
-			},
-		},
-	}
-
-	for _, tc := range testCases {
-		t.Run(tc.name, func(t *testing.T) {
-			for _, rc := range tc.subtests {
-				t.Run(rc.name, func(t *testing.T) {
-					var dc DecodeContext
-					if rc.dctx != nil {
-						dc = *rc.dctx
-					}
-					llvrw := new(bsonrwtest.ValueReaderWriter)
-					if rc.llvrw != nil {
-						llvrw = rc.llvrw
-					}
-					llvrw.T = t
-					// var got interface{}
-					if rc.val == cansetreflectiontest { // We're doing a CanSet reflection test
-						err := tc.vd.DecodeValue(dc, llvrw, reflect.Value{})
-						if !compareErrors(err, rc.err) {
-							t.Errorf("Errors do not match. got %v; want %v", err, rc.err)
-						}
-
-						val := reflect.New(reflect.TypeOf(rc.val)).Elem()
-						err = tc.vd.DecodeValue(dc, llvrw, val)
-						if !compareErrors(err, rc.err) {
-							t.Errorf("Errors do not match. got %v; want %v", err, rc.err)
-						}
-						return
-					}
-					if rc.val == cansettest { // We're doing an IsValid and CanSet test
-						wanterr, ok := rc.err.(ValueDecoderError)
-						if !ok {
-							t.Fatalf("Error must be a DecodeValueError, but got a %T", rc.err)
-						}
-
-						err := tc.vd.DecodeValue(dc, llvrw, reflect.Value{})
-						wanterr.Received = reflect.ValueOf(nil)
-						if !compareErrors(err, wanterr) {
-							t.Errorf("Errors do not match. got %v; want %v", err, wanterr)
-						}
-
-						err = tc.vd.DecodeValue(dc, llvrw, reflect.ValueOf(int(12345)))
-						wanterr.Received = reflect.ValueOf(int(12345))
-						if !compareErrors(err, wanterr) {
-							t.Errorf("Errors do not match. got %v; want %v", err, wanterr)
-						}
-						return
-					}
-					var val reflect.Value
-					if rtype := reflect.TypeOf(rc.val); rtype != nil {
-						val = reflect.New(rtype).Elem()
-					}
-					want := rc.val
-					defer func() {
-						if err := recover(); err != nil {
-							fmt.Println(t.Name())
-							panic(err)
-						}
-					}()
-					err := tc.vd.DecodeValue(dc, llvrw, val)
-					if !compareErrors(err, rc.err) {
-						t.Errorf("Errors do not match. got %v; want %v", err, rc.err)
-					}
-					invoked := llvrw.Invoked
-					if !cmp.Equal(invoked, rc.invoke) {
-						t.Errorf("Incorrect method invoked. got %v; want %v", invoked, rc.invoke)
-					}
-					var got interface{}
-					if val.IsValid() && val.CanInterface() {
-						got = val.Interface()
-					}
-					if rc.err == nil && !cmp.Equal(got, want, cmp.Comparer(compareDecimal128)) {
-						t.Errorf("Values do not match. got (%T)%v; want (%T)%v", got, got, want, want)
-					}
-				})
-			}
-		})
-	}
-
-	t.Run("CodeWithScopeCodec/DecodeValue/success", func(t *testing.T) {
-		dc := DecodeContext{Registry: buildDefaultRegistry()}
-		b := bsoncore.BuildDocument(nil,
-			bsoncore.AppendCodeWithScopeElement(
-				nil, "foo", "var hello = 'world';",
-				buildDocument(bsoncore.AppendNullElement(nil, "bar")),
-			),
-		)
-		dvr := bsonrw.NewBSONDocumentReader(b)
-		dr, err := dvr.ReadDocument()
-		noerr(t, err)
-		_, vr, err := dr.ReadElement()
-		noerr(t, err)
-
-		want := primitive.CodeWithScope{
-			Code:  "var hello = 'world';",
-			Scope: primitive.D{{"bar", nil}},
-		}
-		val := reflect.New(tCodeWithScope).Elem()
-		err = dvd.CodeWithScopeDecodeValue(dc, vr, val)
-		noerr(t, err)
-
-		got := val.Interface().(primitive.CodeWithScope)
-		if got.Code != want.Code && !cmp.Equal(got.Scope, want.Scope) {
-			t.Errorf("CodeWithScopes do not match. got %v; want %v", got, want)
-		}
-	})
-	t.Run("ValueUnmarshalerDecodeValue/UnmarshalBSONValue error", func(t *testing.T) {
-		var dc DecodeContext
-		llvrw := &bsonrwtest.ValueReaderWriter{BSONType: bsontype.String, Return: string("hello, world!")}
-		llvrw.T = t
-
-		want := errors.New("ubsonv error")
-		valUnmarshaler := &testValueUnmarshaler{err: want}
-		got := dvd.ValueUnmarshalerDecodeValue(dc, llvrw, reflect.ValueOf(valUnmarshaler))
-		if !compareErrors(got, want) {
-			t.Errorf("Errors do not match. got %v; want %v", got, want)
-		}
-	})
-	t.Run("ValueUnmarshalerDecodeValue/Unaddressable value", func(t *testing.T) {
-		var dc DecodeContext
-		llvrw := &bsonrwtest.ValueReaderWriter{BSONType: bsontype.String, Return: string("hello, world!")}
-		llvrw.T = t
-
-		val := reflect.ValueOf(testValueUnmarshaler{})
-		want := ValueDecoderError{Name: "ValueUnmarshalerDecodeValue", Types: []reflect.Type{tValueUnmarshaler}, Received: val}
-		got := dvd.ValueUnmarshalerDecodeValue(dc, llvrw, val)
-		if !compareErrors(got, want) {
-			t.Errorf("Errors do not match. got %v; want %v", got, want)
-		}
-	})
-
-	t.Run("SliceCodec/DecodeValue/can't set slice", func(t *testing.T) {
-		var val []string
-		want := ValueDecoderError{Name: "SliceDecodeValue", Kinds: []reflect.Kind{reflect.Slice}, Received: reflect.ValueOf(val)}
-		got := dvd.SliceDecodeValue(DecodeContext{}, nil, reflect.ValueOf(val))
-		if !compareErrors(got, want) {
-			t.Errorf("Errors do not match. got %v; want %v", got, want)
-		}
-	})
-	t.Run("SliceCodec/DecodeValue/too many elements", func(t *testing.T) {
-		idx, doc := bsoncore.AppendDocumentStart(nil)
-		aidx, doc := bsoncore.AppendArrayElementStart(doc, "foo")
-		doc = bsoncore.AppendStringElement(doc, "0", "foo")
-		doc = bsoncore.AppendStringElement(doc, "1", "bar")
-		doc, err := bsoncore.AppendArrayEnd(doc, aidx)
-		noerr(t, err)
-		doc, err = bsoncore.AppendDocumentEnd(doc, idx)
-		noerr(t, err)
-		dvr := bsonrw.NewBSONDocumentReader(doc)
-		noerr(t, err)
-		dr, err := dvr.ReadDocument()
-		noerr(t, err)
-		_, vr, err := dr.ReadElement()
-		noerr(t, err)
-		var val [1]string
-		want := fmt.Errorf("more elements returned in array than can fit inside %T", val)
-
-		dc := DecodeContext{Registry: buildDefaultRegistry()}
-		got := dvd.ArrayDecodeValue(dc, vr, reflect.ValueOf(val))
-		if !compareErrors(got, want) {
-			t.Errorf("Errors do not match. got %v; want %v", got, want)
-		}
-	})
-
-	t.Run("success path", func(t *testing.T) {
-		oid := primitive.NewObjectID()
-		oids := []primitive.ObjectID{primitive.NewObjectID(), primitive.NewObjectID(), primitive.NewObjectID()}
-		var str = new(string)
-		*str = "bar"
-		now := time.Now().Truncate(time.Millisecond).UTC()
-		murl, err := url.Parse("https://mongodb.com/random-url?hello=world")
-		if err != nil {
-			t.Errorf("Error parsing URL: %v", err)
-			t.FailNow()
-		}
-		decimal128, err := primitive.ParseDecimal128("1.5e10")
-		if err != nil {
-			t.Errorf("Error parsing decimal128: %v", err)
-			t.FailNow()
-		}
-
-		testCases := []struct {
-			name  string
-			value interface{}
-			b     []byte
-			err   error
-		}{
-			{
-				"map[string]int",
-				map[string]int32{"foo": 1},
-				[]byte{
-					0x0E, 0x00, 0x00, 0x00,
-					0x10, 'f', 'o', 'o', 0x00,
-					0x01, 0x00, 0x00, 0x00,
-					0x00,
-				},
-				nil,
-			},
-			{
-				"map[string]primitive.ObjectID",
-				map[string]primitive.ObjectID{"foo": oid},
-				func() []byte {
-					idx, doc := bsoncore.AppendDocumentStart(nil)
-					doc = bsoncore.AppendObjectIDElement(doc, "foo", oid)
-					doc, _ = bsoncore.AppendDocumentEnd(doc, idx)
-					return doc
-				}(),
-				nil,
-			},
-			{
-				"map[string][]int32",
-				map[string][]int32{"Z": {1, 2, 3}},
-				buildDocumentArray(func(doc []byte) []byte {
-					doc = bsoncore.AppendInt32Element(doc, "0", 1)
-					doc = bsoncore.AppendInt32Element(doc, "1", 2)
-					return bsoncore.AppendInt32Element(doc, "2", 3)
-				}),
-				nil,
-			},
-			{
-				"map[string][]primitive.ObjectID",
-				map[string][]primitive.ObjectID{"Z": oids},
-				buildDocumentArray(func(doc []byte) []byte {
-					doc = bsoncore.AppendObjectIDElement(doc, "0", oids[0])
-					doc = bsoncore.AppendObjectIDElement(doc, "1", oids[1])
-					return bsoncore.AppendObjectIDElement(doc, "2", oids[2])
-				}),
-				nil,
-			},
-			{
-				"map[string][]json.Number(int64)",
-				map[string][]json.Number{"Z": {json.Number("5"), json.Number("10")}},
-				buildDocumentArray(func(doc []byte) []byte {
-					doc = bsoncore.AppendInt64Element(doc, "0", 5)
-					return bsoncore.AppendInt64Element(doc, "1", 10)
-				}),
-				nil,
-			},
-			{
-				"map[string][]json.Number(float64)",
-				map[string][]json.Number{"Z": {json.Number("5"), json.Number("10.1")}},
-				buildDocumentArray(func(doc []byte) []byte {
-					doc = bsoncore.AppendInt64Element(doc, "0", 5)
-					return bsoncore.AppendDoubleElement(doc, "1", 10.1)
-				}),
-				nil,
-			},
-			{
-				"map[string][]*url.URL",
-				map[string][]*url.URL{"Z": {murl}},
-				buildDocumentArray(func(doc []byte) []byte {
-					return bsoncore.AppendStringElement(doc, "0", murl.String())
-				}),
-				nil,
-			},
-			{
-				"map[string][]primitive.Decimal128",
-				map[string][]primitive.Decimal128{"Z": {decimal128}},
-				buildDocumentArray(func(doc []byte) []byte {
-					return bsoncore.AppendDecimal128Element(doc, "0", decimal128)
-				}),
-				nil,
-			},
-			{
-				"map[mystring]interface{}",
-				map[mystring]interface{}{"pi": 3.14159},
-				buildDocument(bsoncore.AppendDoubleElement(nil, "pi", 3.14159)),
-				nil,
-			},
-			{
-				"-",
-				struct {
-					A string `bson:"-"`
-				}{
-					A: "",
-				},
-				[]byte{0x05, 0x00, 0x00, 0x00, 0x00},
-				nil,
-			},
-			{
-				"omitempty",
-				struct {
-					A string `bson:",omitempty"`
-				}{
-					A: "",
-				},
-				[]byte{0x05, 0x00, 0x00, 0x00, 0x00},
-				nil,
-			},
-			{
-				"omitempty, empty time",
-				struct {
-					A time.Time `bson:",omitempty"`
-				}{
-					A: time.Time{},
-				},
-				[]byte{0x05, 0x00, 0x00, 0x00, 0x00},
-				nil,
-			},
-			{
-				"no private fields",
-				noPrivateFields{a: "should be empty"},
-				[]byte{0x05, 0x00, 0x00, 0x00, 0x00},
-				nil,
-			},
-			{
-				"minsize",
-				struct {
-					A int64 `bson:",minsize"`
-				}{
-					A: 12345,
-				},
-				buildDocument(bsoncore.AppendInt32Element(nil, "a", 12345)),
-				nil,
-			},
-			{
-				"inline",
-				struct {
-					Foo struct {
-						A int64 `bson:",minsize"`
-					} `bson:",inline"`
-				}{
-					Foo: struct {
-						A int64 `bson:",minsize"`
-					}{
-						A: 12345,
-					},
-				},
-				buildDocument(bsoncore.AppendInt32Element(nil, "a", 12345)),
-				nil,
-			},
-			{
-				"inline map",
-				struct {
-					Foo map[string]string `bson:",inline"`
-				}{
-					Foo: map[string]string{"foo": "bar"},
-				},
-				buildDocument(bsoncore.AppendStringElement(nil, "foo", "bar")),
-				nil,
-			},
-			{
-				"alternate name bson:name",
-				struct {
-					A string `bson:"foo"`
-				}{
-					A: "bar",
-				},
-				buildDocument(bsoncore.AppendStringElement(nil, "foo", "bar")),
-				nil,
-			},
-			{
-				"alternate name",
-				struct {
-					A string `bson:"foo"`
-				}{
-					A: "bar",
-				},
-				buildDocument(bsoncore.AppendStringElement(nil, "foo", "bar")),
-				nil,
-			},
-			{
-				"inline, omitempty",
-				struct {
-					A   string
-					Foo zeroTest `bson:"omitempty,inline"`
-				}{
-					A:   "bar",
-					Foo: zeroTest{true},
-				},
-				buildDocument(bsoncore.AppendStringElement(nil, "a", "bar")),
-				nil,
-			},
-			{
-				"struct{}",
-				struct {
-					A bool
-					B int32
-					C int64
-					D uint16
-					E uint64
-					F float64
-					G string
-					H map[string]string
-					I []byte
-					K [2]string
-					L struct {
-						M string
-					}
-					Q  primitive.ObjectID
-					T  []struct{}
-					Y  json.Number
-					Z  time.Time
-					AA json.Number
-					AB *url.URL
-					AC primitive.Decimal128
-					AD *time.Time
-					AE *testValueUnmarshaler
-					AF *bool
-					AG *bool
-					AH *int32
-					AI *int64
-					AJ *primitive.ObjectID
-					AK *primitive.ObjectID
-					AL testValueUnmarshaler
-					AM interface{}
-					AN interface{}
-					AO interface{}
-					AP primitive.D
-					AQ primitive.A
-					AR [2]primitive.E
-					AS []byte
-					AT map[string]interface{}
-					AU primitive.CodeWithScope
-					AV primitive.M
-					AW primitive.D
-					AX map[string]interface{}
-					AY []primitive.E
-					AZ interface{}
-				}{
-					A: true,
-					B: 123,
-					C: 456,
-					D: 789,
-					E: 101112,
-					F: 3.14159,
-					G: "Hello, world",
-					H: map[string]string{"foo": "bar"},
-					I: []byte{0x01, 0x02, 0x03},
-					K: [2]string{"baz", "qux"},
-					L: struct {
-						M string
-					}{
-						M: "foobar",
-					},
-					Q:  oid,
-					T:  nil,
-					Y:  json.Number("5"),
-					Z:  now,
-					AA: json.Number("10.1"),
-					AB: murl,
-					AC: decimal128,
-					AD: &now,
-					AE: &testValueUnmarshaler{t: bsontype.String, val: bsoncore.AppendString(nil, "hello, world!")},
-					AF: func(b bool) *bool { return &b }(true),
-					AG: nil,
-					AH: func(i32 int32) *int32 { return &i32 }(12345),
-					AI: func(i64 int64) *int64 { return &i64 }(1234567890),
-					AJ: &oid,
-					AK: nil,
-					AL: testValueUnmarshaler{t: bsontype.String, val: bsoncore.AppendString(nil, "hello, world!")},
-					AM: "hello, world",
-					AN: int32(12345),
-					AO: oid,
-					AP: primitive.D{{"foo", "bar"}},
-					AQ: primitive.A{"foo", "bar"},
-					AR: [2]primitive.E{{"hello", "world"}, {"pi", 3.14159}},
-					AS: nil,
-					AT: nil,
-					AU: primitive.CodeWithScope{Code: "var hello = 'world';", Scope: primitive.D{{"pi", 3.14159}}},
-					AV: primitive.M{"foo": primitive.M{"bar": "baz"}},
-					AW: primitive.D{{"foo", primitive.D{{"bar", "baz"}}}},
-					AX: map[string]interface{}{"foo": map[string]interface{}{"bar": "baz"}},
-					AY: []primitive.E{{"foo", []primitive.E{{"bar", "baz"}}}},
-					AZ: primitive.D{{"foo", primitive.D{{"bar", "baz"}}}},
-				},
-				buildDocument(func(doc []byte) []byte {
-					doc = bsoncore.AppendBooleanElement(doc, "a", true)
-					doc = bsoncore.AppendInt32Element(doc, "b", 123)
-					doc = bsoncore.AppendInt64Element(doc, "c", 456)
-					doc = bsoncore.AppendInt32Element(doc, "d", 789)
-					doc = bsoncore.AppendInt64Element(doc, "e", 101112)
-					doc = bsoncore.AppendDoubleElement(doc, "f", 3.14159)
-					doc = bsoncore.AppendStringElement(doc, "g", "Hello, world")
-					doc = bsoncore.AppendDocumentElement(doc, "h", buildDocument(bsoncore.AppendStringElement(nil, "foo", "bar")))
-					doc = bsoncore.AppendBinaryElement(doc, "i", 0x00, []byte{0x01, 0x02, 0x03})
-					doc = bsoncore.AppendArrayElement(doc, "k",
-						buildArray(bsoncore.AppendStringElement(bsoncore.AppendStringElement(nil, "0", "baz"), "1", "qux")),
-					)
-					doc = bsoncore.AppendDocumentElement(doc, "l", buildDocument(bsoncore.AppendStringElement(nil, "m", "foobar")))
-					doc = bsoncore.AppendObjectIDElement(doc, "q", oid)
-					doc = bsoncore.AppendNullElement(doc, "t")
-					doc = bsoncore.AppendInt64Element(doc, "y", 5)
-					doc = bsoncore.AppendDateTimeElement(doc, "z", now.UnixNano()/int64(time.Millisecond))
-					doc = bsoncore.AppendDoubleElement(doc, "aa", 10.1)
-					doc = bsoncore.AppendStringElement(doc, "ab", murl.String())
-					doc = bsoncore.AppendDecimal128Element(doc, "ac", decimal128)
-					doc = bsoncore.AppendDateTimeElement(doc, "ad", now.UnixNano()/int64(time.Millisecond))
-					doc = bsoncore.AppendStringElement(doc, "ae", "hello, world!")
-					doc = bsoncore.AppendBooleanElement(doc, "af", true)
-					doc = bsoncore.AppendNullElement(doc, "ag")
-					doc = bsoncore.AppendInt32Element(doc, "ah", 12345)
-					doc = bsoncore.AppendInt32Element(doc, "ai", 1234567890)
-					doc = bsoncore.AppendObjectIDElement(doc, "aj", oid)
-					doc = bsoncore.AppendNullElement(doc, "ak")
-					doc = bsoncore.AppendStringElement(doc, "al", "hello, world!")
-					doc = bsoncore.AppendStringElement(doc, "am", "hello, world")
-					doc = bsoncore.AppendInt32Element(doc, "an", 12345)
-					doc = bsoncore.AppendObjectIDElement(doc, "ao", oid)
-					doc = bsoncore.AppendDocumentElement(doc, "ap", buildDocument(bsoncore.AppendStringElement(nil, "foo", "bar")))
-					doc = bsoncore.AppendArrayElement(doc, "aq",
-						buildArray(bsoncore.AppendStringElement(bsoncore.AppendStringElement(nil, "0", "foo"), "1", "bar")),
-					)
-					doc = bsoncore.AppendDocumentElement(doc, "ar",
-						buildDocument(bsoncore.AppendDoubleElement(bsoncore.AppendStringElement(nil, "hello", "world"), "pi", 3.14159)),
-					)
-					doc = bsoncore.AppendNullElement(doc, "as")
-					doc = bsoncore.AppendNullElement(doc, "at")
-					doc = bsoncore.AppendCodeWithScopeElement(doc, "au",
-						"var hello = 'world';", buildDocument(bsoncore.AppendDoubleElement(nil, "pi", 3.14159)),
-					)
-					for _, name := range [5]string{"av", "aw", "ax", "ay", "az"} {
-						doc = bsoncore.AppendDocumentElement(doc, name, buildDocument(
-							bsoncore.AppendDocumentElement(nil, "foo", buildDocument(
-								bsoncore.AppendStringElement(nil, "bar", "baz"),
-							)),
-						))
-					}
-					return doc
-				}(nil)),
-				nil,
-			},
-			{
-				"struct{[]interface{}}",
-				struct {
-					A []bool
-					B []int32
-					C []int64
-					D []uint16
-					E []uint64
-					F []float64
-					G []string
-					H []map[string]string
-					I [][]byte
-					K [1][2]string
-					L []struct {
-						M string
-					}
-					N  [][]string
-					R  []primitive.ObjectID
-					T  []struct{}
-					W  []map[string]struct{}
-					X  []map[string]struct{}
-					Y  []map[string]struct{}
-					Z  []time.Time
-					AA []json.Number
-					AB []*url.URL
-					AC []primitive.Decimal128
-					AD []*time.Time
-					AE []*testValueUnmarshaler
-					AF []*bool
-					AG []*int32
-					AH []*int64
-					AI []*primitive.ObjectID
-					AJ []primitive.D
-					AK []primitive.A
-					AL [][2]primitive.E
-				}{
-					A: []bool{true},
-					B: []int32{123},
-					C: []int64{456},
-					D: []uint16{789},
-					E: []uint64{101112},
-					F: []float64{3.14159},
-					G: []string{"Hello, world"},
-					H: []map[string]string{{"foo": "bar"}},
-					I: [][]byte{{0x01, 0x02, 0x03}},
-					K: [1][2]string{{"baz", "qux"}},
-					L: []struct {
-						M string
-					}{
-						{
-							M: "foobar",
-						},
-					},
-					N:  [][]string{{"foo", "bar"}},
-					R:  oids,
-					T:  nil,
-					W:  nil,
-					X:  []map[string]struct{}{},   // Should be empty BSON Array
-					Y:  []map[string]struct{}{{}}, // Should be BSON array with one element, an empty BSON SubDocument
-					Z:  []time.Time{now, now},
-					AA: []json.Number{json.Number("5"), json.Number("10.1")},
-					AB: []*url.URL{murl},
-					AC: []primitive.Decimal128{decimal128},
-					AD: []*time.Time{&now, &now},
-					AE: []*testValueUnmarshaler{
-						{t: bsontype.String, val: bsoncore.AppendString(nil, "hello")},
-						{t: bsontype.String, val: bsoncore.AppendString(nil, "world")},
-					},
-					AF: []*bool{pbool(true), nil},
-					AG: []*int32{pi32(12345), nil},
-					AH: []*int64{pi64(1234567890), nil, pi64(9012345678)},
-					AI: []*primitive.ObjectID{&oid, nil},
-					AJ: []primitive.D{{{"foo", "bar"}}, nil},
-					AK: []primitive.A{{"foo", "bar"}, nil},
-					AL: [][2]primitive.E{{{"hello", "world"}, {"pi", 3.14159}}},
-				},
-				buildDocument(func(doc []byte) []byte {
-					doc = appendArrayElement(doc, "a", bsoncore.AppendBooleanElement(nil, "0", true))
-					doc = appendArrayElement(doc, "b", bsoncore.AppendInt32Element(nil, "0", 123))
-					doc = appendArrayElement(doc, "c", bsoncore.AppendInt64Element(nil, "0", 456))
-					doc = appendArrayElement(doc, "d", bsoncore.AppendInt32Element(nil, "0", 789))
-					doc = appendArrayElement(doc, "e", bsoncore.AppendInt64Element(nil, "0", 101112))
-					doc = appendArrayElement(doc, "f", bsoncore.AppendDoubleElement(nil, "0", 3.14159))
-					doc = appendArrayElement(doc, "g", bsoncore.AppendStringElement(nil, "0", "Hello, world"))
-					doc = appendArrayElement(doc, "h", buildDocumentElement("0", bsoncore.AppendStringElement(nil, "foo", "bar")))
-					doc = appendArrayElement(doc, "i", bsoncore.AppendBinaryElement(nil, "0", 0x00, []byte{0x01, 0x02, 0x03}))
-					doc = appendArrayElement(doc, "k",
-						buildArrayElement("0",
-							bsoncore.AppendStringElement(bsoncore.AppendStringElement(nil, "0", "baz"), "1", "qux")),
-					)
-					doc = appendArrayElement(doc, "l", buildDocumentElement("0", bsoncore.AppendStringElement(nil, "m", "foobar")))
-					doc = appendArrayElement(doc, "n",
-						buildArrayElement("0",
-							bsoncore.AppendStringElement(bsoncore.AppendStringElement(nil, "0", "foo"), "1", "bar")),
-					)
-					doc = appendArrayElement(doc, "r",
-						bsoncore.AppendObjectIDElement(
-							bsoncore.AppendObjectIDElement(
-								bsoncore.AppendObjectIDElement(nil,
-									"0", oids[0]),
-								"1", oids[1]),
-							"2", oids[2]),
-					)
-					doc = bsoncore.AppendNullElement(doc, "t")
-					doc = bsoncore.AppendNullElement(doc, "w")
-					doc = appendArrayElement(doc, "x", nil)
-					doc = appendArrayElement(doc, "y", buildDocumentElement("0", nil))
-					doc = appendArrayElement(doc, "z",
-						bsoncore.AppendDateTimeElement(
-							bsoncore.AppendDateTimeElement(
-								nil, "0", now.UnixNano()/int64(time.Millisecond)),
-							"1", now.UnixNano()/int64(time.Millisecond)),
-					)
-					doc = appendArrayElement(doc, "aa", bsoncore.AppendDoubleElement(bsoncore.AppendInt64Element(nil, "0", 5), "1", 10.10))
-					doc = appendArrayElement(doc, "ab", bsoncore.AppendStringElement(nil, "0", murl.String()))
-					doc = appendArrayElement(doc, "ac", bsoncore.AppendDecimal128Element(nil, "0", decimal128))
-					doc = appendArrayElement(doc, "ad",
-						bsoncore.AppendDateTimeElement(
-							bsoncore.AppendDateTimeElement(nil, "0", now.UnixNano()/int64(time.Millisecond)),
-							"1", now.UnixNano()/int64(time.Millisecond)),
-					)
-					doc = appendArrayElement(doc, "ae",
-						bsoncore.AppendStringElement(bsoncore.AppendStringElement(nil, "0", "hello"), "1", "world"),
-					)
-					doc = appendArrayElement(doc, "af",
-						bsoncore.AppendNullElement(bsoncore.AppendBooleanElement(nil, "0", true), "1"),
-					)
-					doc = appendArrayElement(doc, "ag",
-						bsoncore.AppendNullElement(bsoncore.AppendInt32Element(nil, "0", 12345), "1"),
-					)
-					doc = appendArrayElement(doc, "ah",
-						bsoncore.AppendInt64Element(
-							bsoncore.AppendNullElement(bsoncore.AppendInt64Element(nil, "0", 1234567890), "1"),
-							"2", 9012345678,
-						),
-					)
-					doc = appendArrayElement(doc, "ai",
-						bsoncore.AppendNullElement(bsoncore.AppendObjectIDElement(nil, "0", oid), "1"),
-					)
-					doc = appendArrayElement(doc, "aj",
-						bsoncore.AppendNullElement(
-							bsoncore.AppendDocumentElement(nil, "0", buildDocument(bsoncore.AppendStringElement(nil, "foo", "bar"))),
-							"1",
-						),
-					)
-					doc = appendArrayElement(doc, "ak",
-						bsoncore.AppendNullElement(
-							buildArrayElement("0",
-								bsoncore.AppendStringElement(bsoncore.AppendStringElement(nil, "0", "foo"), "1", "bar"),
-							),
-							"1",
-						),
-					)
-					doc = appendArrayElement(doc, "al",
-						buildDocumentElement(
-							"0",
-							bsoncore.AppendDoubleElement(bsoncore.AppendStringElement(nil, "hello", "world"), "pi", 3.14159),
-						),
-					)
-					return doc
-				}(nil)),
-				nil,
-			},
-		}
-
-		t.Run("Decode", func(t *testing.T) {
-			for _, tc := range testCases {
-				t.Run(tc.name, func(t *testing.T) {
-					vr := bsonrw.NewBSONDocumentReader(tc.b)
-					reg := buildDefaultRegistry()
-					vtype := reflect.TypeOf(tc.value)
-					dec, err := reg.LookupDecoder(vtype)
-					noerr(t, err)
-
-					gotVal := reflect.New(reflect.TypeOf(tc.value)).Elem()
-					err = dec.DecodeValue(DecodeContext{Registry: reg}, vr, gotVal)
-					noerr(t, err)
-
-					got := gotVal.Interface()
-					want := tc.value
-					if diff := cmp.Diff(
-						got, want,
-						cmp.Comparer(compareDecimal128),
-						cmp.Comparer(compareNoPrivateFields),
-						cmp.Comparer(compareZeroTest),
-						cmp.Comparer(compareTime),
-					); diff != "" {
-						t.Errorf("difference:\n%s", diff)
-						t.Errorf("Values are not equal.\ngot: %#v\nwant:%#v", got, want)
-					}
-				})
-			}
-		})
-	})
-
-	t.Run("EmptyInterfaceDecodeValue", func(t *testing.T) {
-		t.Run("DecodeValue", func(t *testing.T) {
-			testCases := []struct {
-				name     string
-				val      interface{}
-				bsontype bsontype.Type
-			}{
-				{
-					"Double - float64",
-					float64(3.14159),
-					bsontype.Double,
-				},
-				{
-					"String - string",
-					string("foo bar baz"),
-					bsontype.String,
-				},
-				{
-					"Array - primitive.A",
-					primitive.A{3.14159},
-					bsontype.Array,
-				},
-				{
-					"Binary - Binary",
-					primitive.Binary{Subtype: 0xFF, Data: []byte{0x01, 0x02, 0x03}},
-					bsontype.Binary,
-				},
-				{
-					"Undefined - Undefined",
-					primitive.Undefined{},
-					bsontype.Undefined,
-				},
-				{
-					"ObjectID - primitive.ObjectID",
-					primitive.ObjectID{0x01, 0x02, 0x03, 0x04, 0x05, 0x06, 0x07, 0x08, 0x09, 0x0A, 0x0B, 0x0C},
-					bsontype.ObjectID,
-				},
-				{
-					"Boolean - bool",
-					bool(true),
-					bsontype.Boolean,
-				},
-				{
-					"DateTime - DateTime",
-					primitive.DateTime(1234567890),
-					bsontype.DateTime,
-				},
-				{
-					"Null - Null",
-					nil,
-					bsontype.Null,
-				},
-				{
-					"Regex - Regex",
-					primitive.Regex{Pattern: "foo", Options: "bar"},
-					bsontype.Regex,
-				},
-				{
-					"DBPointer - DBPointer",
-					primitive.DBPointer{
-						DB:      "foobar",
-						Pointer: primitive.ObjectID{0x01, 0x02, 0x03, 0x04, 0x05, 0x06, 0x07, 0x08, 0x09, 0x0A, 0x0B, 0x0C},
-					},
-					bsontype.DBPointer,
-				},
-				{
-					"JavaScript - JavaScript",
-					primitive.JavaScript("var foo = 'bar';"),
-					bsontype.JavaScript,
-				},
-				{
-					"Symbol - Symbol",
-					primitive.Symbol("foobarbazlolz"),
-					bsontype.Symbol,
-				},
-				{
-					"Int32 - int32",
-					int32(123456),
-					bsontype.Int32,
-				},
-				{
-					"Int64 - int64",
-					int64(1234567890),
-					bsontype.Int64,
-				},
-				{
-					"Timestamp - Timestamp",
-					primitive.Timestamp{T: 12345, I: 67890},
-					bsontype.Timestamp,
-				},
-				{
-					"Decimal128 - decimal.Decimal128",
-					primitive.NewDecimal128(12345, 67890),
-					bsontype.Decimal128,
-				},
-				{
-					"MinKey - MinKey",
-					primitive.MinKey{},
-					bsontype.MinKey,
-				},
-				{
-					"MaxKey - MaxKey",
-					primitive.MaxKey{},
-					bsontype.MaxKey,
-				},
-			}
-			for _, tc := range testCases {
-				t.Run(tc.name, func(t *testing.T) {
-					llvr := &bsonrwtest.ValueReaderWriter{BSONType: tc.bsontype}
-
-					t.Run("Type Map failure", func(t *testing.T) {
-						if tc.bsontype == bsontype.Null {
-							t.Skip()
-						}
-						val := reflect.New(tEmpty).Elem()
-						dc := DecodeContext{Registry: NewRegistryBuilder().Build()}
-						want := ErrNoTypeMapEntry{Type: tc.bsontype}
-						got := dvd.EmptyInterfaceDecodeValue(dc, llvr, val)
-						if !compareErrors(got, want) {
-							t.Errorf("Errors are not equal. got %v; want %v", got, want)
-						}
-					})
-
-					t.Run("Lookup failure", func(t *testing.T) {
-						if tc.bsontype == bsontype.Null {
-							t.Skip()
-						}
-						val := reflect.New(tEmpty).Elem()
-						dc := DecodeContext{
-							Registry: NewRegistryBuilder().
-								RegisterTypeMapEntry(tc.bsontype, reflect.TypeOf(tc.val)).
-								Build(),
-						}
-						want := ErrNoDecoder{Type: reflect.TypeOf(tc.val)}
-						got := dvd.EmptyInterfaceDecodeValue(dc, llvr, val)
-						if !compareErrors(got, want) {
-							t.Errorf("Errors are not equal. got %v; want %v", got, want)
-						}
-					})
-
-					t.Run("DecodeValue failure", func(t *testing.T) {
-						if tc.bsontype == bsontype.Null {
-							t.Skip()
-						}
-						want := errors.New("DecodeValue failure error")
-						llc := &llCodec{t: t, err: want}
-						dc := DecodeContext{
-							Registry: NewRegistryBuilder().
-								RegisterDecoder(reflect.TypeOf(tc.val), llc).
-								RegisterTypeMapEntry(tc.bsontype, reflect.TypeOf(tc.val)).
-								Build(),
-						}
-						got := dvd.EmptyInterfaceDecodeValue(dc, llvr, reflect.New(tEmpty).Elem())
-						if !compareErrors(got, want) {
-							t.Errorf("Errors are not equal. got %v; want %v", got, want)
-						}
-					})
-
-					t.Run("Success", func(t *testing.T) {
-						want := tc.val
-						llc := &llCodec{t: t, decodeval: tc.val}
-						dc := DecodeContext{
-							Registry: NewRegistryBuilder().
-								RegisterDecoder(reflect.TypeOf(tc.val), llc).
-								RegisterTypeMapEntry(tc.bsontype, reflect.TypeOf(tc.val)).
-								Build(),
-						}
-						got := reflect.New(tEmpty).Elem()
-						err := dvd.EmptyInterfaceDecodeValue(dc, llvr, got)
-						noerr(t, err)
-						if !cmp.Equal(got.Interface(), want, cmp.Comparer(compareDecimal128)) {
-							t.Errorf("Did not receive expected value. got %v; want %v", got.Interface(), want)
-						}
-					})
-				})
-			}
-		})
-
-		t.Run("non-interface{}", func(t *testing.T) {
-			val := uint64(1234567890)
-			want := ValueDecoderError{Name: "EmptyInterfaceDecodeValue", Types: []reflect.Type{tEmpty}, Received: reflect.ValueOf(val)}
-			got := dvd.EmptyInterfaceDecodeValue(DecodeContext{}, nil, reflect.ValueOf(val))
-			if !compareErrors(got, want) {
-				t.Errorf("Errors are not equal. got %v; want %v", got, want)
-			}
-		})
-
-		t.Run("nil *interface{}", func(t *testing.T) {
-			var val interface{}
-			want := ValueDecoderError{Name: "EmptyInterfaceDecodeValue", Types: []reflect.Type{tEmpty}, Received: reflect.ValueOf(val)}
-			got := dvd.EmptyInterfaceDecodeValue(DecodeContext{}, nil, reflect.ValueOf(val))
-			if !compareErrors(got, want) {
-				t.Errorf("Errors are not equal. got %v; want %v", got, want)
-			}
-		})
-
-		t.Run("no type registered", func(t *testing.T) {
-			llvr := &bsonrwtest.ValueReaderWriter{BSONType: bsontype.Double}
-			want := ErrNoTypeMapEntry{Type: bsontype.Double}
-			val := reflect.New(tEmpty).Elem()
-			got := dvd.EmptyInterfaceDecodeValue(DecodeContext{Registry: NewRegistryBuilder().Build()}, llvr, val)
-			if !compareErrors(got, want) {
-				t.Errorf("Errors are not equal. got %v; want %v", got, want)
-			}
-		})
-		t.Run("top level document", func(t *testing.T) {
-			data := bsoncore.BuildDocument(nil, bsoncore.AppendDoubleElement(nil, "pi", 3.14159))
-			vr := bsonrw.NewBSONDocumentReader(data)
-			want := primitive.D{{"pi", 3.14159}}
-			var got interface{}
-			val := reflect.ValueOf(&got).Elem()
-			err := dvd.EmptyInterfaceDecodeValue(DecodeContext{Registry: buildDefaultRegistry()}, vr, val)
-			noerr(t, err)
-			if !cmp.Equal(got, want) {
-				t.Errorf("Did not get correct result. got %v; want %v", got, want)
-			}
-		})
-	})
-}
-
-type testValueUnmarshaler struct {
-	t   bsontype.Type
-	val []byte
-	err error
-}
-
-func (tvu *testValueUnmarshaler) UnmarshalBSONValue(t bsontype.Type, val []byte) error {
-	tvu.t, tvu.val = t, val
-	return tvu.err
-}
-
-type testUnmarshaler struct {
-	Val []byte
-	Err error
-}
-
-func (tvu *testUnmarshaler) UnmarshalBSON(val []byte) error {
-	tvu.Val = val
-	return tvu.Err
-}
-
-func (tvu testValueUnmarshaler) Equal(tvu2 testValueUnmarshaler) bool {
-	return tvu.t == tvu2.t && bytes.Equal(tvu.val, tvu2.val)
-}
-
-// buildDocumentArray inserts vals inside of an array inside of a document.
-func buildDocumentArray(fn func([]byte) []byte) []byte {
-	aix, doc := bsoncore.AppendArrayElementStart(nil, "Z")
-	doc = fn(doc)
-	doc, _ = bsoncore.AppendArrayEnd(doc, aix)
-	return buildDocument(doc)
-}
-
-func buildArray(vals []byte) []byte {
-	aix, doc := bsoncore.AppendArrayStart(nil)
-	doc = append(doc, vals...)
-	doc, _ = bsoncore.AppendArrayEnd(doc, aix)
-	return doc
-}
-
-func buildArrayElement(key string, vals []byte) []byte {
-	return appendArrayElement(nil, key, vals)
-}
-
-func appendArrayElement(dst []byte, key string, vals []byte) []byte {
-	aix, doc := bsoncore.AppendArrayElementStart(dst, key)
-	doc = append(doc, vals...)
-	doc, _ = bsoncore.AppendArrayEnd(doc, aix)
-	return doc
-}
-
-// buildDocument inserts elems inside of a document.
-func buildDocument(elems []byte) []byte {
-	idx, doc := bsoncore.AppendDocumentStart(nil)
-	doc = append(doc, elems...)
-	doc, _ = bsoncore.AppendDocumentEnd(doc, idx)
-	return doc
-}
-
-func buildDocumentElement(key string, elems []byte) []byte {
-	idx, doc := bsoncore.AppendDocumentElementStart(nil, key)
-	doc = append(doc, elems...)
-	doc, _ = bsoncore.AppendDocumentEnd(doc, idx)
-	return doc
-}

+ 0 - 648
qyxy/src/mgoutil/go.mongodb.org/mongo-driver/bson/bsoncodec/default_value_encoders.go

@@ -1,648 +0,0 @@
-// Copyright (C) MongoDB, Inc. 2017-present.
-//
-// Licensed under the Apache License, Version 2.0 (the "License"); you may
-// not use this file except in compliance with the License. You may obtain
-// a copy of the License at http://www.apache.org/licenses/LICENSE-2.0
-
-package bsoncodec
-
-import (
-	"encoding/json"
-	"errors"
-	"fmt"
-	"math"
-	"net/url"
-	"reflect"
-	"sync"
-	"time"
-
-	"go.mongodb.org/mongo-driver/bson/bsonrw"
-	"go.mongodb.org/mongo-driver/bson/bsontype"
-	"go.mongodb.org/mongo-driver/bson/primitive"
-	"go.mongodb.org/mongo-driver/x/bsonx/bsoncore"
-)
-
-var defaultValueEncoders DefaultValueEncoders
-
-var bvwPool = bsonrw.NewBSONValueWriterPool()
-
-var sliceWriterPool = sync.Pool{
-	New: func() interface{} {
-		sw := make(bsonrw.SliceWriter, 0, 0)
-		return &sw
-	},
-}
-
-func encodeElement(ec EncodeContext, dw bsonrw.DocumentWriter, e primitive.E) error {
-	vw, err := dw.WriteDocumentElement(e.Key)
-	if err != nil {
-		return err
-	}
-
-	if e.Value == nil {
-		return vw.WriteNull()
-	}
-	encoder, err := ec.LookupEncoder(reflect.TypeOf(e.Value))
-	if err != nil {
-		return err
-	}
-
-	err = encoder.EncodeValue(ec, vw, reflect.ValueOf(e.Value))
-	if err != nil {
-		return err
-	}
-	return nil
-}
-
-// DefaultValueEncoders is a namespace type for the default ValueEncoders used
-// when creating a registry.
-type DefaultValueEncoders struct{}
-
-// RegisterDefaultEncoders will register the encoder methods attached to DefaultValueEncoders with
-// the provided RegistryBuilder.
-func (dve DefaultValueEncoders) RegisterDefaultEncoders(rb *RegistryBuilder) {
-	if rb == nil {
-		panic(errors.New("argument to RegisterDefaultEncoders must not be nil"))
-	}
-	rb.
-		RegisterEncoder(tByteSlice, ValueEncoderFunc(dve.ByteSliceEncodeValue)).
-		RegisterEncoder(tTime, ValueEncoderFunc(dve.TimeEncodeValue)).
-		RegisterEncoder(tEmpty, ValueEncoderFunc(dve.EmptyInterfaceEncodeValue)).
-		RegisterEncoder(tOID, ValueEncoderFunc(dve.ObjectIDEncodeValue)).
-		RegisterEncoder(tDecimal, ValueEncoderFunc(dve.Decimal128EncodeValue)).
-		RegisterEncoder(tJSONNumber, ValueEncoderFunc(dve.JSONNumberEncodeValue)).
-		RegisterEncoder(tURL, ValueEncoderFunc(dve.URLEncodeValue)).
-		RegisterEncoder(tValueMarshaler, ValueEncoderFunc(dve.ValueMarshalerEncodeValue)).
-		RegisterEncoder(tMarshaler, ValueEncoderFunc(dve.MarshalerEncodeValue)).
-		RegisterEncoder(tProxy, ValueEncoderFunc(dve.ProxyEncodeValue)).
-		RegisterEncoder(tJavaScript, ValueEncoderFunc(dve.JavaScriptEncodeValue)).
-		RegisterEncoder(tSymbol, ValueEncoderFunc(dve.SymbolEncodeValue)).
-		RegisterEncoder(tBinary, ValueEncoderFunc(dve.BinaryEncodeValue)).
-		RegisterEncoder(tUndefined, ValueEncoderFunc(dve.UndefinedEncodeValue)).
-		RegisterEncoder(tDateTime, ValueEncoderFunc(dve.DateTimeEncodeValue)).
-		RegisterEncoder(tNull, ValueEncoderFunc(dve.NullEncodeValue)).
-		RegisterEncoder(tRegex, ValueEncoderFunc(dve.RegexEncodeValue)).
-		RegisterEncoder(tDBPointer, ValueEncoderFunc(dve.DBPointerEncodeValue)).
-		RegisterEncoder(tTimestamp, ValueEncoderFunc(dve.TimestampEncodeValue)).
-		RegisterEncoder(tMinKey, ValueEncoderFunc(dve.MinKeyEncodeValue)).
-		RegisterEncoder(tMaxKey, ValueEncoderFunc(dve.MaxKeyEncodeValue)).
-		RegisterEncoder(tCoreDocument, ValueEncoderFunc(dve.CoreDocumentEncodeValue)).
-		RegisterEncoder(tCodeWithScope, ValueEncoderFunc(dve.CodeWithScopeEncodeValue)).
-		RegisterDefaultEncoder(reflect.Bool, ValueEncoderFunc(dve.BooleanEncodeValue)).
-		RegisterDefaultEncoder(reflect.Int, ValueEncoderFunc(dve.IntEncodeValue)).
-		RegisterDefaultEncoder(reflect.Int8, ValueEncoderFunc(dve.IntEncodeValue)).
-		RegisterDefaultEncoder(reflect.Int16, ValueEncoderFunc(dve.IntEncodeValue)).
-		RegisterDefaultEncoder(reflect.Int32, ValueEncoderFunc(dve.IntEncodeValue)).
-		RegisterDefaultEncoder(reflect.Int64, ValueEncoderFunc(dve.IntEncodeValue)).
-		RegisterDefaultEncoder(reflect.Uint, ValueEncoderFunc(dve.UintEncodeValue)).
-		RegisterDefaultEncoder(reflect.Uint8, ValueEncoderFunc(dve.UintEncodeValue)).
-		RegisterDefaultEncoder(reflect.Uint16, ValueEncoderFunc(dve.UintEncodeValue)).
-		RegisterDefaultEncoder(reflect.Uint32, ValueEncoderFunc(dve.UintEncodeValue)).
-		RegisterDefaultEncoder(reflect.Uint64, ValueEncoderFunc(dve.UintEncodeValue)).
-		RegisterDefaultEncoder(reflect.Float32, ValueEncoderFunc(dve.FloatEncodeValue)).
-		RegisterDefaultEncoder(reflect.Float64, ValueEncoderFunc(dve.FloatEncodeValue)).
-		RegisterDefaultEncoder(reflect.Array, ValueEncoderFunc(dve.ArrayEncodeValue)).
-		RegisterDefaultEncoder(reflect.Map, ValueEncoderFunc(dve.MapEncodeValue)).
-		RegisterDefaultEncoder(reflect.Slice, ValueEncoderFunc(dve.SliceEncodeValue)).
-		RegisterDefaultEncoder(reflect.String, ValueEncoderFunc(dve.StringEncodeValue)).
-		RegisterDefaultEncoder(reflect.Struct, &StructCodec{cache: make(map[reflect.Type]*structDescription), parser: DefaultStructTagParser}).
-		RegisterDefaultEncoder(reflect.Ptr, NewPointerCodec())
-}
-
-// BooleanEncodeValue is the ValueEncoderFunc for bool types.
-func (dve DefaultValueEncoders) BooleanEncodeValue(ectx EncodeContext, vw bsonrw.ValueWriter, val reflect.Value) error {
-	if !val.IsValid() || val.Kind() != reflect.Bool {
-		return ValueEncoderError{Name: "BooleanEncodeValue", Kinds: []reflect.Kind{reflect.Bool}, Received: val}
-	}
-	return vw.WriteBoolean(val.Bool())
-}
-
-func fitsIn32Bits(i int64) bool {
-	return math.MinInt32 <= i && i <= math.MaxInt32
-}
-
-// IntEncodeValue is the ValueEncoderFunc for int types.
-func (dve DefaultValueEncoders) IntEncodeValue(ec EncodeContext, vw bsonrw.ValueWriter, val reflect.Value) error {
-	switch val.Kind() {
-	case reflect.Int8, reflect.Int16, reflect.Int32:
-		return vw.WriteInt32(int32(val.Int()))
-	case reflect.Int:
-		i64 := val.Int()
-		if fitsIn32Bits(i64) {
-			return vw.WriteInt32(int32(i64))
-		}
-		return vw.WriteInt64(i64)
-	case reflect.Int64:
-		i64 := val.Int()
-		if ec.MinSize && fitsIn32Bits(i64) {
-			return vw.WriteInt32(int32(i64))
-		}
-		return vw.WriteInt64(i64)
-	}
-
-	return ValueEncoderError{
-		Name:     "IntEncodeValue",
-		Kinds:    []reflect.Kind{reflect.Int8, reflect.Int16, reflect.Int32, reflect.Int64, reflect.Int},
-		Received: val,
-	}
-}
-
-// UintEncodeValue is the ValueEncoderFunc for uint types.
-func (dve DefaultValueEncoders) UintEncodeValue(ec EncodeContext, vw bsonrw.ValueWriter, val reflect.Value) error {
-	switch val.Kind() {
-	case reflect.Uint8, reflect.Uint16:
-		return vw.WriteInt32(int32(val.Uint()))
-	case reflect.Uint, reflect.Uint32, reflect.Uint64:
-		u64 := val.Uint()
-		if ec.MinSize && u64 <= math.MaxInt32 {
-			return vw.WriteInt32(int32(u64))
-		}
-		if u64 > math.MaxInt64 {
-			return fmt.Errorf("%d overflows int64", u64)
-		}
-		return vw.WriteInt64(int64(u64))
-	}
-
-	return ValueEncoderError{
-		Name:     "UintEncodeValue",
-		Kinds:    []reflect.Kind{reflect.Uint8, reflect.Uint16, reflect.Uint32, reflect.Uint64, reflect.Uint},
-		Received: val,
-	}
-}
-
-// FloatEncodeValue is the ValueEncoderFunc for float types.
-func (dve DefaultValueEncoders) FloatEncodeValue(ec EncodeContext, vw bsonrw.ValueWriter, val reflect.Value) error {
-	switch val.Kind() {
-	case reflect.Float32, reflect.Float64:
-		return vw.WriteDouble(val.Float())
-	}
-
-	return ValueEncoderError{Name: "FloatEncodeValue", Kinds: []reflect.Kind{reflect.Float32, reflect.Float64}, Received: val}
-}
-
-// StringEncodeValue is the ValueEncoderFunc for string types.
-func (dve DefaultValueEncoders) StringEncodeValue(ectx EncodeContext, vw bsonrw.ValueWriter, val reflect.Value) error {
-	if val.Kind() != reflect.String {
-		return ValueEncoderError{
-			Name:     "StringEncodeValue",
-			Kinds:    []reflect.Kind{reflect.String},
-			Received: val,
-		}
-	}
-
-	return vw.WriteString(val.String())
-}
-
-// ObjectIDEncodeValue is the ValueEncoderFunc for primitive.ObjectID.
-func (dve DefaultValueEncoders) ObjectIDEncodeValue(ec EncodeContext, vw bsonrw.ValueWriter, val reflect.Value) error {
-	if !val.IsValid() || val.Type() != tOID {
-		return ValueEncoderError{Name: "ObjectIDEncodeValue", Types: []reflect.Type{tOID}, Received: val}
-	}
-	return vw.WriteObjectID(val.Interface().(primitive.ObjectID))
-}
-
-// Decimal128EncodeValue is the ValueEncoderFunc for primitive.Decimal128.
-func (dve DefaultValueEncoders) Decimal128EncodeValue(ec EncodeContext, vw bsonrw.ValueWriter, val reflect.Value) error {
-	if !val.IsValid() || val.Type() != tDecimal {
-		return ValueEncoderError{Name: "Decimal128EncodeValue", Types: []reflect.Type{tDecimal}, Received: val}
-	}
-	return vw.WriteDecimal128(val.Interface().(primitive.Decimal128))
-}
-
-// JSONNumberEncodeValue is the ValueEncoderFunc for json.Number.
-func (dve DefaultValueEncoders) JSONNumberEncodeValue(ec EncodeContext, vw bsonrw.ValueWriter, val reflect.Value) error {
-	if !val.IsValid() || val.Type() != tJSONNumber {
-		return ValueEncoderError{Name: "JSONNumberEncodeValue", Types: []reflect.Type{tJSONNumber}, Received: val}
-	}
-	jsnum := val.Interface().(json.Number)
-
-	// Attempt int first, then float64
-	if i64, err := jsnum.Int64(); err == nil {
-		return dve.IntEncodeValue(ec, vw, reflect.ValueOf(i64))
-	}
-
-	f64, err := jsnum.Float64()
-	if err != nil {
-		return err
-	}
-
-	return dve.FloatEncodeValue(ec, vw, reflect.ValueOf(f64))
-}
-
-// URLEncodeValue is the ValueEncoderFunc for url.URL.
-func (dve DefaultValueEncoders) URLEncodeValue(ec EncodeContext, vw bsonrw.ValueWriter, val reflect.Value) error {
-	if !val.IsValid() || val.Type() != tURL {
-		return ValueEncoderError{Name: "URLEncodeValue", Types: []reflect.Type{tURL}, Received: val}
-	}
-	u := val.Interface().(url.URL)
-	return vw.WriteString(u.String())
-}
-
-// TimeEncodeValue is the ValueEncoderFunc for time.TIme.
-func (dve DefaultValueEncoders) TimeEncodeValue(ec EncodeContext, vw bsonrw.ValueWriter, val reflect.Value) error {
-	if !val.IsValid() || val.Type() != tTime {
-		return ValueEncoderError{Name: "TimeEncodeValue", Types: []reflect.Type{tTime}, Received: val}
-	}
-	tt := val.Interface().(time.Time)
-	return vw.WriteDateTime(tt.Unix()*1000 + int64(tt.Nanosecond()/1e6))
-}
-
-// ByteSliceEncodeValue is the ValueEncoderFunc for []byte.
-func (dve DefaultValueEncoders) ByteSliceEncodeValue(ec EncodeContext, vw bsonrw.ValueWriter, val reflect.Value) error {
-	if !val.IsValid() || val.Type() != tByteSlice {
-		return ValueEncoderError{Name: "ByteSliceEncodeValue", Types: []reflect.Type{tByteSlice}, Received: val}
-	}
-	if val.IsNil() {
-		return vw.WriteNull()
-	}
-	return vw.WriteBinary(val.Interface().([]byte))
-}
-
-// MapEncodeValue is the ValueEncoderFunc for map[string]* types.
-func (dve DefaultValueEncoders) MapEncodeValue(ec EncodeContext, vw bsonrw.ValueWriter, val reflect.Value) error {
-	if !val.IsValid() || val.Kind() != reflect.Map || val.Type().Key().Kind() != reflect.String {
-		return ValueEncoderError{Name: "MapEncodeValue", Kinds: []reflect.Kind{reflect.Map}, Received: val}
-	}
-
-	if val.IsNil() {
-		// If we have a nill map but we can't WriteNull, that means we're probably trying to encode
-		// to a TopLevel document. We can't currently tell if this is what actually happened, but if
-		// there's a deeper underlying problem, the error will also be returned from WriteDocument,
-		// so just continue. The operations on a map reflection value are valid, so we can call
-		// MapKeys within mapEncodeValue without a problem.
-		err := vw.WriteNull()
-		if err == nil {
-			return nil
-		}
-	}
-
-	dw, err := vw.WriteDocument()
-	if err != nil {
-		return err
-	}
-
-	return dve.mapEncodeValue(ec, dw, val, nil)
-}
-
-// mapEncodeValue handles encoding of the values of a map. The collisionFn returns
-// true if the provided key exists, this is mainly used for inline maps in the
-// struct codec.
-func (dve DefaultValueEncoders) mapEncodeValue(ec EncodeContext, dw bsonrw.DocumentWriter, val reflect.Value, collisionFn func(string) bool) error {
-
-	encoder, err := ec.LookupEncoder(val.Type().Elem())
-	if err != nil {
-		return err
-	}
-
-	keys := val.MapKeys()
-	for _, key := range keys {
-		if collisionFn != nil && collisionFn(key.String()) {
-			return fmt.Errorf("Key %s of inlined map conflicts with a struct field name", key)
-		}
-		vw, err := dw.WriteDocumentElement(key.String())
-		if err != nil {
-			return err
-		}
-
-		if enc, ok := encoder.(ValueEncoder); ok {
-			err = enc.EncodeValue(ec, vw, val.MapIndex(key))
-			if err != nil {
-				return err
-			}
-			continue
-		}
-		err = encoder.EncodeValue(ec, vw, val.MapIndex(key))
-		if err != nil {
-			return err
-		}
-	}
-
-	return dw.WriteDocumentEnd()
-}
-
-// ArrayEncodeValue is the ValueEncoderFunc for array types.
-func (dve DefaultValueEncoders) ArrayEncodeValue(ec EncodeContext, vw bsonrw.ValueWriter, val reflect.Value) error {
-	if !val.IsValid() || val.Kind() != reflect.Array {
-		return ValueEncoderError{Name: "ArrayEncodeValue", Kinds: []reflect.Kind{reflect.Array}, Received: val}
-	}
-
-	// If we have a []primitive.E we want to treat it as a document instead of as an array.
-	if val.Type().Elem() == tE {
-		dw, err := vw.WriteDocument()
-		if err != nil {
-			return err
-		}
-
-		for idx := 0; idx < val.Len(); idx++ {
-			e := val.Index(idx).Interface().(primitive.E)
-			err = encodeElement(ec, dw, e)
-			if err != nil {
-				return err
-			}
-		}
-
-		return dw.WriteDocumentEnd()
-	}
-
-	aw, err := vw.WriteArray()
-	if err != nil {
-		return err
-	}
-
-	encoder, err := ec.LookupEncoder(val.Type().Elem())
-	if err != nil {
-		return err
-	}
-
-	for idx := 0; idx < val.Len(); idx++ {
-		vw, err := aw.WriteArrayElement()
-		if err != nil {
-			return err
-		}
-
-		err = encoder.EncodeValue(ec, vw, val.Index(idx))
-		if err != nil {
-			return err
-		}
-	}
-	return aw.WriteArrayEnd()
-}
-
-// SliceEncodeValue is the ValueEncoderFunc for slice types.
-func (dve DefaultValueEncoders) SliceEncodeValue(ec EncodeContext, vw bsonrw.ValueWriter, val reflect.Value) error {
-	if !val.IsValid() || val.Kind() != reflect.Slice {
-		return ValueEncoderError{Name: "SliceEncodeValue", Kinds: []reflect.Kind{reflect.Slice}, Received: val}
-	}
-
-	if val.IsNil() {
-		return vw.WriteNull()
-	}
-
-	// If we have a []primitive.E we want to treat it as a document instead of as an array.
-	if val.Type().ConvertibleTo(tD) {
-		d := val.Convert(tD).Interface().(primitive.D)
-
-		dw, err := vw.WriteDocument()
-		if err != nil {
-			return err
-		}
-
-		for _, e := range d {
-			err = encodeElement(ec, dw, e)
-			if err != nil {
-				return err
-			}
-		}
-
-		return dw.WriteDocumentEnd()
-	}
-
-	aw, err := vw.WriteArray()
-	if err != nil {
-		return err
-	}
-
-	encoder, err := ec.LookupEncoder(val.Type().Elem())
-	if err != nil {
-		return err
-	}
-
-	for idx := 0; idx < val.Len(); idx++ {
-		vw, err := aw.WriteArrayElement()
-		if err != nil {
-			return err
-		}
-
-		err = encoder.EncodeValue(ec, vw, val.Index(idx))
-		if err != nil {
-			return err
-		}
-	}
-	return aw.WriteArrayEnd()
-}
-
-// EmptyInterfaceEncodeValue is the ValueEncoderFunc for interface{}.
-func (dve DefaultValueEncoders) EmptyInterfaceEncodeValue(ec EncodeContext, vw bsonrw.ValueWriter, val reflect.Value) error {
-	if !val.IsValid() || val.Type() != tEmpty {
-		return ValueEncoderError{Name: "EmptyInterfaceEncodeValue", Types: []reflect.Type{tEmpty}, Received: val}
-	}
-
-	if val.IsNil() {
-		return vw.WriteNull()
-	}
-	encoder, err := ec.LookupEncoder(val.Elem().Type())
-	if err != nil {
-		return err
-	}
-
-	return encoder.EncodeValue(ec, vw, val.Elem())
-}
-
-// ValueMarshalerEncodeValue is the ValueEncoderFunc for ValueMarshaler implementations.
-func (dve DefaultValueEncoders) ValueMarshalerEncodeValue(ec EncodeContext, vw bsonrw.ValueWriter, val reflect.Value) error {
-	if !val.IsValid() || !val.Type().Implements(tValueMarshaler) {
-		return ValueEncoderError{Name: "ValueMarshalerEncodeValue", Types: []reflect.Type{tValueMarshaler}, Received: val}
-	}
-
-	fn := val.Convert(tValueMarshaler).MethodByName("MarshalBSONValue")
-	returns := fn.Call(nil)
-	if !returns[2].IsNil() {
-		return returns[2].Interface().(error)
-	}
-	t, data := returns[0].Interface().(bsontype.Type), returns[1].Interface().([]byte)
-	return bsonrw.Copier{}.CopyValueFromBytes(vw, t, data)
-}
-
-// MarshalerEncodeValue is the ValueEncoderFunc for Marshaler implementations.
-func (dve DefaultValueEncoders) MarshalerEncodeValue(ec EncodeContext, vw bsonrw.ValueWriter, val reflect.Value) error {
-	if !val.IsValid() || !val.Type().Implements(tMarshaler) {
-		return ValueEncoderError{Name: "MarshalerEncodeValue", Types: []reflect.Type{tMarshaler}, Received: val}
-	}
-
-	fn := val.Convert(tMarshaler).MethodByName("MarshalBSON")
-	returns := fn.Call(nil)
-	if !returns[1].IsNil() {
-		return returns[1].Interface().(error)
-	}
-	data := returns[0].Interface().([]byte)
-	return bsonrw.Copier{}.CopyValueFromBytes(vw, bsontype.EmbeddedDocument, data)
-}
-
-// ProxyEncodeValue is the ValueEncoderFunc for Proxy implementations.
-func (dve DefaultValueEncoders) ProxyEncodeValue(ec EncodeContext, vw bsonrw.ValueWriter, val reflect.Value) error {
-	if !val.IsValid() || !val.Type().Implements(tProxy) {
-		return ValueEncoderError{Name: "ProxyEncodeValue", Types: []reflect.Type{tProxy}, Received: val}
-	}
-
-	fn := val.Convert(tProxy).MethodByName("ProxyBSON")
-	returns := fn.Call(nil)
-	if !returns[1].IsNil() {
-		return returns[1].Interface().(error)
-	}
-	data := returns[0]
-	var encoder ValueEncoder
-	var err error
-	if data.Elem().IsValid() {
-		encoder, err = ec.LookupEncoder(data.Elem().Type())
-	} else {
-		encoder, err = ec.LookupEncoder(nil)
-	}
-	if err != nil {
-		return err
-	}
-	return encoder.EncodeValue(ec, vw, data.Elem())
-}
-
-// JavaScriptEncodeValue is the ValueEncoderFunc for the primitive.JavaScript type.
-func (DefaultValueEncoders) JavaScriptEncodeValue(ectx EncodeContext, vw bsonrw.ValueWriter, val reflect.Value) error {
-	if !val.IsValid() || val.Type() != tJavaScript {
-		return ValueEncoderError{Name: "JavaScriptEncodeValue", Types: []reflect.Type{tJavaScript}, Received: val}
-	}
-
-	return vw.WriteJavascript(val.String())
-}
-
-// SymbolEncodeValue is the ValueEncoderFunc for the primitive.Symbol type.
-func (DefaultValueEncoders) SymbolEncodeValue(ectx EncodeContext, vw bsonrw.ValueWriter, val reflect.Value) error {
-	if !val.IsValid() || val.Type() != tSymbol {
-		return ValueEncoderError{Name: "SymbolEncodeValue", Types: []reflect.Type{tSymbol}, Received: val}
-	}
-
-	return vw.WriteSymbol(val.String())
-}
-
-// BinaryEncodeValue is the ValueEncoderFunc for Binary.
-func (DefaultValueEncoders) BinaryEncodeValue(ec EncodeContext, vw bsonrw.ValueWriter, val reflect.Value) error {
-	if !val.IsValid() || val.Type() != tBinary {
-		return ValueEncoderError{Name: "BinaryEncodeValue", Types: []reflect.Type{tBinary}, Received: val}
-	}
-	b := val.Interface().(primitive.Binary)
-
-	return vw.WriteBinaryWithSubtype(b.Data, b.Subtype)
-}
-
-// UndefinedEncodeValue is the ValueEncoderFunc for Undefined.
-func (DefaultValueEncoders) UndefinedEncodeValue(ec EncodeContext, vw bsonrw.ValueWriter, val reflect.Value) error {
-	if !val.IsValid() || val.Type() != tUndefined {
-		return ValueEncoderError{Name: "UndefinedEncodeValue", Types: []reflect.Type{tUndefined}, Received: val}
-	}
-
-	return vw.WriteUndefined()
-}
-
-// DateTimeEncodeValue is the ValueEncoderFunc for DateTime.
-func (DefaultValueEncoders) DateTimeEncodeValue(ec EncodeContext, vw bsonrw.ValueWriter, val reflect.Value) error {
-	if !val.IsValid() || val.Type() != tDateTime {
-		return ValueEncoderError{Name: "DateTimeEncodeValue", Types: []reflect.Type{tDateTime}, Received: val}
-	}
-
-	return vw.WriteDateTime(val.Int())
-}
-
-// NullEncodeValue is the ValueEncoderFunc for Null.
-func (DefaultValueEncoders) NullEncodeValue(ec EncodeContext, vw bsonrw.ValueWriter, val reflect.Value) error {
-	if !val.IsValid() || val.Type() != tNull {
-		return ValueEncoderError{Name: "NullEncodeValue", Types: []reflect.Type{tNull}, Received: val}
-	}
-
-	return vw.WriteNull()
-}
-
-// RegexEncodeValue is the ValueEncoderFunc for Regex.
-func (DefaultValueEncoders) RegexEncodeValue(ec EncodeContext, vw bsonrw.ValueWriter, val reflect.Value) error {
-	if !val.IsValid() || val.Type() != tRegex {
-		return ValueEncoderError{Name: "RegexEncodeValue", Types: []reflect.Type{tRegex}, Received: val}
-	}
-
-	regex := val.Interface().(primitive.Regex)
-
-	return vw.WriteRegex(regex.Pattern, regex.Options)
-}
-
-// DBPointerEncodeValue is the ValueEncoderFunc for DBPointer.
-func (DefaultValueEncoders) DBPointerEncodeValue(ec EncodeContext, vw bsonrw.ValueWriter, val reflect.Value) error {
-	if !val.IsValid() || val.Type() != tDBPointer {
-		return ValueEncoderError{Name: "DBPointerEncodeValue", Types: []reflect.Type{tDBPointer}, Received: val}
-	}
-
-	dbp := val.Interface().(primitive.DBPointer)
-
-	return vw.WriteDBPointer(dbp.DB, dbp.Pointer)
-}
-
-// TimestampEncodeValue is the ValueEncoderFunc for Timestamp.
-func (DefaultValueEncoders) TimestampEncodeValue(ec EncodeContext, vw bsonrw.ValueWriter, val reflect.Value) error {
-	if !val.IsValid() || val.Type() != tTimestamp {
-		return ValueEncoderError{Name: "TimestampEncodeValue", Types: []reflect.Type{tTimestamp}, Received: val}
-	}
-
-	ts := val.Interface().(primitive.Timestamp)
-
-	return vw.WriteTimestamp(ts.T, ts.I)
-}
-
-// MinKeyEncodeValue is the ValueEncoderFunc for MinKey.
-func (DefaultValueEncoders) MinKeyEncodeValue(ec EncodeContext, vw bsonrw.ValueWriter, val reflect.Value) error {
-	if !val.IsValid() || val.Type() != tMinKey {
-		return ValueEncoderError{Name: "MinKeyEncodeValue", Types: []reflect.Type{tMinKey}, Received: val}
-	}
-
-	return vw.WriteMinKey()
-}
-
-// MaxKeyEncodeValue is the ValueEncoderFunc for MaxKey.
-func (DefaultValueEncoders) MaxKeyEncodeValue(ec EncodeContext, vw bsonrw.ValueWriter, val reflect.Value) error {
-	if !val.IsValid() || val.Type() != tMaxKey {
-		return ValueEncoderError{Name: "MaxKeyEncodeValue", Types: []reflect.Type{tMaxKey}, Received: val}
-	}
-
-	return vw.WriteMaxKey()
-}
-
-// CoreDocumentEncodeValue is the ValueEncoderFunc for bsoncore.Document.
-func (DefaultValueEncoders) CoreDocumentEncodeValue(ec EncodeContext, vw bsonrw.ValueWriter, val reflect.Value) error {
-	if !val.IsValid() || val.Type() != tCoreDocument {
-		return ValueEncoderError{Name: "CoreDocumentEncodeValue", Types: []reflect.Type{tCoreDocument}, Received: val}
-	}
-
-	cdoc := val.Interface().(bsoncore.Document)
-
-	return bsonrw.Copier{}.CopyDocumentFromBytes(vw, cdoc)
-}
-
-// CodeWithScopeEncodeValue is the ValueEncoderFunc for CodeWithScope.
-func (dve DefaultValueEncoders) CodeWithScopeEncodeValue(ec EncodeContext, vw bsonrw.ValueWriter, val reflect.Value) error {
-	if !val.IsValid() || val.Type() != tCodeWithScope {
-		return ValueEncoderError{Name: "CodeWithScopeEncodeValue", Types: []reflect.Type{tCodeWithScope}, Received: val}
-	}
-
-	cws := val.Interface().(primitive.CodeWithScope)
-
-	dw, err := vw.WriteCodeWithScope(string(cws.Code))
-	if err != nil {
-		return err
-	}
-
-	sw := sliceWriterPool.Get().(*bsonrw.SliceWriter)
-	defer sliceWriterPool.Put(sw)
-	*sw = (*sw)[:0]
-
-	scopeVW := bvwPool.Get(sw)
-	defer bvwPool.Put(scopeVW)
-
-	encoder, err := ec.LookupEncoder(reflect.TypeOf(cws.Scope))
-	if err != nil {
-		return err
-	}
-
-	err = encoder.EncodeValue(ec, scopeVW, reflect.ValueOf(cws.Scope))
-	if err != nil {
-		return err
-	}
-
-	err = bsonrw.Copier{}.CopyBytesToDocumentWriter(dw, *sw)
-	if err != nil {
-		return err
-	}
-	return dw.WriteDocumentEnd()
-}

+ 0 - 1436
qyxy/src/mgoutil/go.mongodb.org/mongo-driver/bson/bsoncodec/default_value_encoders_test.go

@@ -1,1436 +0,0 @@
-// Copyright (C) MongoDB, Inc. 2017-present.
-//
-// Licensed under the Apache License, Version 2.0 (the "License"); you may
-// not use this file except in compliance with the License. You may obtain
-// a copy of the License at http://www.apache.org/licenses/LICENSE-2.0
-
-package bsoncodec
-
-import (
-	"encoding/json"
-	"errors"
-	"fmt"
-	"net/url"
-	"reflect"
-	"testing"
-	"time"
-
-	"github.com/google/go-cmp/cmp"
-	"go.mongodb.org/mongo-driver/bson/bsonrw"
-	"go.mongodb.org/mongo-driver/bson/bsonrw/bsonrwtest"
-	"go.mongodb.org/mongo-driver/bson/bsontype"
-	"go.mongodb.org/mongo-driver/bson/primitive"
-	"go.mongodb.org/mongo-driver/x/bsonx/bsoncore"
-	"math"
-)
-
-func TestDefaultValueEncoders(t *testing.T) {
-	var dve DefaultValueEncoders
-	var wrong = func(string, string) string { return "wrong" }
-
-	type mybool bool
-	type myint8 int8
-	type myint16 int16
-	type myint32 int32
-	type myint64 int64
-	type myint int
-	type myuint8 uint8
-	type myuint16 uint16
-	type myuint32 uint32
-	type myuint64 uint64
-	type myuint uint
-	type myfloat32 float32
-	type myfloat64 float64
-	type mystring string
-
-	now := time.Now().Truncate(time.Millisecond)
-	pjsnum := new(json.Number)
-	*pjsnum = json.Number("3.14159")
-	d128 := primitive.NewDecimal128(12345, 67890)
-
-	type subtest struct {
-		name   string
-		val    interface{}
-		ectx   *EncodeContext
-		llvrw  *bsonrwtest.ValueReaderWriter
-		invoke bsonrwtest.Invoked
-		err    error
-	}
-
-	testCases := []struct {
-		name     string
-		ve       ValueEncoder
-		subtests []subtest
-	}{
-		{
-			"BooleanEncodeValue",
-			ValueEncoderFunc(dve.BooleanEncodeValue),
-			[]subtest{
-				{
-					"wrong type",
-					wrong,
-					nil,
-					nil,
-					bsonrwtest.Nothing,
-					ValueEncoderError{Name: "BooleanEncodeValue", Kinds: []reflect.Kind{reflect.Bool}, Received: reflect.ValueOf(wrong)},
-				},
-				{"fast path", bool(true), nil, nil, bsonrwtest.WriteBoolean, nil},
-				{"reflection path", mybool(true), nil, nil, bsonrwtest.WriteBoolean, nil},
-			},
-		},
-		{
-			"IntEncodeValue",
-			ValueEncoderFunc(dve.IntEncodeValue),
-			[]subtest{
-				{
-					"wrong type",
-					wrong,
-					nil,
-					nil,
-					bsonrwtest.Nothing,
-					ValueEncoderError{
-						Name:     "IntEncodeValue",
-						Kinds:    []reflect.Kind{reflect.Int8, reflect.Int16, reflect.Int32, reflect.Int64, reflect.Int},
-						Received: reflect.ValueOf(wrong),
-					},
-				},
-				{"int8/fast path", int8(127), nil, nil, bsonrwtest.WriteInt32, nil},
-				{"int16/fast path", int16(32767), nil, nil, bsonrwtest.WriteInt32, nil},
-				{"int32/fast path", int32(2147483647), nil, nil, bsonrwtest.WriteInt32, nil},
-				{"int64/fast path", int64(1234567890987), nil, nil, bsonrwtest.WriteInt64, nil},
-				{"int64/fast path - minsize", int64(math.MaxInt32), &EncodeContext{MinSize: true}, nil, bsonrwtest.WriteInt32, nil},
-				{"int64/fast path - minsize too large", int64(math.MaxInt32 + 1), &EncodeContext{MinSize: true}, nil, bsonrwtest.WriteInt64, nil},
-				{"int64/fast path - minsize too small", int64(math.MinInt32 - 1), &EncodeContext{MinSize: true}, nil, bsonrwtest.WriteInt64, nil},
-				{"int/fast path - positive int32", int(math.MaxInt32 - 1), nil, nil, bsonrwtest.WriteInt32, nil},
-				{"int/fast path - negative int32", int(math.MinInt32 + 1), nil, nil, bsonrwtest.WriteInt32, nil},
-				{"int/fast path - MaxInt32", int(math.MaxInt32), nil, nil, bsonrwtest.WriteInt32, nil},
-				{"int/fast path - MinInt32", int(math.MinInt32), nil, nil, bsonrwtest.WriteInt32, nil},
-				{"int/fast path - larger than MaxInt32", int(math.MaxInt32 + 1), nil, nil, bsonrwtest.WriteInt64, nil},
-				{"int/fast path - smaller than MinInt32", int(math.MinInt32 - 1), nil, nil, bsonrwtest.WriteInt64, nil},
-				{"int8/reflection path", myint8(127), nil, nil, bsonrwtest.WriteInt32, nil},
-				{"int16/reflection path", myint16(32767), nil, nil, bsonrwtest.WriteInt32, nil},
-				{"int32/reflection path", myint32(2147483647), nil, nil, bsonrwtest.WriteInt32, nil},
-				{"int64/reflection path", myint64(1234567890987), nil, nil, bsonrwtest.WriteInt64, nil},
-				{"int64/reflection path - minsize", myint64(math.MaxInt32), &EncodeContext{MinSize: true}, nil, bsonrwtest.WriteInt32, nil},
-				{"int64/reflection path - minsize too large", myint64(math.MaxInt32 + 1), &EncodeContext{MinSize: true}, nil, bsonrwtest.WriteInt64, nil},
-				{"int64/reflection path - minsize too small", myint64(math.MinInt32 - 1), &EncodeContext{MinSize: true}, nil, bsonrwtest.WriteInt64, nil},
-				{"int/reflection path - positive int32", myint(math.MaxInt32 - 1), nil, nil, bsonrwtest.WriteInt32, nil},
-				{"int/reflection path - negative int32", myint(math.MinInt32 + 1), nil, nil, bsonrwtest.WriteInt32, nil},
-				{"int/reflection path - MaxInt32", myint(math.MaxInt32), nil, nil, bsonrwtest.WriteInt32, nil},
-				{"int/reflection path - MinInt32", myint(math.MinInt32), nil, nil, bsonrwtest.WriteInt32, nil},
-				{"int/reflection path - larger than MaxInt32", myint(math.MaxInt32 + 1), nil, nil, bsonrwtest.WriteInt64, nil},
-				{"int/reflection path - smaller than MinInt32", myint(math.MinInt32 - 1), nil, nil, bsonrwtest.WriteInt64, nil},
-			},
-		},
-		{
-			"UintEncodeValue",
-			ValueEncoderFunc(dve.UintEncodeValue),
-			[]subtest{
-				{
-					"wrong type",
-					wrong,
-					nil,
-					nil,
-					bsonrwtest.Nothing,
-					ValueEncoderError{
-						Name:     "UintEncodeValue",
-						Kinds:    []reflect.Kind{reflect.Uint8, reflect.Uint16, reflect.Uint32, reflect.Uint64, reflect.Uint},
-						Received: reflect.ValueOf(wrong),
-					},
-				},
-				{"uint8/fast path", uint8(127), nil, nil, bsonrwtest.WriteInt32, nil},
-				{"uint16/fast path", uint16(32767), nil, nil, bsonrwtest.WriteInt32, nil},
-				{"uint32/fast path", uint32(2147483647), nil, nil, bsonrwtest.WriteInt64, nil},
-				{"uint64/fast path", uint64(1234567890987), nil, nil, bsonrwtest.WriteInt64, nil},
-				{"uint/fast path", uint(1234567), nil, nil, bsonrwtest.WriteInt64, nil},
-				{"uint32/fast path - minsize", uint32(2147483647), &EncodeContext{MinSize: true}, nil, bsonrwtest.WriteInt32, nil},
-				{"uint64/fast path - minsize", uint64(2147483647), &EncodeContext{MinSize: true}, nil, bsonrwtest.WriteInt32, nil},
-				{"uint/fast path - minsize", uint(2147483647), &EncodeContext{MinSize: true}, nil, bsonrwtest.WriteInt32, nil},
-				{"uint32/fast path - minsize too large", uint32(2147483648), &EncodeContext{MinSize: true}, nil, bsonrwtest.WriteInt64, nil},
-				{"uint64/fast path - minsize too large", uint64(2147483648), &EncodeContext{MinSize: true}, nil, bsonrwtest.WriteInt64, nil},
-				{"uint/fast path - minsize too large", uint(2147483648), &EncodeContext{MinSize: true}, nil, bsonrwtest.WriteInt64, nil},
-				{"uint64/fast path - overflow", uint64(1 << 63), nil, nil, bsonrwtest.Nothing, fmt.Errorf("%d overflows int64", uint(1<<63))},
-				{"uint/fast path - overflow", uint(1 << 63), nil, nil, bsonrwtest.Nothing, fmt.Errorf("%d overflows int64", uint(1<<63))},
-				{"uint8/reflection path", myuint8(127), nil, nil, bsonrwtest.WriteInt32, nil},
-				{"uint16/reflection path", myuint16(32767), nil, nil, bsonrwtest.WriteInt32, nil},
-				{"uint32/reflection path", myuint32(2147483647), nil, nil, bsonrwtest.WriteInt64, nil},
-				{"uint64/reflection path", myuint64(1234567890987), nil, nil, bsonrwtest.WriteInt64, nil},
-				{"uint/reflection path", myuint(1234567890987), nil, nil, bsonrwtest.WriteInt64, nil},
-				{"uint32/reflection path - minsize", myuint32(2147483647), &EncodeContext{MinSize: true}, nil, bsonrwtest.WriteInt32, nil},
-				{"uint64/reflection path - minsize", myuint64(2147483647), &EncodeContext{MinSize: true}, nil, bsonrwtest.WriteInt32, nil},
-				{"uint/reflection path - minsize", myuint(2147483647), &EncodeContext{MinSize: true}, nil, bsonrwtest.WriteInt32, nil},
-				{"uint32/reflection path - minsize too large", myuint(1 << 31), &EncodeContext{MinSize: true}, nil, bsonrwtest.WriteInt64, nil},
-				{"uint64/reflection path - minsize too large", myuint64(1 << 31), &EncodeContext{MinSize: true}, nil, bsonrwtest.WriteInt64, nil},
-				{"uint/reflection path - minsize too large", myuint(2147483648), &EncodeContext{MinSize: true}, nil, bsonrwtest.WriteInt64, nil},
-				{"uint64/reflection path - overflow", myuint64(1 << 63), nil, nil, bsonrwtest.Nothing, fmt.Errorf("%d overflows int64", uint(1<<63))},
-				{"uint/reflection path - overflow", myuint(1 << 63), nil, nil, bsonrwtest.Nothing, fmt.Errorf("%d overflows int64", uint(1<<63))},
-			},
-		},
-		{
-			"FloatEncodeValue",
-			ValueEncoderFunc(dve.FloatEncodeValue),
-			[]subtest{
-				{
-					"wrong type",
-					wrong,
-					nil,
-					nil,
-					bsonrwtest.Nothing,
-					ValueEncoderError{
-						Name:     "FloatEncodeValue",
-						Kinds:    []reflect.Kind{reflect.Float32, reflect.Float64},
-						Received: reflect.ValueOf(wrong),
-					},
-				},
-				{"float32/fast path", float32(3.14159), nil, nil, bsonrwtest.WriteDouble, nil},
-				{"float64/fast path", float64(3.14159), nil, nil, bsonrwtest.WriteDouble, nil},
-				{"float32/reflection path", myfloat32(3.14159), nil, nil, bsonrwtest.WriteDouble, nil},
-				{"float64/reflection path", myfloat64(3.14159), nil, nil, bsonrwtest.WriteDouble, nil},
-			},
-		},
-		{
-			"TimeEncodeValue",
-			ValueEncoderFunc(dve.TimeEncodeValue),
-			[]subtest{
-				{
-					"wrong type",
-					wrong,
-					nil,
-					nil,
-					bsonrwtest.Nothing,
-					ValueEncoderError{Name: "TimeEncodeValue", Types: []reflect.Type{tTime}, Received: reflect.ValueOf(wrong)},
-				},
-				{"time.Time", now, nil, nil, bsonrwtest.WriteDateTime, nil},
-			},
-		},
-		{
-			"MapEncodeValue",
-			ValueEncoderFunc(dve.MapEncodeValue),
-			[]subtest{
-				{
-					"wrong kind",
-					wrong,
-					nil,
-					nil,
-					bsonrwtest.Nothing,
-					ValueEncoderError{Name: "MapEncodeValue", Kinds: []reflect.Kind{reflect.Map}, Received: reflect.ValueOf(wrong)},
-				},
-				{
-					"wrong kind (non-string key)",
-					map[int]interface{}{},
-					nil,
-					nil,
-					bsonrwtest.Nothing,
-					ValueEncoderError{
-						Name:     "MapEncodeValue",
-						Kinds:    []reflect.Kind{reflect.Map},
-						Received: reflect.ValueOf(map[int]interface{}{}),
-					},
-				},
-				{
-					"WriteDocument Error",
-					map[string]interface{}{},
-					nil,
-					&bsonrwtest.ValueReaderWriter{Err: errors.New("wd error"), ErrAfter: bsonrwtest.WriteDocument},
-					bsonrwtest.WriteDocument,
-					errors.New("wd error"),
-				},
-				{
-					"Lookup Error",
-					map[string]interface{}{},
-					&EncodeContext{Registry: NewRegistryBuilder().Build()},
-					&bsonrwtest.ValueReaderWriter{},
-					bsonrwtest.WriteDocument,
-					ErrNoEncoder{Type: reflect.TypeOf((*interface{})(nil)).Elem()},
-				},
-				{
-					"WriteDocumentElement Error",
-					map[string]interface{}{"foo": "bar"},
-					&EncodeContext{Registry: buildDefaultRegistry()},
-					&bsonrwtest.ValueReaderWriter{Err: errors.New("wde error"), ErrAfter: bsonrwtest.WriteDocumentElement},
-					bsonrwtest.WriteDocumentElement,
-					errors.New("wde error"),
-				},
-				{
-					"EncodeValue Error",
-					map[string]interface{}{"foo": "bar"},
-					&EncodeContext{Registry: buildDefaultRegistry()},
-					&bsonrwtest.ValueReaderWriter{Err: errors.New("ev error"), ErrAfter: bsonrwtest.WriteString},
-					bsonrwtest.WriteString,
-					errors.New("ev error"),
-				},
-			},
-		},
-		{
-			"ArrayEncodeValue",
-			ValueEncoderFunc(dve.ArrayEncodeValue),
-			[]subtest{
-				{
-					"wrong kind",
-					wrong,
-					nil,
-					nil,
-					bsonrwtest.Nothing,
-					ValueEncoderError{Name: "ArrayEncodeValue", Kinds: []reflect.Kind{reflect.Array}, Received: reflect.ValueOf(wrong)},
-				},
-				{
-					"WriteArray Error",
-					[1]string{},
-					nil,
-					&bsonrwtest.ValueReaderWriter{Err: errors.New("wa error"), ErrAfter: bsonrwtest.WriteArray},
-					bsonrwtest.WriteArray,
-					errors.New("wa error"),
-				},
-				{
-					"Lookup Error",
-					[1]interface{}{},
-					&EncodeContext{Registry: NewRegistryBuilder().Build()},
-					&bsonrwtest.ValueReaderWriter{},
-					bsonrwtest.WriteArray,
-					ErrNoEncoder{Type: reflect.TypeOf((*interface{})(nil)).Elem()},
-				},
-				{
-					"WriteArrayElement Error",
-					[1]string{"foo"},
-					&EncodeContext{Registry: buildDefaultRegistry()},
-					&bsonrwtest.ValueReaderWriter{Err: errors.New("wae error"), ErrAfter: bsonrwtest.WriteArrayElement},
-					bsonrwtest.WriteArrayElement,
-					errors.New("wae error"),
-				},
-				{
-					"EncodeValue Error",
-					[1]string{"foo"},
-					&EncodeContext{Registry: buildDefaultRegistry()},
-					&bsonrwtest.ValueReaderWriter{Err: errors.New("ev error"), ErrAfter: bsonrwtest.WriteString},
-					bsonrwtest.WriteString,
-					errors.New("ev error"),
-				},
-				{
-					"[1]primitive.E/success",
-					[1]primitive.E{{"hello", "world"}},
-					&EncodeContext{Registry: buildDefaultRegistry()},
-					nil,
-					bsonrwtest.WriteDocumentEnd,
-					nil,
-				},
-				{
-					"[1]primitive.E/success",
-					[1]primitive.E{{"hello", nil}},
-					&EncodeContext{Registry: buildDefaultRegistry()},
-					nil,
-					bsonrwtest.WriteDocumentEnd,
-					nil,
-				},
-			},
-		},
-		{
-			"SliceEncodeValue",
-			ValueEncoderFunc(dve.SliceEncodeValue),
-			[]subtest{
-				{
-					"wrong kind",
-					wrong,
-					nil,
-					nil,
-					bsonrwtest.Nothing,
-					ValueEncoderError{Name: "SliceEncodeValue", Kinds: []reflect.Kind{reflect.Slice}, Received: reflect.ValueOf(wrong)},
-				},
-				{
-					"WriteArray Error",
-					[]string{},
-					nil,
-					&bsonrwtest.ValueReaderWriter{Err: errors.New("wa error"), ErrAfter: bsonrwtest.WriteArray},
-					bsonrwtest.WriteArray,
-					errors.New("wa error"),
-				},
-				{
-					"Lookup Error",
-					[]interface{}{},
-					&EncodeContext{Registry: NewRegistryBuilder().Build()},
-					&bsonrwtest.ValueReaderWriter{},
-					bsonrwtest.WriteArray,
-					ErrNoEncoder{Type: reflect.TypeOf((*interface{})(nil)).Elem()},
-				},
-				{
-					"WriteArrayElement Error",
-					[]string{"foo"},
-					&EncodeContext{Registry: buildDefaultRegistry()},
-					&bsonrwtest.ValueReaderWriter{Err: errors.New("wae error"), ErrAfter: bsonrwtest.WriteArrayElement},
-					bsonrwtest.WriteArrayElement,
-					errors.New("wae error"),
-				},
-				{
-					"EncodeValue Error",
-					[]string{"foo"},
-					&EncodeContext{Registry: buildDefaultRegistry()},
-					&bsonrwtest.ValueReaderWriter{Err: errors.New("ev error"), ErrAfter: bsonrwtest.WriteString},
-					bsonrwtest.WriteString,
-					errors.New("ev error"),
-				},
-				{
-					"D/success",
-					primitive.D{{"hello", "world"}},
-					&EncodeContext{Registry: buildDefaultRegistry()},
-					nil,
-					bsonrwtest.WriteDocumentEnd,
-					nil,
-				},
-				{
-					"D/success",
-					primitive.D{{"hello", nil}},
-					&EncodeContext{Registry: buildDefaultRegistry()},
-					nil,
-					bsonrwtest.WriteDocumentEnd,
-					nil,
-				},
-			},
-		},
-		{
-			"ObjectIDEncodeValue",
-			ValueEncoderFunc(dve.ObjectIDEncodeValue),
-			[]subtest{
-				{
-					"wrong type",
-					wrong,
-					nil,
-					nil,
-					bsonrwtest.Nothing,
-					ValueEncoderError{Name: "ObjectIDEncodeValue", Types: []reflect.Type{tOID}, Received: reflect.ValueOf(wrong)},
-				},
-				{
-					"primitive.ObjectID/success",
-					primitive.ObjectID{0x01, 0x02, 0x03, 0x04, 0x05, 0x06, 0x07, 0x08, 0x09, 0x0A, 0x0B, 0x0C},
-					nil, nil, bsonrwtest.WriteObjectID, nil,
-				},
-			},
-		},
-		{
-			"Decimal128EncodeValue",
-			ValueEncoderFunc(dve.Decimal128EncodeValue),
-			[]subtest{
-				{
-					"wrong type",
-					wrong,
-					nil,
-					nil,
-					bsonrwtest.Nothing,
-					ValueEncoderError{Name: "Decimal128EncodeValue", Types: []reflect.Type{tDecimal}, Received: reflect.ValueOf(wrong)},
-				},
-				{"Decimal128/success", d128, nil, nil, bsonrwtest.WriteDecimal128, nil},
-			},
-		},
-		{
-			"JSONNumberEncodeValue",
-			ValueEncoderFunc(dve.JSONNumberEncodeValue),
-			[]subtest{
-				{
-					"wrong type",
-					wrong,
-					nil,
-					nil,
-					bsonrwtest.Nothing,
-					ValueEncoderError{Name: "JSONNumberEncodeValue", Types: []reflect.Type{tJSONNumber}, Received: reflect.ValueOf(wrong)},
-				},
-				{
-					"json.Number/invalid",
-					json.Number("hello world"),
-					nil, nil, bsonrwtest.Nothing, errors.New(`strconv.ParseFloat: parsing "hello world": invalid syntax`),
-				},
-				{
-					"json.Number/int64/success",
-					json.Number("1234567890"),
-					nil, nil, bsonrwtest.WriteInt64, nil,
-				},
-				{
-					"json.Number/float64/success",
-					json.Number("3.14159"),
-					nil, nil, bsonrwtest.WriteDouble, nil,
-				},
-			},
-		},
-		{
-			"URLEncodeValue",
-			ValueEncoderFunc(dve.URLEncodeValue),
-			[]subtest{
-				{
-					"wrong type",
-					wrong,
-					nil,
-					nil,
-					bsonrwtest.Nothing,
-					ValueEncoderError{Name: "URLEncodeValue", Types: []reflect.Type{tURL}, Received: reflect.ValueOf(wrong)},
-				},
-				{"url.URL", url.URL{Scheme: "http", Host: "example.com"}, nil, nil, bsonrwtest.WriteString, nil},
-			},
-		},
-		{
-			"ByteSliceEncodeValue",
-			ValueEncoderFunc(dve.ByteSliceEncodeValue),
-			[]subtest{
-				{
-					"wrong type",
-					wrong,
-					nil,
-					nil,
-					bsonrwtest.Nothing,
-					ValueEncoderError{Name: "ByteSliceEncodeValue", Types: []reflect.Type{tByteSlice}, Received: reflect.ValueOf(wrong)},
-				},
-				{"[]byte", []byte{0x01, 0x02, 0x03}, nil, nil, bsonrwtest.WriteBinary, nil},
-				{"[]byte/nil", []byte(nil), nil, nil, bsonrwtest.WriteNull, nil},
-			},
-		},
-		{
-			"EmptyInterfaceEncodeValue",
-			ValueEncoderFunc(dve.EmptyInterfaceEncodeValue),
-			[]subtest{
-				{
-					"wrong type",
-					wrong,
-					nil,
-					nil,
-					bsonrwtest.Nothing,
-					ValueEncoderError{Name: "EmptyInterfaceEncodeValue", Types: []reflect.Type{tEmpty}, Received: reflect.ValueOf(wrong)},
-				},
-			},
-		},
-		{
-			"ValueMarshalerEncodeValue",
-			ValueEncoderFunc(dve.ValueMarshalerEncodeValue),
-			[]subtest{
-				{
-					"wrong type",
-					wrong,
-					nil,
-					nil,
-					bsonrwtest.Nothing,
-					ValueEncoderError{
-						Name:     "ValueMarshalerEncodeValue",
-						Types:    []reflect.Type{tValueMarshaler},
-						Received: reflect.ValueOf(wrong),
-					},
-				},
-				{
-					"MarshalBSONValue error",
-					testValueMarshaler{err: errors.New("mbsonv error")},
-					nil,
-					nil,
-					bsonrwtest.Nothing,
-					errors.New("mbsonv error"),
-				},
-				{
-					"Copy error",
-					testValueMarshaler{},
-					nil,
-					nil,
-					bsonrwtest.Nothing,
-					fmt.Errorf("Cannot copy unknown BSON type %s", bsontype.Type(0)),
-				},
-				{
-					"success",
-					testValueMarshaler{t: bsontype.String, buf: []byte{0x04, 0x00, 0x00, 0x00, 'f', 'o', 'o', 0x00}},
-					nil,
-					nil,
-					bsonrwtest.WriteString,
-					nil,
-				},
-			},
-		},
-		{
-			"MarshalerEncodeValue",
-			ValueEncoderFunc(dve.MarshalerEncodeValue),
-			[]subtest{
-				{
-					"wrong type",
-					wrong,
-					nil,
-					nil,
-					bsonrwtest.Nothing,
-					ValueEncoderError{Name: "MarshalerEncodeValue", Types: []reflect.Type{tMarshaler}, Received: reflect.ValueOf(wrong)},
-				},
-				{
-					"MarshalBSON error",
-					testMarshaler{err: errors.New("mbson error")},
-					nil,
-					nil,
-					bsonrwtest.Nothing,
-					errors.New("mbson error"),
-				},
-				{
-					"success",
-					testMarshaler{buf: bsoncore.BuildDocument(nil, bsoncore.AppendDoubleElement(nil, "pi", 3.14159))},
-					nil,
-					nil,
-					bsonrwtest.WriteDocumentEnd,
-					nil,
-				},
-			},
-		},
-		{
-			"ProxyEncodeValue",
-			ValueEncoderFunc(dve.ProxyEncodeValue),
-			[]subtest{
-				{
-					"wrong type",
-					wrong,
-					nil,
-					nil,
-					bsonrwtest.Nothing,
-					ValueEncoderError{Name: "ProxyEncodeValue", Types: []reflect.Type{tProxy}, Received: reflect.ValueOf(wrong)},
-				},
-				{
-					"Proxy error",
-					testProxy{err: errors.New("proxy error")},
-					nil,
-					nil,
-					bsonrwtest.Nothing,
-					errors.New("proxy error"),
-				},
-				{
-					"Lookup error",
-					testProxy{ret: nil},
-					&EncodeContext{Registry: buildDefaultRegistry()},
-					nil,
-					bsonrwtest.Nothing,
-					ErrNoEncoder{Type: nil},
-				},
-				{
-					"success",
-					testProxy{ret: int64(1234567890)},
-					&EncodeContext{Registry: buildDefaultRegistry()},
-					nil,
-					bsonrwtest.WriteInt64,
-					nil,
-				},
-			},
-		},
-		{
-			"PointerCodec.EncodeValue",
-			NewPointerCodec(),
-			[]subtest{
-				{
-					"nil",
-					nil,
-					nil,
-					nil,
-					bsonrwtest.WriteNull,
-					nil,
-				},
-				{
-					"not pointer",
-					int32(123456),
-					nil,
-					nil,
-					bsonrwtest.Nothing,
-					ValueEncoderError{Name: "PointerCodec.EncodeValue", Kinds: []reflect.Kind{reflect.Ptr}, Received: reflect.ValueOf(int32(123456))},
-				},
-				{
-					"typed nil",
-					(*int32)(nil),
-					nil,
-					nil,
-					bsonrwtest.WriteNull,
-					nil,
-				},
-				{
-					"no encoder",
-					&wrong,
-					&EncodeContext{Registry: buildDefaultRegistry()},
-					nil,
-					bsonrwtest.Nothing,
-					ErrNoEncoder{Type: reflect.TypeOf(wrong)},
-				},
-			},
-		},
-		{
-			"JavaScriptEncodeValue",
-			ValueEncoderFunc(dve.JavaScriptEncodeValue),
-			[]subtest{
-				{
-					"wrong type",
-					wrong,
-					nil,
-					nil,
-					bsonrwtest.Nothing,
-					ValueEncoderError{Name: "JavaScriptEncodeValue", Types: []reflect.Type{tJavaScript}, Received: reflect.ValueOf(wrong)},
-				},
-				{"JavaScript", primitive.JavaScript("foobar"), nil, nil, bsonrwtest.WriteJavascript, nil},
-			},
-		},
-		{
-			"SymbolEncodeValue",
-			ValueEncoderFunc(dve.SymbolEncodeValue),
-			[]subtest{
-				{
-					"wrong type",
-					wrong,
-					nil,
-					nil,
-					bsonrwtest.Nothing,
-					ValueEncoderError{Name: "SymbolEncodeValue", Types: []reflect.Type{tSymbol}, Received: reflect.ValueOf(wrong)},
-				},
-				{"Symbol", primitive.Symbol("foobar"), nil, nil, bsonrwtest.WriteSymbol, nil},
-			},
-		},
-		{
-			"BinaryEncodeValue",
-			ValueEncoderFunc(dve.BinaryEncodeValue),
-			[]subtest{
-				{
-					"wrong type",
-					wrong,
-					nil,
-					nil,
-					bsonrwtest.Nothing,
-					ValueEncoderError{Name: "BinaryEncodeValue", Types: []reflect.Type{tBinary}, Received: reflect.ValueOf(wrong)},
-				},
-				{"Binary/success", primitive.Binary{Data: []byte{0x01, 0x02}, Subtype: 0xFF}, nil, nil, bsonrwtest.WriteBinaryWithSubtype, nil},
-			},
-		},
-		{
-			"UndefinedEncodeValue",
-			ValueEncoderFunc(dve.UndefinedEncodeValue),
-			[]subtest{
-				{
-					"wrong type",
-					wrong,
-					nil,
-					nil,
-					bsonrwtest.Nothing,
-					ValueEncoderError{Name: "UndefinedEncodeValue", Types: []reflect.Type{tUndefined}, Received: reflect.ValueOf(wrong)},
-				},
-				{"Undefined/success", primitive.Undefined{}, nil, nil, bsonrwtest.WriteUndefined, nil},
-			},
-		},
-		{
-			"DateTimeEncodeValue",
-			ValueEncoderFunc(dve.DateTimeEncodeValue),
-			[]subtest{
-				{
-					"wrong type",
-					wrong,
-					nil,
-					nil,
-					bsonrwtest.Nothing,
-					ValueEncoderError{Name: "DateTimeEncodeValue", Types: []reflect.Type{tDateTime}, Received: reflect.ValueOf(wrong)},
-				},
-				{"DateTime/success", primitive.DateTime(1234567890), nil, nil, bsonrwtest.WriteDateTime, nil},
-			},
-		},
-		{
-			"NullEncodeValue",
-			ValueEncoderFunc(dve.NullEncodeValue),
-			[]subtest{
-				{
-					"wrong type",
-					wrong,
-					nil,
-					nil,
-					bsonrwtest.Nothing,
-					ValueEncoderError{Name: "NullEncodeValue", Types: []reflect.Type{tNull}, Received: reflect.ValueOf(wrong)},
-				},
-				{"Null/success", primitive.Null{}, nil, nil, bsonrwtest.WriteNull, nil},
-			},
-		},
-		{
-			"RegexEncodeValue",
-			ValueEncoderFunc(dve.RegexEncodeValue),
-			[]subtest{
-				{
-					"wrong type",
-					wrong,
-					nil,
-					nil,
-					bsonrwtest.Nothing,
-					ValueEncoderError{Name: "RegexEncodeValue", Types: []reflect.Type{tRegex}, Received: reflect.ValueOf(wrong)},
-				},
-				{"Regex/success", primitive.Regex{Pattern: "foo", Options: "bar"}, nil, nil, bsonrwtest.WriteRegex, nil},
-			},
-		},
-		{
-			"DBPointerEncodeValue",
-			ValueEncoderFunc(dve.DBPointerEncodeValue),
-			[]subtest{
-				{
-					"wrong type",
-					wrong,
-					nil,
-					nil,
-					bsonrwtest.Nothing,
-					ValueEncoderError{Name: "DBPointerEncodeValue", Types: []reflect.Type{tDBPointer}, Received: reflect.ValueOf(wrong)},
-				},
-				{
-					"DBPointer/success",
-					primitive.DBPointer{
-						DB:      "foobar",
-						Pointer: primitive.ObjectID{0x01, 0x02, 0x03, 0x04, 0x05, 0x06, 0x07, 0x08, 0x09, 0x0A, 0x0B, 0x0C},
-					},
-					nil, nil, bsonrwtest.WriteDBPointer, nil,
-				},
-			},
-		},
-		{
-			"TimestampEncodeValue",
-			ValueEncoderFunc(dve.TimestampEncodeValue),
-			[]subtest{
-				{
-					"wrong type",
-					wrong,
-					nil,
-					nil,
-					bsonrwtest.Nothing,
-					ValueEncoderError{Name: "TimestampEncodeValue", Types: []reflect.Type{tTimestamp}, Received: reflect.ValueOf(wrong)},
-				},
-				{"Timestamp/success", primitive.Timestamp{T: 12345, I: 67890}, nil, nil, bsonrwtest.WriteTimestamp, nil},
-			},
-		},
-		{
-			"MinKeyEncodeValue",
-			ValueEncoderFunc(dve.MinKeyEncodeValue),
-			[]subtest{
-				{
-					"wrong type",
-					wrong,
-					nil,
-					nil,
-					bsonrwtest.Nothing,
-					ValueEncoderError{Name: "MinKeyEncodeValue", Types: []reflect.Type{tMinKey}, Received: reflect.ValueOf(wrong)},
-				},
-				{"MinKey/success", primitive.MinKey{}, nil, nil, bsonrwtest.WriteMinKey, nil},
-			},
-		},
-		{
-			"MaxKeyEncodeValue",
-			ValueEncoderFunc(dve.MaxKeyEncodeValue),
-			[]subtest{
-				{
-					"wrong type",
-					wrong,
-					nil,
-					nil,
-					bsonrwtest.Nothing,
-					ValueEncoderError{Name: "MaxKeyEncodeValue", Types: []reflect.Type{tMaxKey}, Received: reflect.ValueOf(wrong)},
-				},
-				{"MaxKey/success", primitive.MaxKey{}, nil, nil, bsonrwtest.WriteMaxKey, nil},
-			},
-		},
-		{
-			"CoreDocumentEncodeValue",
-			ValueEncoderFunc(dve.CoreDocumentEncodeValue),
-			[]subtest{
-				{
-					"wrong type",
-					wrong,
-					nil,
-					nil,
-					bsonrwtest.Nothing,
-					ValueEncoderError{
-						Name:     "CoreDocumentEncodeValue",
-						Types:    []reflect.Type{tCoreDocument},
-						Received: reflect.ValueOf(wrong),
-					},
-				},
-				{
-					"WriteDocument Error",
-					bsoncore.Document{},
-					nil,
-					&bsonrwtest.ValueReaderWriter{Err: errors.New("wd error"), ErrAfter: bsonrwtest.WriteDocument},
-					bsonrwtest.WriteDocument,
-					errors.New("wd error"),
-				},
-				{
-					"bsoncore.Document.Elements Error",
-					bsoncore.Document{0xFF, 0x00, 0x00, 0x00, 0x00},
-					nil,
-					&bsonrwtest.ValueReaderWriter{},
-					bsonrwtest.WriteDocument,
-					errors.New("length read exceeds number of bytes available. length=5 bytes=255"),
-				},
-				{
-					"WriteDocumentElement Error",
-					bsoncore.Document(buildDocument(bsoncore.AppendNullElement(nil, "foo"))),
-					nil,
-					&bsonrwtest.ValueReaderWriter{Err: errors.New("wde error"), ErrAfter: bsonrwtest.WriteDocumentElement},
-					bsonrwtest.WriteDocumentElement,
-					errors.New("wde error"),
-				},
-				{
-					"encodeValue error",
-					bsoncore.Document(buildDocument(bsoncore.AppendNullElement(nil, "foo"))),
-					nil,
-					&bsonrwtest.ValueReaderWriter{Err: errors.New("ev error"), ErrAfter: bsonrwtest.WriteNull},
-					bsonrwtest.WriteNull,
-					errors.New("ev error"),
-				},
-				{
-					"iterator error",
-					bsoncore.Document{0x0C, 0x00, 0x00, 0x00, 0x01, 'f', 'o', 'o', 0x00, 0x01, 0x02, 0x03},
-					nil,
-					&bsonrwtest.ValueReaderWriter{},
-					bsonrwtest.WriteDocumentElement,
-					errors.New("not enough bytes available to read type. bytes=3 type=double"),
-				},
-			},
-		},
-		{
-			"CodeWithScopeEncodeValue",
-			ValueEncoderFunc(dve.CodeWithScopeEncodeValue),
-			[]subtest{
-				{
-					"wrong type",
-					wrong,
-					nil,
-					nil,
-					bsonrwtest.Nothing,
-					ValueEncoderError{
-						Name:     "CodeWithScopeEncodeValue",
-						Types:    []reflect.Type{tCodeWithScope},
-						Received: reflect.ValueOf(wrong),
-					},
-				},
-				{
-					"WriteCodeWithScope error",
-					primitive.CodeWithScope{},
-					nil,
-					&bsonrwtest.ValueReaderWriter{Err: errors.New("wcws error"), ErrAfter: bsonrwtest.WriteCodeWithScope},
-					bsonrwtest.WriteCodeWithScope,
-					errors.New("wcws error"),
-				},
-				{
-					"CodeWithScope/success",
-					primitive.CodeWithScope{
-						Code:  "var hello = 'world';",
-						Scope: primitive.D{},
-					},
-					&EncodeContext{Registry: buildDefaultRegistry()},
-					nil, bsonrwtest.WriteDocumentEnd, nil,
-				},
-			},
-		},
-	}
-
-	for _, tc := range testCases {
-		t.Run(tc.name, func(t *testing.T) {
-			for _, subtest := range tc.subtests {
-				t.Run(subtest.name, func(t *testing.T) {
-					var ec EncodeContext
-					if subtest.ectx != nil {
-						ec = *subtest.ectx
-					}
-					llvrw := new(bsonrwtest.ValueReaderWriter)
-					if subtest.llvrw != nil {
-						llvrw = subtest.llvrw
-					}
-					llvrw.T = t
-					err := tc.ve.EncodeValue(ec, llvrw, reflect.ValueOf(subtest.val))
-					if !compareErrors(err, subtest.err) {
-						t.Errorf("Errors do not match. got %v; want %v", err, subtest.err)
-					}
-					invoked := llvrw.Invoked
-					if !cmp.Equal(invoked, subtest.invoke) {
-						t.Errorf("Incorrect method invoked. got %v; want %v", invoked, subtest.invoke)
-					}
-				})
-			}
-		})
-	}
-
-	t.Run("success path", func(t *testing.T) {
-		oid := primitive.NewObjectID()
-		oids := []primitive.ObjectID{primitive.NewObjectID(), primitive.NewObjectID(), primitive.NewObjectID()}
-		var str = new(string)
-		*str = "bar"
-		now := time.Now().Truncate(time.Millisecond)
-		murl, err := url.Parse("https://mongodb.com/random-url?hello=world")
-		if err != nil {
-			t.Errorf("Error parsing URL: %v", err)
-			t.FailNow()
-		}
-		decimal128, err := primitive.ParseDecimal128("1.5e10")
-		if err != nil {
-			t.Errorf("Error parsing decimal128: %v", err)
-			t.FailNow()
-		}
-
-		testCases := []struct {
-			name  string
-			value interface{}
-			b     []byte
-			err   error
-		}{
-			{
-				"map[string]int",
-				map[string]int32{"foo": 1},
-				[]byte{
-					0x0E, 0x00, 0x00, 0x00,
-					0x10, 'f', 'o', 'o', 0x00,
-					0x01, 0x00, 0x00, 0x00,
-					0x00,
-				},
-				nil,
-			},
-			{
-				"map[string]primitive.ObjectID",
-				map[string]primitive.ObjectID{"foo": oid},
-				buildDocument(bsoncore.AppendObjectIDElement(nil, "foo", oid)),
-				nil,
-			},
-			{
-				"map[string][]int32",
-				map[string][]int32{"Z": {1, 2, 3}},
-				buildDocumentArray(func(doc []byte) []byte {
-					doc = bsoncore.AppendInt32Element(doc, "0", 1)
-					doc = bsoncore.AppendInt32Element(doc, "1", 2)
-					return bsoncore.AppendInt32Element(doc, "2", 3)
-				}),
-				nil,
-			},
-			{
-				"map[string][]primitive.ObjectID",
-				map[string][]primitive.ObjectID{"Z": oids},
-				buildDocumentArray(func(doc []byte) []byte {
-					doc = bsoncore.AppendObjectIDElement(doc, "0", oids[0])
-					doc = bsoncore.AppendObjectIDElement(doc, "1", oids[1])
-					return bsoncore.AppendObjectIDElement(doc, "2", oids[2])
-				}),
-				nil,
-			},
-			{
-				"map[string][]json.Number(int64)",
-				map[string][]json.Number{"Z": {json.Number("5"), json.Number("10")}},
-				buildDocumentArray(func(doc []byte) []byte {
-					doc = bsoncore.AppendInt64Element(doc, "0", 5)
-					return bsoncore.AppendInt64Element(doc, "1", 10)
-				}),
-				nil,
-			},
-			{
-				"map[string][]json.Number(float64)",
-				map[string][]json.Number{"Z": {json.Number("5"), json.Number("10.1")}},
-				buildDocumentArray(func(doc []byte) []byte {
-					doc = bsoncore.AppendInt64Element(doc, "0", 5)
-					return bsoncore.AppendDoubleElement(doc, "1", 10.1)
-				}),
-				nil,
-			},
-			{
-				"map[string][]*url.URL",
-				map[string][]*url.URL{"Z": {murl}},
-				buildDocumentArray(func(doc []byte) []byte {
-					return bsoncore.AppendStringElement(doc, "0", murl.String())
-				}),
-				nil,
-			},
-			{
-				"map[string][]primitive.Decimal128",
-				map[string][]primitive.Decimal128{"Z": {decimal128}},
-				buildDocumentArray(func(doc []byte) []byte {
-					return bsoncore.AppendDecimal128Element(doc, "0", decimal128)
-				}),
-				nil,
-			},
-			{
-				"-",
-				struct {
-					A string `bson:"-"`
-				}{
-					A: "",
-				},
-				[]byte{0x05, 0x00, 0x00, 0x00, 0x00},
-				nil,
-			},
-			{
-				"omitempty",
-				struct {
-					A string `bson:",omitempty"`
-				}{
-					A: "",
-				},
-				[]byte{0x05, 0x00, 0x00, 0x00, 0x00},
-				nil,
-			},
-			{
-				"omitempty, empty time",
-				struct {
-					A time.Time `bson:",omitempty"`
-				}{
-					A: time.Time{},
-				},
-				[]byte{0x05, 0x00, 0x00, 0x00, 0x00},
-				nil,
-			},
-			{
-				"no private fields",
-				noPrivateFields{a: "should be empty"},
-				[]byte{0x05, 0x00, 0x00, 0x00, 0x00},
-				nil,
-			},
-			{
-				"minsize",
-				struct {
-					A int64 `bson:",minsize"`
-				}{
-					A: 12345,
-				},
-				buildDocument(bsoncore.AppendInt32Element(nil, "a", 12345)),
-				nil,
-			},
-			{
-				"inline",
-				struct {
-					Foo struct {
-						A int64 `bson:",minsize"`
-					} `bson:",inline"`
-				}{
-					Foo: struct {
-						A int64 `bson:",minsize"`
-					}{
-						A: 12345,
-					},
-				},
-				buildDocument(bsoncore.AppendInt32Element(nil, "a", 12345)),
-				nil,
-			},
-			{
-				"inline map",
-				struct {
-					Foo map[string]string `bson:",inline"`
-				}{
-					Foo: map[string]string{"foo": "bar"},
-				},
-				buildDocument(bsoncore.AppendStringElement(nil, "foo", "bar")),
-				nil,
-			},
-			{
-				"alternate name bson:name",
-				struct {
-					A string `bson:"foo"`
-				}{
-					A: "bar",
-				},
-				buildDocument(bsoncore.AppendStringElement(nil, "foo", "bar")),
-				nil,
-			},
-			{
-				"alternate name",
-				struct {
-					A string `bson:"foo"`
-				}{
-					A: "bar",
-				},
-				buildDocument(bsoncore.AppendStringElement(nil, "foo", "bar")),
-				nil,
-			},
-			{
-				"inline, omitempty",
-				struct {
-					A   string
-					Foo zeroTest `bson:"omitempty,inline"`
-				}{
-					A:   "bar",
-					Foo: zeroTest{true},
-				},
-				buildDocument(bsoncore.AppendStringElement(nil, "a", "bar")),
-				nil,
-			},
-			{
-				"struct{}",
-				struct {
-					A bool
-					B int32
-					C int64
-					D uint16
-					E uint64
-					F float64
-					G string
-					H map[string]string
-					I []byte
-					K [2]string
-					L struct {
-						M string
-					}
-					Q  primitive.ObjectID
-					T  []struct{}
-					Y  json.Number
-					Z  time.Time
-					AA json.Number
-					AB *url.URL
-					AC primitive.Decimal128
-					AD *time.Time
-					AE testValueMarshaler
-					AF Proxy
-					AG testProxy
-					AH map[string]interface{}
-					AI primitive.CodeWithScope
-				}{
-					A: true,
-					B: 123,
-					C: 456,
-					D: 789,
-					E: 101112,
-					F: 3.14159,
-					G: "Hello, world",
-					H: map[string]string{"foo": "bar"},
-					I: []byte{0x01, 0x02, 0x03},
-					K: [2]string{"baz", "qux"},
-					L: struct {
-						M string
-					}{
-						M: "foobar",
-					},
-					Q:  oid,
-					T:  nil,
-					Y:  json.Number("5"),
-					Z:  now,
-					AA: json.Number("10.1"),
-					AB: murl,
-					AC: decimal128,
-					AD: &now,
-					AE: testValueMarshaler{t: bsontype.String, buf: bsoncore.AppendString(nil, "hello, world")},
-					AF: testProxy{ret: struct{ Hello string }{Hello: "world!"}},
-					AG: testProxy{ret: struct{ Pi float64 }{Pi: 3.14159}},
-					AH: nil,
-					AI: primitive.CodeWithScope{Code: "var hello = 'world';", Scope: primitive.D{{"pi", 3.14159}}},
-				},
-				buildDocument(func(doc []byte) []byte {
-					doc = bsoncore.AppendBooleanElement(doc, "a", true)
-					doc = bsoncore.AppendInt32Element(doc, "b", 123)
-					doc = bsoncore.AppendInt64Element(doc, "c", 456)
-					doc = bsoncore.AppendInt32Element(doc, "d", 789)
-					doc = bsoncore.AppendInt64Element(doc, "e", 101112)
-					doc = bsoncore.AppendDoubleElement(doc, "f", 3.14159)
-					doc = bsoncore.AppendStringElement(doc, "g", "Hello, world")
-					doc = bsoncore.AppendDocumentElement(doc, "h", buildDocument(bsoncore.AppendStringElement(nil, "foo", "bar")))
-					doc = bsoncore.AppendBinaryElement(doc, "i", 0x00, []byte{0x01, 0x02, 0x03})
-					doc = bsoncore.AppendArrayElement(doc, "k",
-						buildArray(bsoncore.AppendStringElement(bsoncore.AppendStringElement(nil, "0", "baz"), "1", "qux")),
-					)
-					doc = bsoncore.AppendDocumentElement(doc, "l", buildDocument(bsoncore.AppendStringElement(nil, "m", "foobar")))
-					doc = bsoncore.AppendObjectIDElement(doc, "q", oid)
-					doc = bsoncore.AppendNullElement(doc, "t")
-					doc = bsoncore.AppendInt64Element(doc, "y", 5)
-					doc = bsoncore.AppendDateTimeElement(doc, "z", now.UnixNano()/int64(time.Millisecond))
-					doc = bsoncore.AppendDoubleElement(doc, "aa", 10.1)
-					doc = bsoncore.AppendStringElement(doc, "ab", murl.String())
-					doc = bsoncore.AppendDecimal128Element(doc, "ac", decimal128)
-					doc = bsoncore.AppendDateTimeElement(doc, "ad", now.UnixNano()/int64(time.Millisecond))
-					doc = bsoncore.AppendStringElement(doc, "ae", "hello, world")
-					doc = bsoncore.AppendDocumentElement(doc, "af", buildDocument(bsoncore.AppendStringElement(nil, "hello", "world!")))
-					doc = bsoncore.AppendDocumentElement(doc, "ag", buildDocument(bsoncore.AppendDoubleElement(nil, "pi", 3.14159)))
-					doc = bsoncore.AppendNullElement(doc, "ah")
-					doc = bsoncore.AppendCodeWithScopeElement(doc, "ai",
-						"var hello = 'world';", buildDocument(bsoncore.AppendDoubleElement(nil, "pi", 3.14159)),
-					)
-					return doc
-				}(nil)),
-				nil,
-			},
-			{
-				"struct{[]interface{}}",
-				struct {
-					A []bool
-					B []int32
-					C []int64
-					D []uint16
-					E []uint64
-					F []float64
-					G []string
-					H []map[string]string
-					I [][]byte
-					K [1][2]string
-					L []struct {
-						M string
-					}
-					N  [][]string
-					R  []primitive.ObjectID
-					T  []struct{}
-					W  []map[string]struct{}
-					X  []map[string]struct{}
-					Y  []map[string]struct{}
-					Z  []time.Time
-					AA []json.Number
-					AB []*url.URL
-					AC []primitive.Decimal128
-					AD []*time.Time
-					AE []testValueMarshaler
-					AF []Proxy
-					AG []testProxy
-				}{
-					A: []bool{true},
-					B: []int32{123},
-					C: []int64{456},
-					D: []uint16{789},
-					E: []uint64{101112},
-					F: []float64{3.14159},
-					G: []string{"Hello, world"},
-					H: []map[string]string{{"foo": "bar"}},
-					I: [][]byte{{0x01, 0x02, 0x03}},
-					K: [1][2]string{{"baz", "qux"}},
-					L: []struct {
-						M string
-					}{
-						{
-							M: "foobar",
-						},
-					},
-					N:  [][]string{{"foo", "bar"}},
-					R:  oids,
-					T:  nil,
-					W:  nil,
-					X:  []map[string]struct{}{},   // Should be empty BSON Array
-					Y:  []map[string]struct{}{{}}, // Should be BSON array with one element, an empty BSON SubDocument
-					Z:  []time.Time{now, now},
-					AA: []json.Number{json.Number("5"), json.Number("10.1")},
-					AB: []*url.URL{murl},
-					AC: []primitive.Decimal128{decimal128},
-					AD: []*time.Time{&now, &now},
-					AE: []testValueMarshaler{
-						{t: bsontype.String, buf: bsoncore.AppendString(nil, "hello")},
-						{t: bsontype.String, buf: bsoncore.AppendString(nil, "world")},
-					},
-					AF: []Proxy{
-						testProxy{ret: struct{ Hello string }{Hello: "world!"}},
-						testProxy{ret: struct{ Foo string }{Foo: "bar"}},
-					},
-					AG: []testProxy{
-						{ret: struct{ One int64 }{One: 1234567890}},
-						{ret: struct{ Pi float64 }{Pi: 3.14159}},
-					},
-				},
-				buildDocument(func(doc []byte) []byte {
-					doc = appendArrayElement(doc, "a", bsoncore.AppendBooleanElement(nil, "0", true))
-					doc = appendArrayElement(doc, "b", bsoncore.AppendInt32Element(nil, "0", 123))
-					doc = appendArrayElement(doc, "c", bsoncore.AppendInt64Element(nil, "0", 456))
-					doc = appendArrayElement(doc, "d", bsoncore.AppendInt32Element(nil, "0", 789))
-					doc = appendArrayElement(doc, "e", bsoncore.AppendInt64Element(nil, "0", 101112))
-					doc = appendArrayElement(doc, "f", bsoncore.AppendDoubleElement(nil, "0", 3.14159))
-					doc = appendArrayElement(doc, "g", bsoncore.AppendStringElement(nil, "0", "Hello, world"))
-					doc = appendArrayElement(doc, "h", buildDocumentElement("0", bsoncore.AppendStringElement(nil, "foo", "bar")))
-					doc = appendArrayElement(doc, "i", bsoncore.AppendBinaryElement(nil, "0", 0x00, []byte{0x01, 0x02, 0x03}))
-					doc = appendArrayElement(doc, "k",
-						buildArrayElement("0",
-							bsoncore.AppendStringElement(bsoncore.AppendStringElement(nil, "0", "baz"), "1", "qux")),
-					)
-					doc = appendArrayElement(doc, "l", buildDocumentElement("0", bsoncore.AppendStringElement(nil, "m", "foobar")))
-					doc = appendArrayElement(doc, "n",
-						buildArrayElement("0",
-							bsoncore.AppendStringElement(bsoncore.AppendStringElement(nil, "0", "foo"), "1", "bar")),
-					)
-					doc = appendArrayElement(doc, "r",
-						bsoncore.AppendObjectIDElement(
-							bsoncore.AppendObjectIDElement(
-								bsoncore.AppendObjectIDElement(nil,
-									"0", oids[0]),
-								"1", oids[1]),
-							"2", oids[2]),
-					)
-					doc = bsoncore.AppendNullElement(doc, "t")
-					doc = bsoncore.AppendNullElement(doc, "w")
-					doc = appendArrayElement(doc, "x", nil)
-					doc = appendArrayElement(doc, "y", buildDocumentElement("0", nil))
-					doc = appendArrayElement(doc, "z",
-						bsoncore.AppendDateTimeElement(
-							bsoncore.AppendDateTimeElement(
-								nil, "0", now.UnixNano()/int64(time.Millisecond)),
-							"1", now.UnixNano()/int64(time.Millisecond)),
-					)
-					doc = appendArrayElement(doc, "aa", bsoncore.AppendDoubleElement(bsoncore.AppendInt64Element(nil, "0", 5), "1", 10.10))
-					doc = appendArrayElement(doc, "ab", bsoncore.AppendStringElement(nil, "0", murl.String()))
-					doc = appendArrayElement(doc, "ac", bsoncore.AppendDecimal128Element(nil, "0", decimal128))
-					doc = appendArrayElement(doc, "ad",
-						bsoncore.AppendDateTimeElement(
-							bsoncore.AppendDateTimeElement(nil, "0", now.UnixNano()/int64(time.Millisecond)),
-							"1", now.UnixNano()/int64(time.Millisecond)),
-					)
-					doc = appendArrayElement(doc, "ae",
-						bsoncore.AppendStringElement(bsoncore.AppendStringElement(nil, "0", "hello"), "1", "world"),
-					)
-					doc = appendArrayElement(doc, "af",
-						bsoncore.AppendDocumentElement(
-							bsoncore.AppendDocumentElement(nil, "0",
-								bsoncore.BuildDocument(nil, bsoncore.AppendStringElement(nil, "hello", "world!")),
-							), "1",
-							bsoncore.BuildDocument(nil, bsoncore.AppendStringElement(nil, "foo", "bar")),
-						),
-					)
-					doc = appendArrayElement(doc, "ag",
-						bsoncore.AppendDocumentElement(
-							bsoncore.AppendDocumentElement(nil, "0",
-								bsoncore.BuildDocument(nil, bsoncore.AppendInt64Element(nil, "one", 1234567890)),
-							), "1",
-							bsoncore.BuildDocument(nil, bsoncore.AppendDoubleElement(nil, "pi", 3.14159)),
-						),
-					)
-					return doc
-				}(nil)),
-				nil,
-			},
-		}
-
-		for _, tc := range testCases {
-			t.Run(tc.name, func(t *testing.T) {
-				b := make(bsonrw.SliceWriter, 0, 512)
-				vw, err := bsonrw.NewBSONValueWriter(&b)
-				noerr(t, err)
-				reg := buildDefaultRegistry()
-				enc, err := reg.LookupEncoder(reflect.TypeOf(tc.value))
-				noerr(t, err)
-				err = enc.EncodeValue(EncodeContext{Registry: reg}, vw, reflect.ValueOf(tc.value))
-				if err != tc.err {
-					t.Errorf("Did not receive expected error. got %v; want %v", err, tc.err)
-				}
-				if diff := cmp.Diff([]byte(b), tc.b); diff != "" {
-					t.Errorf("Bytes written differ: (-got +want)\n%s", diff)
-					t.Errorf("Bytes\ngot: %v\nwant:%v\n", b, tc.b)
-					t.Errorf("Readers\ngot: %v\nwant:%v\n", bsoncore.Document(b), bsoncore.Document(tc.b))
-				}
-			})
-		}
-	})
-
-	t.Run("EmptyInterfaceEncodeValue/nil", func(t *testing.T) {
-		val := reflect.New(tEmpty).Elem()
-		llvrw := new(bsonrwtest.ValueReaderWriter)
-		err := dve.EmptyInterfaceEncodeValue(EncodeContext{Registry: NewRegistryBuilder().Build()}, llvrw, val)
-		noerr(t, err)
-		if llvrw.Invoked != bsonrwtest.WriteNull {
-			t.Errorf("Incorrect method called. got %v; want %v", llvrw.Invoked, bsonrwtest.WriteNull)
-		}
-	})
-
-	t.Run("EmptyInterfaceEncodeValue/LookupEncoder error", func(t *testing.T) {
-		val := reflect.New(tEmpty).Elem()
-		val.Set(reflect.ValueOf(int64(1234567890)))
-		llvrw := new(bsonrwtest.ValueReaderWriter)
-		got := dve.EmptyInterfaceEncodeValue(EncodeContext{Registry: NewRegistryBuilder().Build()}, llvrw, val)
-		want := ErrNoEncoder{Type: tInt64}
-		if !compareErrors(got, want) {
-			t.Errorf("Did not recieve expected error. got %v; want %v", got, want)
-		}
-	})
-}
-
-type testValueMarshaler struct {
-	t   bsontype.Type
-	buf []byte
-	err error
-}
-
-func (tvm testValueMarshaler) MarshalBSONValue() (bsontype.Type, []byte, error) {
-	return tvm.t, tvm.buf, tvm.err
-}
-
-type testMarshaler struct {
-	buf []byte
-	err error
-}
-
-func (tvm testMarshaler) MarshalBSON() ([]byte, error) {
-	return tvm.buf, tvm.err
-}
-
-type testProxy struct {
-	ret interface{}
-	err error
-}
-
-func (tp testProxy) ProxyBSON() (interface{}, error) { return tp.ret, tp.err }

+ 0 - 61
qyxy/src/mgoutil/go.mongodb.org/mongo-driver/bson/bsoncodec/doc.go

@@ -1,61 +0,0 @@
-// Package bsoncodec provides a system for encoding values to BSON representations and decoding
-// values from BSON representations. This package considers both binary BSON and ExtendedJSON as
-// BSON representations. The types in this package enable a flexible system for handling this
-// encoding and decoding.
-//
-// The codec system is composed of two parts:
-//
-// 1) ValueEncoders and ValueDecoders that handle encoding and decoding Go values to and from BSON
-// representations.
-//
-// 2) A Registry that holds these ValueEncoders and ValueDecoders and provides methods for
-// retrieving them.
-//
-// ValueEncoders and ValueDecoders
-//
-// The ValueEncoder interface is implemented by types that can encode a provided Go type to BSON.
-// The value to encode is provided as a reflect.Value and a bsonrw.ValueWriter is used within the
-// EncodeValue method to actually create the BSON representation. For convenience, ValueEncoderFunc
-// is provided to allow use of a function with the correct signature as a ValueEncoder. An
-// EncodeContext instance is provided to allow implementations to lookup further ValueEncoders and
-// to provide configuration information.
-//
-// The ValueDecoder interface is the inverse of the ValueEncoder. Implementations should ensure that
-// the value they receive is settable. Similar to ValueEncoderFunc, ValueDecoderFunc is provided to
-// allow the use of a function with the correct signature as a ValueDecoder. A DecodeContext
-// instance is provided and serves similar functionality to the EncodeContext.
-//
-// Registry and RegistryBuilder
-//
-// A Registry is an immutable store for ValueEncoders, ValueDecoders, and a type map. For looking up
-// ValueEncoders and Decoders the Registry first attempts to find a ValueEncoder or ValueDecoder for
-// the type provided; if one cannot be found it then checks to see if a registered ValueEncoder or
-// ValueDecoder exists for an interface the type implements. Finally, the reflect.Kind of the type
-// is used to lookup a default ValueEncoder or ValueDecoder for that kind. If no ValueEncoder or
-// ValueDecoder can be found, an error is returned.
-//
-// The Registry also holds a type map. This allows users to retrieve the Go type that should be used
-// when decoding a BSON value into an empty interface. This is primarily only used for the empty
-// interface ValueDecoder.
-//
-// A RegistryBuilder is used to construct a Registry. The Register methods are used to associate
-// either a reflect.Type or a reflect.Kind with a ValueEncoder or ValueDecoder. A RegistryBuilder
-// returned from NewRegistryBuilder contains no registered ValueEncoders nor ValueDecoders and
-// contains an empty type map.
-//
-// The RegisterTypeMapEntry method handles associating a BSON type with a Go type. For example, if
-// you want to decode BSON int64 and int32 values into Go int instances, you would do the following:
-//
-//  var regbuilder *RegistryBuilder = ... intType := reflect.TypeOf(int(0))
-//  regbuilder.RegisterTypeMapEntry(bsontype.Int64, intType).RegisterTypeMapEntry(bsontype.Int32,
-//  intType)
-//
-// DefaultValueEncoders and DefaultValueDecoders
-//
-// The DefaultValueEncoders and DefaultValueDecoders types provide a full set of ValueEncoders and
-// ValueDecoders for handling a wide range of Go types, including all of the types within the
-// primitive package. To make registering these codecs easier, a helper method on each type is
-// provided. For the DefaultValueEncoders type the method is called RegisterDefaultEncoders and for
-// the DefaultValueDecoders type the method is called RegisterDefaultDecoders, this method also
-// handles registering type map entries for each BSON type.
-package bsoncodec

+ 0 - 65
qyxy/src/mgoutil/go.mongodb.org/mongo-driver/bson/bsoncodec/mode.go

@@ -1,65 +0,0 @@
-// Copyright (C) MongoDB, Inc. 2017-present.
-//
-// Licensed under the Apache License, Version 2.0 (the "License"); you may
-// not use this file except in compliance with the License. You may obtain
-// a copy of the License at http://www.apache.org/licenses/LICENSE-2.0
-
-package bsoncodec
-
-import "fmt"
-
-type mode int
-
-const (
-	_ mode = iota
-	mTopLevel
-	mDocument
-	mArray
-	mValue
-	mElement
-	mCodeWithScope
-	mSpacer
-)
-
-func (m mode) String() string {
-	var str string
-
-	switch m {
-	case mTopLevel:
-		str = "TopLevel"
-	case mDocument:
-		str = "DocumentMode"
-	case mArray:
-		str = "ArrayMode"
-	case mValue:
-		str = "ValueMode"
-	case mElement:
-		str = "ElementMode"
-	case mCodeWithScope:
-		str = "CodeWithScopeMode"
-	case mSpacer:
-		str = "CodeWithScopeSpacerFrame"
-	default:
-		str = "UnknownMode"
-	}
-
-	return str
-}
-
-// TransitionError is an error returned when an invalid progressing a
-// ValueReader or ValueWriter state machine occurs.
-type TransitionError struct {
-	parent      mode
-	current     mode
-	destination mode
-}
-
-func (te TransitionError) Error() string {
-	if te.destination == mode(0) {
-		return fmt.Sprintf("invalid state transition: cannot read/write value while in %s", te.current)
-	}
-	if te.parent == mode(0) {
-		return fmt.Sprintf("invalid state transition: %s -> %s", te.current, te.destination)
-	}
-	return fmt.Sprintf("invalid state transition: %s -> %s; parent %s", te.current, te.destination, te.parent)
-}

+ 0 - 110
qyxy/src/mgoutil/go.mongodb.org/mongo-driver/bson/bsoncodec/pointer_codec.go

@@ -1,110 +0,0 @@
-// Copyright (C) MongoDB, Inc. 2017-present.
-//
-// Licensed under the Apache License, Version 2.0 (the "License"); you may
-// not use this file except in compliance with the License. You may obtain
-// a copy of the License at http://www.apache.org/licenses/LICENSE-2.0
-
-package bsoncodec
-
-import (
-	"reflect"
-	"sync"
-
-	"go.mongodb.org/mongo-driver/bson/bsonrw"
-	"go.mongodb.org/mongo-driver/bson/bsontype"
-)
-
-var defaultPointerCodec = &PointerCodec{
-	ecache: make(map[reflect.Type]ValueEncoder),
-	dcache: make(map[reflect.Type]ValueDecoder),
-}
-
-var _ ValueEncoder = &PointerCodec{}
-var _ ValueDecoder = &PointerCodec{}
-
-// PointerCodec is the Codec used for pointers.
-type PointerCodec struct {
-	ecache map[reflect.Type]ValueEncoder
-	dcache map[reflect.Type]ValueDecoder
-	l      sync.RWMutex
-}
-
-// NewPointerCodec returns a PointerCodec that has been initialized.
-func NewPointerCodec() *PointerCodec {
-	return &PointerCodec{
-		ecache: make(map[reflect.Type]ValueEncoder),
-		dcache: make(map[reflect.Type]ValueDecoder),
-	}
-}
-
-// EncodeValue handles encoding a pointer by either encoding it to BSON Null if the pointer is nil
-// or looking up an encoder for the type of value the pointer points to.
-func (pc *PointerCodec) EncodeValue(ec EncodeContext, vw bsonrw.ValueWriter, val reflect.Value) error {
-	if val.Kind() != reflect.Ptr {
-		if !val.IsValid() {
-			return vw.WriteNull()
-		}
-		return ValueEncoderError{Name: "PointerCodec.EncodeValue", Kinds: []reflect.Kind{reflect.Ptr}, Received: val}
-	}
-
-	if val.IsNil() {
-		return vw.WriteNull()
-	}
-
-	pc.l.RLock()
-	enc, ok := pc.ecache[val.Type()]
-	pc.l.RUnlock()
-	if ok {
-		if enc == nil {
-			return ErrNoEncoder{Type: val.Type()}
-		}
-		return enc.EncodeValue(ec, vw, val.Elem())
-	}
-
-	enc, err := ec.LookupEncoder(val.Type().Elem())
-	pc.l.Lock()
-	pc.ecache[val.Type()] = enc
-	pc.l.Unlock()
-	if err != nil {
-		return err
-	}
-
-	return enc.EncodeValue(ec, vw, val.Elem())
-}
-
-// DecodeValue handles decoding a pointer by looking up a decoder for the type it points to and
-// using that to decode. If the BSON value is Null, this method will set the pointer to nil.
-func (pc *PointerCodec) DecodeValue(dc DecodeContext, vr bsonrw.ValueReader, val reflect.Value) error {
-	if !val.CanSet() || val.Kind() != reflect.Ptr {
-		return ValueDecoderError{Name: "PointerCodec.DecodeValue", Kinds: []reflect.Kind{reflect.Ptr}, Received: val}
-	}
-
-	if vr.Type() == bsontype.Null {
-		val.Set(reflect.Zero(val.Type()))
-		return vr.ReadNull()
-	}
-
-	if val.IsNil() {
-		val.Set(reflect.New(val.Type().Elem()))
-	}
-
-	pc.l.RLock()
-	dec, ok := pc.dcache[val.Type()]
-	pc.l.RUnlock()
-	if ok {
-		if dec == nil {
-			return ErrNoDecoder{Type: val.Type()}
-		}
-		return dec.DecodeValue(dc, vr, val.Elem())
-	}
-
-	dec, err := dc.LookupDecoder(val.Type().Elem())
-	pc.l.Lock()
-	pc.dcache[val.Type()] = dec
-	pc.l.Unlock()
-	if err != nil {
-		return err
-	}
-
-	return dec.DecodeValue(dc, vr, val.Elem())
-}

+ 0 - 14
qyxy/src/mgoutil/go.mongodb.org/mongo-driver/bson/bsoncodec/proxy.go

@@ -1,14 +0,0 @@
-// Copyright (C) MongoDB, Inc. 2017-present.
-//
-// Licensed under the Apache License, Version 2.0 (the "License"); you may
-// not use this file except in compliance with the License. You may obtain
-// a copy of the License at http://www.apache.org/licenses/LICENSE-2.0
-
-package bsoncodec
-
-// Proxy is an interface implemented by types that cannot themselves be directly encoded. Types
-// that implement this interface with have ProxyBSON called during the encoding process and that
-// value will be encoded in place for the implementer.
-type Proxy interface {
-	ProxyBSON() (interface{}, error)
-}

+ 0 - 384
qyxy/src/mgoutil/go.mongodb.org/mongo-driver/bson/bsoncodec/registry.go

@@ -1,384 +0,0 @@
-// Copyright (C) MongoDB, Inc. 2017-present.
-//
-// Licensed under the Apache License, Version 2.0 (the "License"); you may
-// not use this file except in compliance with the License. You may obtain
-// a copy of the License at http://www.apache.org/licenses/LICENSE-2.0
-
-package bsoncodec
-
-import (
-	"errors"
-	"reflect"
-	"sync"
-
-	"go.mongodb.org/mongo-driver/bson/bsontype"
-)
-
-// ErrNilType is returned when nil is passed to either LookupEncoder or LookupDecoder.
-var ErrNilType = errors.New("cannot perform a decoder lookup on <nil>")
-
-// ErrNotPointer is returned when a non-pointer type is provided to LookupDecoder.
-var ErrNotPointer = errors.New("non-pointer provided to LookupDecoder")
-
-// ErrNoEncoder is returned when there wasn't an encoder available for a type.
-type ErrNoEncoder struct {
-	Type reflect.Type
-}
-
-func (ene ErrNoEncoder) Error() string {
-	if ene.Type == nil {
-		return "no encoder found for <nil>"
-	}
-	return "no encoder found for " + ene.Type.String()
-}
-
-// ErrNoDecoder is returned when there wasn't a decoder available for a type.
-type ErrNoDecoder struct {
-	Type reflect.Type
-}
-
-func (end ErrNoDecoder) Error() string {
-	return "no decoder found for " + end.Type.String()
-}
-
-// ErrNoTypeMapEntry is returned when there wasn't a type available for the provided BSON type.
-type ErrNoTypeMapEntry struct {
-	Type bsontype.Type
-}
-
-func (entme ErrNoTypeMapEntry) Error() string {
-	return "no type map entry found for " + entme.Type.String()
-}
-
-// ErrNotInterface is returned when the provided type is not an interface.
-var ErrNotInterface = errors.New("The provided type is not an interface")
-
-var defaultRegistry *Registry
-
-func init() {
-	defaultRegistry = buildDefaultRegistry()
-}
-
-// A RegistryBuilder is used to build a Registry. This type is not goroutine
-// safe.
-type RegistryBuilder struct {
-	typeEncoders      map[reflect.Type]ValueEncoder
-	interfaceEncoders []interfaceValueEncoder
-	kindEncoders      map[reflect.Kind]ValueEncoder
-
-	typeDecoders      map[reflect.Type]ValueDecoder
-	interfaceDecoders []interfaceValueDecoder
-	kindDecoders      map[reflect.Kind]ValueDecoder
-
-	typeMap map[bsontype.Type]reflect.Type
-}
-
-// A Registry is used to store and retrieve codecs for types and interfaces. This type is the main
-// typed passed around and Encoders and Decoders are constructed from it.
-type Registry struct {
-	typeEncoders map[reflect.Type]ValueEncoder
-	typeDecoders map[reflect.Type]ValueDecoder
-
-	interfaceEncoders []interfaceValueEncoder
-	interfaceDecoders []interfaceValueDecoder
-
-	kindEncoders map[reflect.Kind]ValueEncoder
-	kindDecoders map[reflect.Kind]ValueDecoder
-
-	typeMap map[bsontype.Type]reflect.Type
-
-	mu sync.RWMutex
-}
-
-// NewRegistryBuilder creates a new empty RegistryBuilder.
-func NewRegistryBuilder() *RegistryBuilder {
-	return &RegistryBuilder{
-		typeEncoders: make(map[reflect.Type]ValueEncoder),
-		typeDecoders: make(map[reflect.Type]ValueDecoder),
-
-		interfaceEncoders: make([]interfaceValueEncoder, 0),
-		interfaceDecoders: make([]interfaceValueDecoder, 0),
-
-		kindEncoders: make(map[reflect.Kind]ValueEncoder),
-		kindDecoders: make(map[reflect.Kind]ValueDecoder),
-
-		typeMap: make(map[bsontype.Type]reflect.Type),
-	}
-}
-
-func buildDefaultRegistry() *Registry {
-	rb := NewRegistryBuilder()
-	defaultValueEncoders.RegisterDefaultEncoders(rb)
-	defaultValueDecoders.RegisterDefaultDecoders(rb)
-	return rb.Build()
-}
-
-// RegisterCodec will register the provided ValueCodec for the provided type.
-func (rb *RegistryBuilder) RegisterCodec(t reflect.Type, codec ValueCodec) *RegistryBuilder {
-	rb.RegisterEncoder(t, codec)
-	rb.RegisterDecoder(t, codec)
-	return rb
-}
-
-// RegisterEncoder will register the provided ValueEncoder to the provided type.
-//
-// The type registered will be used directly, so an encoder can be registered for a type and a
-// different encoder can be registered for a pointer to that type.
-func (rb *RegistryBuilder) RegisterEncoder(t reflect.Type, enc ValueEncoder) *RegistryBuilder {
-	if t == tEmpty {
-		rb.typeEncoders[t] = enc
-		return rb
-	}
-	switch t.Kind() {
-	case reflect.Interface:
-		for idx, ir := range rb.interfaceEncoders {
-			if ir.i == t {
-				rb.interfaceEncoders[idx].ve = enc
-				return rb
-			}
-		}
-
-		rb.interfaceEncoders = append(rb.interfaceEncoders, interfaceValueEncoder{i: t, ve: enc})
-	default:
-		rb.typeEncoders[t] = enc
-	}
-	return rb
-}
-
-// RegisterDecoder will register the provided ValueDecoder to the provided type.
-//
-// The type registered will be used directly, so a decoder can be registered for a type and a
-// different decoder can be registered for a pointer to that type.
-func (rb *RegistryBuilder) RegisterDecoder(t reflect.Type, dec ValueDecoder) *RegistryBuilder {
-	if t == nil {
-		rb.typeDecoders[nil] = dec
-		return rb
-	}
-	if t == tEmpty {
-		rb.typeDecoders[t] = dec
-		return rb
-	}
-	switch t.Kind() {
-	case reflect.Interface:
-		for idx, ir := range rb.interfaceDecoders {
-			if ir.i == t {
-				rb.interfaceDecoders[idx].vd = dec
-				return rb
-			}
-		}
-
-		rb.interfaceDecoders = append(rb.interfaceDecoders, interfaceValueDecoder{i: t, vd: dec})
-	default:
-		rb.typeDecoders[t] = dec
-	}
-	return rb
-}
-
-// RegisterDefaultEncoder will registr the provided ValueEncoder to the provided
-// kind.
-func (rb *RegistryBuilder) RegisterDefaultEncoder(kind reflect.Kind, enc ValueEncoder) *RegistryBuilder {
-	rb.kindEncoders[kind] = enc
-	return rb
-}
-
-// RegisterDefaultDecoder will register the provided ValueDecoder to the
-// provided kind.
-func (rb *RegistryBuilder) RegisterDefaultDecoder(kind reflect.Kind, dec ValueDecoder) *RegistryBuilder {
-	rb.kindDecoders[kind] = dec
-	return rb
-}
-
-// RegisterTypeMapEntry will register the provided type to the BSON type. The primary usage for this
-// mapping is decoding situations where an empty interface is used and a default type needs to be
-// created and decoded into.
-//
-// NOTE: It is unlikely that registering a type for BSON Embedded Document is actually desired. By
-// registering a type map entry for BSON Embedded Document the type registered will be used in any
-// case where a BSON Embedded Document will be decoded into an empty interface. For example, if you
-// register primitive.M, the EmptyInterface decoder will always use primitive.M, even if an ancestor
-// was a primitive.D.
-func (rb *RegistryBuilder) RegisterTypeMapEntry(bt bsontype.Type, rt reflect.Type) *RegistryBuilder {
-	rb.typeMap[bt] = rt
-	return rb
-}
-
-// Build creates a Registry from the current state of this RegistryBuilder.
-func (rb *RegistryBuilder) Build() *Registry {
-	registry := new(Registry)
-
-	registry.typeEncoders = make(map[reflect.Type]ValueEncoder)
-	for t, enc := range rb.typeEncoders {
-		registry.typeEncoders[t] = enc
-	}
-
-	registry.typeDecoders = make(map[reflect.Type]ValueDecoder)
-	for t, dec := range rb.typeDecoders {
-		registry.typeDecoders[t] = dec
-	}
-
-	registry.interfaceEncoders = make([]interfaceValueEncoder, len(rb.interfaceEncoders))
-	copy(registry.interfaceEncoders, rb.interfaceEncoders)
-
-	registry.interfaceDecoders = make([]interfaceValueDecoder, len(rb.interfaceDecoders))
-	copy(registry.interfaceDecoders, rb.interfaceDecoders)
-
-	registry.kindEncoders = make(map[reflect.Kind]ValueEncoder)
-	for kind, enc := range rb.kindEncoders {
-		registry.kindEncoders[kind] = enc
-	}
-
-	registry.kindDecoders = make(map[reflect.Kind]ValueDecoder)
-	for kind, dec := range rb.kindDecoders {
-		registry.kindDecoders[kind] = dec
-	}
-
-	registry.typeMap = make(map[bsontype.Type]reflect.Type)
-	for bt, rt := range rb.typeMap {
-		registry.typeMap[bt] = rt
-	}
-
-	return registry
-}
-
-// LookupEncoder will inspect the registry for an encoder that satisfies the
-// type provided. An encoder registered for a specific type will take
-// precedence over an encoder registered for an interface the type satisfies,
-// which takes precedence over an encoder for the reflect.Kind of the value. If
-// no encoder can be found, an error is returned.
-func (r *Registry) LookupEncoder(t reflect.Type) (ValueEncoder, error) {
-	encodererr := ErrNoEncoder{Type: t}
-	r.mu.RLock()
-	enc, found := r.lookupTypeEncoder(t)
-	r.mu.RUnlock()
-	if found {
-		if enc == nil {
-			return nil, ErrNoEncoder{Type: t}
-		}
-		return enc, nil
-	}
-
-	enc, found = r.lookupInterfaceEncoder(t)
-	if found {
-		r.mu.Lock()
-		r.typeEncoders[t] = enc
-		r.mu.Unlock()
-		return enc, nil
-	}
-
-	if t == nil {
-		r.mu.Lock()
-		r.typeEncoders[t] = nil
-		r.mu.Unlock()
-		return nil, encodererr
-	}
-
-	enc, found = r.kindEncoders[t.Kind()]
-	if !found {
-		r.mu.Lock()
-		r.typeEncoders[t] = nil
-		r.mu.Unlock()
-		return nil, encodererr
-	}
-
-	r.mu.Lock()
-	r.typeEncoders[t] = enc
-	r.mu.Unlock()
-	return enc, nil
-}
-
-func (r *Registry) lookupTypeEncoder(t reflect.Type) (ValueEncoder, bool) {
-	enc, found := r.typeEncoders[t]
-	return enc, found
-}
-
-func (r *Registry) lookupInterfaceEncoder(t reflect.Type) (ValueEncoder, bool) {
-	if t == nil {
-		return nil, false
-	}
-	for _, ienc := range r.interfaceEncoders {
-		if !t.Implements(ienc.i) {
-			continue
-		}
-
-		return ienc.ve, true
-	}
-	return nil, false
-}
-
-// LookupDecoder will inspect the registry for a decoder that satisfies the
-// type provided. A decoder registered for a specific type will take
-// precedence over a decoder registered for an interface the type satisfies,
-// which takes precedence over a decoder for the reflect.Kind of the value. If
-// no decoder can be found, an error is returned.
-func (r *Registry) LookupDecoder(t reflect.Type) (ValueDecoder, error) {
-	if t == nil {
-		return nil, ErrNilType
-	}
-	decodererr := ErrNoDecoder{Type: t}
-	r.mu.RLock()
-	dec, found := r.lookupTypeDecoder(t)
-	r.mu.RUnlock()
-	if found {
-		if dec == nil {
-			return nil, ErrNoDecoder{Type: t}
-		}
-		return dec, nil
-	}
-
-	dec, found = r.lookupInterfaceDecoder(t)
-	if found {
-		r.mu.Lock()
-		r.typeDecoders[t] = dec
-		r.mu.Unlock()
-		return dec, nil
-	}
-
-	dec, found = r.kindDecoders[t.Kind()]
-	if !found {
-		r.mu.Lock()
-		r.typeDecoders[t] = nil
-		r.mu.Unlock()
-		return nil, decodererr
-	}
-
-	r.mu.Lock()
-	r.typeDecoders[t] = dec
-	r.mu.Unlock()
-	return dec, nil
-}
-
-func (r *Registry) lookupTypeDecoder(t reflect.Type) (ValueDecoder, bool) {
-	dec, found := r.typeDecoders[t]
-	return dec, found
-}
-
-func (r *Registry) lookupInterfaceDecoder(t reflect.Type) (ValueDecoder, bool) {
-	for _, idec := range r.interfaceDecoders {
-		if !t.Implements(idec.i) && !reflect.PtrTo(t).Implements(idec.i) {
-			continue
-		}
-
-		return idec.vd, true
-	}
-	return nil, false
-}
-
-// LookupTypeMapEntry inspects the registry's type map for a Go type for the corresponding BSON
-// type. If no type is found, ErrNoTypeMapEntry is returned.
-func (r *Registry) LookupTypeMapEntry(bt bsontype.Type) (reflect.Type, error) {
-	t, ok := r.typeMap[bt]
-	if !ok || t == nil {
-		return nil, ErrNoTypeMapEntry{Type: bt}
-	}
-	return t, nil
-}
-
-type interfaceValueEncoder struct {
-	i  reflect.Type
-	ve ValueEncoder
-}
-
-type interfaceValueDecoder struct {
-	i  reflect.Type
-	vd ValueDecoder
-}

+ 0 - 359
qyxy/src/mgoutil/go.mongodb.org/mongo-driver/bson/bsoncodec/registry_test.go

@@ -1,359 +0,0 @@
-// Copyright (C) MongoDB, Inc. 2017-present.
-//
-// Licensed under the Apache License, Version 2.0 (the "License"); you may
-// not use this file except in compliance with the License. You may obtain
-// a copy of the License at http://www.apache.org/licenses/LICENSE-2.0
-
-package bsoncodec
-
-import (
-	"reflect"
-	"testing"
-
-	"github.com/google/go-cmp/cmp"
-	"go.mongodb.org/mongo-driver/bson/bsonrw"
-	"go.mongodb.org/mongo-driver/bson/bsontype"
-)
-
-func TestRegistry(t *testing.T) {
-	t.Run("Register", func(t *testing.T) {
-		fc1, fc2, fc3, fc4 := new(fakeCodec), new(fakeCodec), new(fakeCodec), new(fakeCodec)
-		t.Run("interface", func(t *testing.T) {
-			var t1f *testInterface1
-			var t2f *testInterface2
-			var t4f *testInterface4
-			ips := []interfaceValueEncoder{
-				{i: reflect.TypeOf(t1f).Elem(), ve: fc1},
-				{i: reflect.TypeOf(t2f).Elem(), ve: fc2},
-				{i: reflect.TypeOf(t1f).Elem(), ve: fc3},
-				{i: reflect.TypeOf(t4f).Elem(), ve: fc4},
-			}
-			want := []interfaceValueEncoder{
-				{i: reflect.TypeOf(t1f).Elem(), ve: fc3},
-				{i: reflect.TypeOf(t2f).Elem(), ve: fc2},
-				{i: reflect.TypeOf(t4f).Elem(), ve: fc4},
-			}
-			rb := NewRegistryBuilder()
-			for _, ip := range ips {
-				rb.RegisterEncoder(ip.i, ip.ve)
-			}
-			got := rb.interfaceEncoders
-			if !cmp.Equal(got, want, cmp.AllowUnexported(interfaceValueEncoder{}, fakeCodec{}), cmp.Comparer(typeComparer)) {
-				t.Errorf("The registered interfaces are not correct. got %v; want %v", got, want)
-			}
-		})
-		t.Run("type", func(t *testing.T) {
-			ft1, ft2, ft4 := fakeType1{}, fakeType2{}, fakeType4{}
-			rb := NewRegistryBuilder().
-				RegisterEncoder(reflect.TypeOf(ft1), fc1).
-				RegisterEncoder(reflect.TypeOf(ft2), fc2).
-				RegisterEncoder(reflect.TypeOf(ft1), fc3).
-				RegisterEncoder(reflect.TypeOf(ft4), fc4)
-			want := []struct {
-				t reflect.Type
-				c ValueEncoder
-			}{
-				{reflect.TypeOf(ft1), fc3},
-				{reflect.TypeOf(ft2), fc2},
-				{reflect.TypeOf(ft4), fc4},
-			}
-			got := rb.typeEncoders
-			for _, s := range want {
-				wantT, wantC := s.t, s.c
-				gotC, exists := got[wantT]
-				if !exists {
-					t.Errorf("Did not find type in the type registry: %v", wantT)
-				}
-				if !cmp.Equal(gotC, wantC, cmp.AllowUnexported(fakeCodec{})) {
-					t.Errorf("Codecs did not match. got %#v; want %#v", gotC, wantC)
-				}
-			}
-		})
-		t.Run("kind", func(t *testing.T) {
-			k1, k2, k4 := reflect.Struct, reflect.Slice, reflect.Map
-			rb := NewRegistryBuilder().
-				RegisterDefaultEncoder(k1, fc1).
-				RegisterDefaultEncoder(k2, fc2).
-				RegisterDefaultEncoder(k1, fc3).
-				RegisterDefaultEncoder(k4, fc4)
-			want := []struct {
-				k reflect.Kind
-				c ValueEncoder
-			}{
-				{k1, fc3},
-				{k2, fc2},
-				{k4, fc4},
-			}
-			got := rb.kindEncoders
-			for _, s := range want {
-				wantK, wantC := s.k, s.c
-				gotC, exists := got[wantK]
-				if !exists {
-					t.Errorf("Did not find kind in the kind registry: %v", wantK)
-				}
-				if !cmp.Equal(gotC, wantC, cmp.AllowUnexported(fakeCodec{})) {
-					t.Errorf("Codecs did not match. got %#v; want %#v", gotC, wantC)
-				}
-			}
-		})
-		t.Run("RegisterDefault", func(t *testing.T) {
-			t.Run("MapCodec", func(t *testing.T) {
-				codec := fakeCodec{num: 1}
-				codec2 := fakeCodec{num: 2}
-				rb := NewRegistryBuilder()
-				rb.RegisterDefaultEncoder(reflect.Map, codec)
-				if rb.kindEncoders[reflect.Map] != codec {
-					t.Errorf("Did not properly set the map codec. got %v; want %v", rb.kindEncoders[reflect.Map], codec)
-				}
-				rb.RegisterDefaultEncoder(reflect.Map, codec2)
-				if rb.kindEncoders[reflect.Map] != codec2 {
-					t.Errorf("Did not properly set the map codec. got %v; want %v", rb.kindEncoders[reflect.Map], codec2)
-				}
-			})
-			t.Run("StructCodec", func(t *testing.T) {
-				codec := fakeCodec{num: 1}
-				codec2 := fakeCodec{num: 2}
-				rb := NewRegistryBuilder()
-				rb.RegisterDefaultEncoder(reflect.Struct, codec)
-				if rb.kindEncoders[reflect.Struct] != codec {
-					t.Errorf("Did not properly set the struct codec. got %v; want %v", rb.kindEncoders[reflect.Struct], codec)
-				}
-				rb.RegisterDefaultEncoder(reflect.Struct, codec2)
-				if rb.kindEncoders[reflect.Struct] != codec2 {
-					t.Errorf("Did not properly set the struct codec. got %v; want %v", rb.kindEncoders[reflect.Struct], codec2)
-				}
-			})
-			t.Run("SliceCodec", func(t *testing.T) {
-				codec := fakeCodec{num: 1}
-				codec2 := fakeCodec{num: 2}
-				rb := NewRegistryBuilder()
-				rb.RegisterDefaultEncoder(reflect.Slice, codec)
-				if rb.kindEncoders[reflect.Slice] != codec {
-					t.Errorf("Did not properly set the slice codec. got %v; want %v", rb.kindEncoders[reflect.Slice], codec)
-				}
-				rb.RegisterDefaultEncoder(reflect.Slice, codec2)
-				if rb.kindEncoders[reflect.Slice] != codec2 {
-					t.Errorf("Did not properly set the slice codec. got %v; want %v", rb.kindEncoders[reflect.Slice], codec2)
-				}
-			})
-			t.Run("ArrayCodec", func(t *testing.T) {
-				codec := fakeCodec{num: 1}
-				codec2 := fakeCodec{num: 2}
-				rb := NewRegistryBuilder()
-				rb.RegisterDefaultEncoder(reflect.Array, codec)
-				if rb.kindEncoders[reflect.Array] != codec {
-					t.Errorf("Did not properly set the slice codec. got %v; want %v", rb.kindEncoders[reflect.Array], codec)
-				}
-				rb.RegisterDefaultEncoder(reflect.Array, codec2)
-				if rb.kindEncoders[reflect.Array] != codec2 {
-					t.Errorf("Did not properly set the slice codec. got %v; want %v", rb.kindEncoders[reflect.Array], codec2)
-				}
-			})
-		})
-		t.Run("Lookup", func(t *testing.T) {
-			type Codec interface {
-				ValueEncoder
-				ValueDecoder
-			}
-
-			var arrinstance [12]int
-			arr := reflect.TypeOf(arrinstance)
-			slc := reflect.TypeOf(make([]int, 12))
-			m := reflect.TypeOf(make(map[string]int))
-			strct := reflect.TypeOf(struct{ Foo string }{})
-			ft1 := reflect.PtrTo(reflect.TypeOf(fakeType1{}))
-			ft2 := reflect.TypeOf(fakeType2{})
-			ft3 := reflect.TypeOf(fakeType5(func(string, string) string { return "fakeType5" }))
-			ti2 := reflect.TypeOf((*testInterface2)(nil)).Elem()
-			fc1, fc2, fc4 := fakeCodec{num: 1}, fakeCodec{num: 2}, fakeCodec{num: 4}
-			fsc, fslcc, fmc := new(fakeStructCodec), new(fakeSliceCodec), new(fakeMapCodec)
-			pc := NewPointerCodec()
-			reg := NewRegistryBuilder().
-				RegisterEncoder(ft1, fc1).
-				RegisterEncoder(ft2, fc2).
-				RegisterEncoder(ti2, fc4).
-				RegisterDefaultEncoder(reflect.Struct, fsc).
-				RegisterDefaultEncoder(reflect.Slice, fslcc).
-				RegisterDefaultEncoder(reflect.Array, fslcc).
-				RegisterDefaultEncoder(reflect.Map, fmc).
-				RegisterDefaultEncoder(reflect.Ptr, pc).
-				RegisterDecoder(ft1, fc1).
-				RegisterDecoder(ft2, fc2).
-				RegisterDecoder(ti2, fc4).
-				RegisterDefaultDecoder(reflect.Struct, fsc).
-				RegisterDefaultDecoder(reflect.Slice, fslcc).
-				RegisterDefaultDecoder(reflect.Array, fslcc).
-				RegisterDefaultDecoder(reflect.Map, fmc).
-				RegisterDefaultDecoder(reflect.Ptr, pc).
-				Build()
-
-			testCases := []struct {
-				name      string
-				t         reflect.Type
-				wantcodec Codec
-				wanterr   error
-				testcache bool
-			}{
-				{
-					"type registry (pointer)",
-					ft1,
-					fc1,
-					nil,
-					false,
-				},
-				{
-					"type registry (non-pointer)",
-					ft2,
-					fc2,
-					nil,
-					false,
-				},
-				{
-					"interface registry",
-					ti2,
-					fc4,
-					nil,
-					true,
-				},
-				{
-					"default struct codec (pointer)",
-					reflect.PtrTo(strct),
-					pc,
-					nil,
-					false,
-				},
-				{
-					"default struct codec (non-pointer)",
-					strct,
-					fsc,
-					nil,
-					false,
-				},
-				{
-					"default array codec",
-					arr,
-					fslcc,
-					nil,
-					false,
-				},
-				{
-					"default slice codec",
-					slc,
-					fslcc,
-					nil,
-					false,
-				},
-				{
-					"default map",
-					m,
-					fmc,
-					nil,
-					false,
-				},
-				{
-					"map non-string key",
-					reflect.TypeOf(map[int]int{}),
-					fmc,
-					nil,
-					false,
-				},
-				{
-					"No Codec Registered",
-					ft3,
-					nil,
-					ErrNoEncoder{Type: ft3},
-					false,
-				},
-			}
-
-			allowunexported := cmp.AllowUnexported(fakeCodec{}, fakeStructCodec{}, fakeSliceCodec{}, fakeMapCodec{})
-			comparepc := func(pc1, pc2 *PointerCodec) bool { return true }
-			for _, tc := range testCases {
-				t.Run(tc.name, func(t *testing.T) {
-					t.Run("Encoder", func(t *testing.T) {
-						gotcodec, goterr := reg.LookupEncoder(tc.t)
-						if !cmp.Equal(goterr, tc.wanterr, cmp.Comparer(compareErrors)) {
-							t.Errorf("Errors did not match. got %v; want %v", goterr, tc.wanterr)
-						}
-						if !cmp.Equal(gotcodec, tc.wantcodec, allowunexported, cmp.Comparer(comparepc)) {
-							t.Errorf("Codecs did not match. got %v; want %v", gotcodec, tc.wantcodec)
-						}
-					})
-					t.Run("Decoder", func(t *testing.T) {
-						var wanterr error
-						if ene, ok := tc.wanterr.(ErrNoEncoder); ok {
-							wanterr = ErrNoDecoder{Type: ene.Type}
-						} else {
-							wanterr = tc.wanterr
-						}
-						gotcodec, goterr := reg.LookupDecoder(tc.t)
-						if !cmp.Equal(goterr, wanterr, cmp.Comparer(compareErrors)) {
-							t.Errorf("Errors did not match. got %v; want %v", goterr, wanterr)
-						}
-						if !cmp.Equal(gotcodec, tc.wantcodec, allowunexported, cmp.Comparer(comparepc)) {
-							t.Errorf("Codecs did not match. got %v; want %v", gotcodec, tc.wantcodec)
-							t.Errorf("Codecs did not match. got %T; want %T", gotcodec, tc.wantcodec)
-						}
-					})
-				})
-			}
-		})
-	})
-	t.Run("Type Map", func(t *testing.T) {
-		reg := NewRegistryBuilder().
-			RegisterTypeMapEntry(bsontype.String, reflect.TypeOf(string(""))).
-			RegisterTypeMapEntry(bsontype.Int32, reflect.TypeOf(int(0))).
-			Build()
-
-		var got, want reflect.Type
-
-		want = reflect.TypeOf(string(""))
-		got, err := reg.LookupTypeMapEntry(bsontype.String)
-		noerr(t, err)
-		if got != want {
-			t.Errorf("Did not get expected type. got %v; want %v", got, want)
-		}
-
-		want = reflect.TypeOf(int(0))
-		got, err = reg.LookupTypeMapEntry(bsontype.Int32)
-		noerr(t, err)
-		if got != want {
-			t.Errorf("Did not get expected type. got %v; want %v", got, want)
-		}
-
-		want = nil
-		wanterr := ErrNoTypeMapEntry{Type: bsontype.ObjectID}
-		got, err = reg.LookupTypeMapEntry(bsontype.ObjectID)
-		if err != wanterr {
-			t.Errorf("Did not get expected error. got %v; want %v", err, wanterr)
-		}
-		if got != want {
-			t.Errorf("Did not get expected type. got %v; want %v", got, want)
-		}
-	})
-}
-
-type fakeType1 struct{ b bool }
-type fakeType2 struct{ b bool }
-type fakeType3 struct{ b bool }
-type fakeType4 struct{ b bool }
-type fakeType5 func(string, string) string
-type fakeStructCodec struct{ fakeCodec }
-type fakeSliceCodec struct{ fakeCodec }
-type fakeMapCodec struct{ fakeCodec }
-
-type fakeCodec struct{ num int }
-
-func (fc fakeCodec) EncodeValue(EncodeContext, bsonrw.ValueWriter, reflect.Value) error {
-	return nil
-}
-func (fc fakeCodec) DecodeValue(DecodeContext, bsonrw.ValueReader, reflect.Value) error {
-	return nil
-}
-
-type testInterface1 interface{ test1() }
-type testInterface2 interface{ test2() }
-type testInterface3 interface{ test3() }
-type testInterface4 interface{ test4() }
-
-func typeComparer(i1, i2 reflect.Type) bool { return i1 == i2 }

+ 0 - 367
qyxy/src/mgoutil/go.mongodb.org/mongo-driver/bson/bsoncodec/struct_codec.go

@@ -1,367 +0,0 @@
-// Copyright (C) MongoDB, Inc. 2017-present.
-//
-// Licensed under the Apache License, Version 2.0 (the "License"); you may
-// not use this file except in compliance with the License. You may obtain
-// a copy of the License at http://www.apache.org/licenses/LICENSE-2.0
-
-package bsoncodec
-
-import (
-	"errors"
-	"fmt"
-	"reflect"
-	"strings"
-	"sync"
-
-	"go.mongodb.org/mongo-driver/bson/bsonrw"
-	"go.mongodb.org/mongo-driver/bson/bsontype"
-)
-
-var defaultStructCodec = &StructCodec{
-	cache:  make(map[reflect.Type]*structDescription),
-	parser: DefaultStructTagParser,
-}
-
-// Zeroer allows custom struct types to implement a report of zero
-// state. All struct types that don't implement Zeroer or where IsZero
-// returns false are considered to be not zero.
-type Zeroer interface {
-	IsZero() bool
-}
-
-// StructCodec is the Codec used for struct values.
-type StructCodec struct {
-	cache  map[reflect.Type]*structDescription
-	l      sync.RWMutex
-	parser StructTagParser
-}
-
-var _ ValueEncoder = &StructCodec{}
-var _ ValueDecoder = &StructCodec{}
-
-// NewStructCodec returns a StructCodec that uses p for struct tag parsing.
-func NewStructCodec(p StructTagParser) (*StructCodec, error) {
-	if p == nil {
-		return nil, errors.New("a StructTagParser must be provided to NewStructCodec")
-	}
-
-	return &StructCodec{
-		cache:  make(map[reflect.Type]*structDescription),
-		parser: p,
-	}, nil
-}
-
-// EncodeValue handles encoding generic struct types.
-func (sc *StructCodec) EncodeValue(r EncodeContext, vw bsonrw.ValueWriter, val reflect.Value) error {
-	if !val.IsValid() || val.Kind() != reflect.Struct {
-		return ValueEncoderError{Name: "StructCodec.EncodeValue", Kinds: []reflect.Kind{reflect.Struct}, Received: val}
-	}
-
-	sd, err := sc.describeStruct(r.Registry, val.Type())
-	if err != nil {
-		return err
-	}
-
-	dw, err := vw.WriteDocument()
-	if err != nil {
-		return err
-	}
-	var rv reflect.Value
-	for _, desc := range sd.fl {
-		if desc.inline == nil {
-			rv = val.Field(desc.idx)
-		} else {
-			rv = val.FieldByIndex(desc.inline)
-		}
-
-		if desc.encoder == nil {
-			return ErrNoEncoder{Type: rv.Type()}
-		}
-
-		encoder := desc.encoder
-
-		iszero := sc.isZero
-		if iz, ok := encoder.(CodecZeroer); ok {
-			iszero = iz.IsTypeZero
-		}
-
-		if desc.omitEmpty && iszero(rv.Interface()) {
-			continue
-		}
-
-		vw2, err := dw.WriteDocumentElement(desc.name)
-		if err != nil {
-			return err
-		}
-
-		ectx := EncodeContext{Registry: r.Registry, MinSize: desc.minSize}
-		err = encoder.EncodeValue(ectx, vw2, rv)
-		if err != nil {
-			return err
-		}
-	}
-
-	if sd.inlineMap >= 0 {
-		rv := val.Field(sd.inlineMap)
-		collisionFn := func(key string) bool {
-			_, exists := sd.fm[key]
-			return exists
-		}
-
-		return defaultValueEncoders.mapEncodeValue(r, dw, rv, collisionFn)
-	}
-
-	return dw.WriteDocumentEnd()
-}
-
-// DecodeValue implements the Codec interface.
-// By default, map types in val will not be cleared. If a map has existing key/value pairs, it will be extended with the new ones from vr.
-// For slices, the decoder will set the length of the slice to zero and append all elements. The underlying array will not be cleared.
-func (sc *StructCodec) DecodeValue(r DecodeContext, vr bsonrw.ValueReader, val reflect.Value) error {
-	if !val.CanSet() || val.Kind() != reflect.Struct {
-		return ValueDecoderError{Name: "StructCodec.DecodeValue", Kinds: []reflect.Kind{reflect.Struct}, Received: val}
-	}
-
-	switch vr.Type() {
-	case bsontype.Type(0), bsontype.EmbeddedDocument:
-	default:
-		return fmt.Errorf("cannot decode %v into a %s", vr.Type(), val.Type())
-	}
-
-	sd, err := sc.describeStruct(r.Registry, val.Type())
-	if err != nil {
-		return err
-	}
-
-	var decoder ValueDecoder
-	var inlineMap reflect.Value
-	if sd.inlineMap >= 0 {
-		inlineMap = val.Field(sd.inlineMap)
-		if inlineMap.IsNil() {
-			inlineMap.Set(reflect.MakeMap(inlineMap.Type()))
-		}
-		decoder, err = r.LookupDecoder(inlineMap.Type().Elem())
-		if err != nil {
-			return err
-		}
-	}
-
-	dr, err := vr.ReadDocument()
-	if err != nil {
-		return err
-	}
-
-	for {
-		name, vr, err := dr.ReadElement()
-		if err == bsonrw.ErrEOD {
-			break
-		}
-		if err != nil {
-			return err
-		}
-
-		fd, exists := sd.fm[name]
-		if !exists {
-			// if the original name isn't found in the struct description, try again with the name in lowercase
-			// this could match if a BSON tag isn't specified because by default, describeStruct lowercases all field
-			// names
-			fd, exists = sd.fm[strings.ToLower(name)]
-		}
-
-		if !exists {
-			if sd.inlineMap < 0 {
-				// The encoding/json package requires a flag to return on error for non-existent fields.
-				// This functionality seems appropriate for the struct codec.
-				err = vr.Skip()
-				if err != nil {
-					return err
-				}
-				continue
-			}
-
-			elem := reflect.New(inlineMap.Type().Elem()).Elem()
-			err = decoder.DecodeValue(r, vr, elem)
-			if err != nil {
-				return err
-			}
-			inlineMap.SetMapIndex(reflect.ValueOf(name), elem)
-			continue
-		}
-
-		var field reflect.Value
-		if fd.inline == nil {
-			field = val.Field(fd.idx)
-		} else {
-			field = val.FieldByIndex(fd.inline)
-		}
-
-		if !field.CanSet() { // Being settable is a super set of being addressable.
-			return fmt.Errorf("cannot decode element '%s' into field %v; it is not settable", name, field)
-		}
-		if field.Kind() == reflect.Ptr && field.IsNil() {
-			field.Set(reflect.New(field.Type().Elem()))
-		}
-		field = field.Addr()
-
-		dctx := DecodeContext{Registry: r.Registry, Truncate: fd.truncate || r.Truncate}
-		if fd.decoder == nil {
-			return ErrNoDecoder{Type: field.Elem().Type()}
-		}
-
-		if decoder, ok := fd.decoder.(ValueDecoder); ok {
-			err = decoder.DecodeValue(dctx, vr, field.Elem())
-			if err != nil {
-				return err
-			}
-			continue
-		}
-		err = fd.decoder.DecodeValue(dctx, vr, field)
-		if err != nil {
-			return err
-		}
-	}
-
-	return nil
-}
-
-func (sc *StructCodec) isZero(i interface{}) bool {
-	v := reflect.ValueOf(i)
-
-	// check the value validity
-	if !v.IsValid() {
-		return true
-	}
-
-	if z, ok := v.Interface().(Zeroer); ok && (v.Kind() != reflect.Ptr || !v.IsNil()) {
-		return z.IsZero()
-	}
-
-	switch v.Kind() {
-	case reflect.Array, reflect.Map, reflect.Slice, reflect.String:
-		return v.Len() == 0
-	case reflect.Bool:
-		return !v.Bool()
-	case reflect.Int, reflect.Int8, reflect.Int16, reflect.Int32, reflect.Int64:
-		return v.Int() == 0
-	case reflect.Uint, reflect.Uint8, reflect.Uint16, reflect.Uint32, reflect.Uint64, reflect.Uintptr:
-		return v.Uint() == 0
-	case reflect.Float32, reflect.Float64:
-		return v.Float() == 0
-	case reflect.Interface, reflect.Ptr:
-		return v.IsNil()
-	}
-
-	return false
-}
-
-type structDescription struct {
-	fm        map[string]fieldDescription
-	fl        []fieldDescription
-	inlineMap int
-}
-
-type fieldDescription struct {
-	name      string
-	idx       int
-	omitEmpty bool
-	minSize   bool
-	truncate  bool
-	inline    []int
-	encoder   ValueEncoder
-	decoder   ValueDecoder
-}
-
-func (sc *StructCodec) describeStruct(r *Registry, t reflect.Type) (*structDescription, error) {
-	// We need to analyze the struct, including getting the tags, collecting
-	// information about inlining, and create a map of the field name to the field.
-	sc.l.RLock()
-	ds, exists := sc.cache[t]
-	sc.l.RUnlock()
-	if exists {
-		return ds, nil
-	}
-
-	numFields := t.NumField()
-	sd := &structDescription{
-		fm:        make(map[string]fieldDescription, numFields),
-		fl:        make([]fieldDescription, 0, numFields),
-		inlineMap: -1,
-	}
-
-	for i := 0; i < numFields; i++ {
-		sf := t.Field(i)
-		if sf.PkgPath != "" {
-			// unexported, ignore
-			continue
-		}
-
-		encoder, err := r.LookupEncoder(sf.Type)
-		if err != nil {
-			encoder = nil
-		}
-		decoder, err := r.LookupDecoder(sf.Type)
-		if err != nil {
-			decoder = nil
-		}
-
-		description := fieldDescription{idx: i, encoder: encoder, decoder: decoder}
-
-		stags, err := sc.parser.ParseStructTags(sf)
-		if err != nil {
-			return nil, err
-		}
-		if stags.Skip {
-			continue
-		}
-		description.name = stags.Name
-		description.omitEmpty = stags.OmitEmpty
-		description.minSize = stags.MinSize
-		description.truncate = stags.Truncate
-
-		if stags.Inline {
-			switch sf.Type.Kind() {
-			case reflect.Map:
-				if sd.inlineMap >= 0 {
-					return nil, errors.New("(struct " + t.String() + ") multiple inline maps")
-				}
-				if sf.Type.Key() != tString {
-					return nil, errors.New("(struct " + t.String() + ") inline map must have a string keys")
-				}
-				sd.inlineMap = description.idx
-			case reflect.Struct:
-				inlinesf, err := sc.describeStruct(r, sf.Type)
-				if err != nil {
-					return nil, err
-				}
-				for _, fd := range inlinesf.fl {
-					if _, exists := sd.fm[fd.name]; exists {
-						return nil, fmt.Errorf("(struct %s) duplicated key %s", t.String(), fd.name)
-					}
-					if fd.inline == nil {
-						fd.inline = []int{i, fd.idx}
-					} else {
-						fd.inline = append([]int{i}, fd.inline...)
-					}
-					sd.fm[fd.name] = fd
-					sd.fl = append(sd.fl, fd)
-				}
-			default:
-				return nil, fmt.Errorf("(struct %s) inline fields must be either a struct or a map", t.String())
-			}
-			continue
-		}
-
-		if _, exists := sd.fm[description.name]; exists {
-			return nil, fmt.Errorf("struct %s) duplicated key %s", t.String(), description.name)
-		}
-
-		sd.fm[description.name] = description
-		sd.fl = append(sd.fl, description)
-	}
-
-	sc.l.Lock()
-	sc.cache[t] = sd
-	sc.l.Unlock()
-
-	return sd, nil
-}

+ 0 - 47
qyxy/src/mgoutil/go.mongodb.org/mongo-driver/bson/bsoncodec/struct_codec_test.go

@@ -1,47 +0,0 @@
-// Copyright (C) MongoDB, Inc. 2017-present.
-//
-// Licensed under the Apache License, Version 2.0 (the "License"); you may
-// not use this file except in compliance with the License. You may obtain
-// a copy of the License at http://www.apache.org/licenses/LICENSE-2.0
-
-package bsoncodec
-
-import (
-	"testing"
-	"time"
-
-	"github.com/stretchr/testify/assert"
-)
-
-func TestZeoerInterfaceUsedByDecoder(t *testing.T) {
-	enc := &StructCodec{}
-
-	// cases that are zero, because they are known types or pointers
-	var st *nonZeroer
-	assert.True(t, enc.isZero(st))
-	assert.True(t, enc.isZero(0))
-	assert.True(t, enc.isZero(false))
-
-	// cases that shouldn't be zero
-	st = &nonZeroer{value: false}
-	assert.False(t, enc.isZero(struct{ val bool }{val: true}))
-	assert.False(t, enc.isZero(struct{ val bool }{val: false}))
-	assert.False(t, enc.isZero(st))
-	st.value = true
-	assert.False(t, enc.isZero(st))
-
-	// a test to see if the interface impacts the outcome
-	z := zeroTest{}
-	assert.False(t, enc.isZero(z))
-
-	z.reportZero = true
-	assert.True(t, enc.isZero(z))
-
-	// *time.Time with nil should be zero
-	var tp *time.Time
-	assert.True(t, enc.isZero(tp))
-
-	// actually all zeroer if nil should also be zero
-	var zp *zeroTest
-	assert.True(t, enc.isZero(zp))
-}

+ 0 - 119
qyxy/src/mgoutil/go.mongodb.org/mongo-driver/bson/bsoncodec/struct_tag_parser.go

@@ -1,119 +0,0 @@
-// Copyright (C) MongoDB, Inc. 2017-present.
-//
-// Licensed under the Apache License, Version 2.0 (the "License"); you may
-// not use this file except in compliance with the License. You may obtain
-// a copy of the License at http://www.apache.org/licenses/LICENSE-2.0
-
-package bsoncodec
-
-import (
-	"reflect"
-	"strings"
-)
-
-// StructTagParser returns the struct tags for a given struct field.
-type StructTagParser interface {
-	ParseStructTags(reflect.StructField) (StructTags, error)
-}
-
-// StructTagParserFunc is an adapter that allows a generic function to be used
-// as a StructTagParser.
-type StructTagParserFunc func(reflect.StructField) (StructTags, error)
-
-// ParseStructTags implements the StructTagParser interface.
-func (stpf StructTagParserFunc) ParseStructTags(sf reflect.StructField) (StructTags, error) {
-	return stpf(sf)
-}
-
-// StructTags represents the struct tag fields that the StructCodec uses during
-// the encoding and decoding process.
-//
-// In the case of a struct, the lowercased field name is used as the key for each exported
-// field but this behavior may be changed using a struct tag. The tag may also contain flags to
-// adjust the marshalling behavior for the field.
-//
-// The properties are defined below:
-//
-//     OmitEmpty  Only include the field if it's not set to the zero value for the type or to
-//                empty slices or maps.
-//
-//     MinSize    Marshal an integer of a type larger than 32 bits value as an int32, if that's
-//                feasible while preserving the numeric value.
-//
-//     Truncate   When unmarshaling a BSON double, it is permitted to lose precision to fit within
-//                a float32.
-//
-//     Inline     Inline the field, which must be a struct or a map, causing all of its fields
-//                or keys to be processed as if they were part of the outer struct. For maps,
-//                keys must not conflict with the bson keys of other struct fields.
-//
-//     Skip       This struct field should be skipped. This is usually denoted by parsing a "-"
-//                for the name.
-//
-// TODO(skriptble): Add tags for undefined as nil and for null as nil.
-type StructTags struct {
-	Name      string
-	OmitEmpty bool
-	MinSize   bool
-	Truncate  bool
-	Inline    bool
-	Skip      bool
-}
-
-// DefaultStructTagParser is the StructTagParser used by the StructCodec by default.
-// It will handle the bson struct tag. See the documentation for StructTags to see
-// what each of the returned fields means.
-//
-// If there is no name in the struct tag fields, the struct field name is lowercased.
-// The tag formats accepted are:
-//
-//     "[<key>][,<flag1>[,<flag2>]]"
-//
-//     `(...) bson:"[<key>][,<flag1>[,<flag2>]]" (...)`
-//
-// An example:
-//
-//     type T struct {
-//         A bool
-//         B int    "myb"
-//         C string "myc,omitempty"
-//         D string `bson:",omitempty" json:"jsonkey"`
-//         E int64  ",minsize"
-//         F int64  "myf,omitempty,minsize"
-//     }
-//
-// A struct tag either consisting entirely of '-' or with a bson key with a
-// value consisting entirely of '-' will return a StructTags with Skip true and
-// the remaining fields will be their default values.
-var DefaultStructTagParser StructTagParserFunc = func(sf reflect.StructField) (StructTags, error) {
-	key := strings.ToLower(sf.Name)
-	tag, ok := sf.Tag.Lookup("bson")
-	if !ok && !strings.Contains(string(sf.Tag), ":") && len(sf.Tag) > 0 {
-		tag = string(sf.Tag)
-	}
-	var st StructTags
-	if tag == "-" {
-		st.Skip = true
-		return st, nil
-	}
-
-	for idx, str := range strings.Split(tag, ",") {
-		if idx == 0 && str != "" {
-			key = str
-		}
-		switch str {
-		case "omitempty":
-			st.OmitEmpty = true
-		case "minsize":
-			st.MinSize = true
-		case "truncate":
-			st.Truncate = true
-		case "inline":
-			st.Inline = true
-		}
-	}
-
-	st.Name = key
-
-	return st, nil
-}

+ 0 - 73
qyxy/src/mgoutil/go.mongodb.org/mongo-driver/bson/bsoncodec/struct_tag_parser_test.go

@@ -1,73 +0,0 @@
-// Copyright (C) MongoDB, Inc. 2017-present.
-//
-// Licensed under the Apache License, Version 2.0 (the "License"); you may
-// not use this file except in compliance with the License. You may obtain
-// a copy of the License at http://www.apache.org/licenses/LICENSE-2.0
-
-package bsoncodec
-
-import (
-	"reflect"
-	"testing"
-
-	"github.com/google/go-cmp/cmp"
-)
-
-func TestDefaultStructTagParser(t *testing.T) {
-	testCases := []struct {
-		name string
-		sf   reflect.StructField
-		want StructTags
-	}{
-		{
-			"no bson tag",
-			reflect.StructField{Name: "foo", Tag: reflect.StructTag("bar")},
-			StructTags{Name: "bar"},
-		},
-		{
-			"empty",
-			reflect.StructField{Name: "foo", Tag: reflect.StructTag("")},
-			StructTags{Name: "foo"},
-		},
-		{
-			"tag only dash",
-			reflect.StructField{Name: "foo", Tag: reflect.StructTag("-")},
-			StructTags{Skip: true},
-		},
-		{
-			"bson tag only dash",
-			reflect.StructField{Name: "foo", Tag: reflect.StructTag(`bson:"-"`)},
-			StructTags{Skip: true},
-		},
-		{
-			"all options",
-			reflect.StructField{Name: "foo", Tag: reflect.StructTag(`bar,omitempty,minsize,truncate,inline`)},
-			StructTags{Name: "bar", OmitEmpty: true, MinSize: true, Truncate: true, Inline: true},
-		},
-		{
-			"all options default name",
-			reflect.StructField{Name: "foo", Tag: reflect.StructTag(`,omitempty,minsize,truncate,inline`)},
-			StructTags{Name: "foo", OmitEmpty: true, MinSize: true, Truncate: true, Inline: true},
-		},
-		{
-			"bson tag all options",
-			reflect.StructField{Name: "foo", Tag: reflect.StructTag(`bson:"bar,omitempty,minsize,truncate,inline"`)},
-			StructTags{Name: "bar", OmitEmpty: true, MinSize: true, Truncate: true, Inline: true},
-		},
-		{
-			"bson tag all options default name",
-			reflect.StructField{Name: "foo", Tag: reflect.StructTag(`bson:",omitempty,minsize,truncate,inline"`)},
-			StructTags{Name: "foo", OmitEmpty: true, MinSize: true, Truncate: true, Inline: true},
-		},
-	}
-
-	for _, tc := range testCases {
-		t.Run(tc.name, func(t *testing.T) {
-			got, err := DefaultStructTagParser(tc.sf)
-			noerr(t, err)
-			if !cmp.Equal(got, tc.want) {
-				t.Errorf("Returned struct tags do not match. got %#v; want %#v", got, tc.want)
-			}
-		})
-	}
-}

+ 0 - 80
qyxy/src/mgoutil/go.mongodb.org/mongo-driver/bson/bsoncodec/types.go

@@ -1,80 +0,0 @@
-// Copyright (C) MongoDB, Inc. 2017-present.
-//
-// Licensed under the Apache License, Version 2.0 (the "License"); you may
-// not use this file except in compliance with the License. You may obtain
-// a copy of the License at http://www.apache.org/licenses/LICENSE-2.0
-
-package bsoncodec
-
-import (
-	"encoding/json"
-	"net/url"
-	"reflect"
-	"time"
-
-	"go.mongodb.org/mongo-driver/bson/primitive"
-	"go.mongodb.org/mongo-driver/x/bsonx/bsoncore"
-)
-
-var ptBool = reflect.TypeOf((*bool)(nil))
-var ptInt8 = reflect.TypeOf((*int8)(nil))
-var ptInt16 = reflect.TypeOf((*int16)(nil))
-var ptInt32 = reflect.TypeOf((*int32)(nil))
-var ptInt64 = reflect.TypeOf((*int64)(nil))
-var ptInt = reflect.TypeOf((*int)(nil))
-var ptUint8 = reflect.TypeOf((*uint8)(nil))
-var ptUint16 = reflect.TypeOf((*uint16)(nil))
-var ptUint32 = reflect.TypeOf((*uint32)(nil))
-var ptUint64 = reflect.TypeOf((*uint64)(nil))
-var ptUint = reflect.TypeOf((*uint)(nil))
-var ptFloat32 = reflect.TypeOf((*float32)(nil))
-var ptFloat64 = reflect.TypeOf((*float64)(nil))
-var ptString = reflect.TypeOf((*string)(nil))
-
-var tBool = reflect.TypeOf(false)
-var tFloat32 = reflect.TypeOf(float32(0))
-var tFloat64 = reflect.TypeOf(float64(0))
-var tInt = reflect.TypeOf(int(0))
-var tInt8 = reflect.TypeOf(int8(0))
-var tInt16 = reflect.TypeOf(int16(0))
-var tInt32 = reflect.TypeOf(int32(0))
-var tInt64 = reflect.TypeOf(int64(0))
-var tString = reflect.TypeOf("")
-var tTime = reflect.TypeOf(time.Time{})
-var tUint = reflect.TypeOf(uint(0))
-var tUint8 = reflect.TypeOf(uint8(0))
-var tUint16 = reflect.TypeOf(uint16(0))
-var tUint32 = reflect.TypeOf(uint32(0))
-var tUint64 = reflect.TypeOf(uint64(0))
-
-var tEmpty = reflect.TypeOf((*interface{})(nil)).Elem()
-var tByteSlice = reflect.TypeOf([]byte(nil))
-var tByte = reflect.TypeOf(byte(0x00))
-var tURL = reflect.TypeOf(url.URL{})
-var tJSONNumber = reflect.TypeOf(json.Number(""))
-
-var tValueMarshaler = reflect.TypeOf((*ValueMarshaler)(nil)).Elem()
-var tValueUnmarshaler = reflect.TypeOf((*ValueUnmarshaler)(nil)).Elem()
-var tMarshaler = reflect.TypeOf((*Marshaler)(nil)).Elem()
-var tUnmarshaler = reflect.TypeOf((*Unmarshaler)(nil)).Elem()
-var tProxy = reflect.TypeOf((*Proxy)(nil)).Elem()
-
-var tBinary = reflect.TypeOf(primitive.Binary{})
-var tUndefined = reflect.TypeOf(primitive.Undefined{})
-var tOID = reflect.TypeOf(primitive.ObjectID{})
-var tDateTime = reflect.TypeOf(primitive.DateTime(0))
-var tNull = reflect.TypeOf(primitive.Null{})
-var tRegex = reflect.TypeOf(primitive.Regex{})
-var tCodeWithScope = reflect.TypeOf(primitive.CodeWithScope{})
-var tDBPointer = reflect.TypeOf(primitive.DBPointer{})
-var tJavaScript = reflect.TypeOf(primitive.JavaScript(""))
-var tSymbol = reflect.TypeOf(primitive.Symbol(""))
-var tTimestamp = reflect.TypeOf(primitive.Timestamp{})
-var tDecimal = reflect.TypeOf(primitive.Decimal128{})
-var tMinKey = reflect.TypeOf(primitive.MinKey{})
-var tMaxKey = reflect.TypeOf(primitive.MaxKey{})
-var tD = reflect.TypeOf(primitive.D{})
-var tA = reflect.TypeOf(primitive.A{})
-var tE = reflect.TypeOf(primitive.E{})
-
-var tCoreDocument = reflect.TypeOf(bsoncore.Document{})

+ 0 - 33
qyxy/src/mgoutil/go.mongodb.org/mongo-driver/bson/bsonrw/bsonrw_test.go

@@ -1,33 +0,0 @@
-// Copyright (C) MongoDB, Inc. 2017-present.
-//
-// Licensed under the Apache License, Version 2.0 (the "License"); you may
-// not use this file except in compliance with the License. You may obtain
-// a copy of the License at http://www.apache.org/licenses/LICENSE-2.0
-
-package bsonrw
-
-import "testing"
-
-func compareErrors(err1, err2 error) bool {
-	if err1 == nil && err2 == nil {
-		return true
-	}
-
-	if err1 == nil || err2 == nil {
-		return false
-	}
-
-	if err1.Error() != err2.Error() {
-		return false
-	}
-
-	return true
-}
-
-func noerr(t *testing.T, err error) {
-	if err != nil {
-		t.Helper()
-		t.Errorf("Unexpected error: (%T)%v", err, err)
-		t.FailNow()
-	}
-}

+ 0 - 847
qyxy/src/mgoutil/go.mongodb.org/mongo-driver/bson/bsonrw/bsonrwtest/bsonrwtest.go

@@ -1,847 +0,0 @@
-// Copyright (C) MongoDB, Inc. 2017-present.
-//
-// Licensed under the Apache License, Version 2.0 (the "License"); you may
-// not use this file except in compliance with the License. You may obtain
-// a copy of the License at http://www.apache.org/licenses/LICENSE-2.0
-
-package bsonrwtest // import "go.mongodb.org/mongo-driver/bson/bsonrw/bsonrwtest"
-
-import (
-	"testing"
-
-	"go.mongodb.org/mongo-driver/bson/bsonrw"
-	"go.mongodb.org/mongo-driver/bson/bsontype"
-	"go.mongodb.org/mongo-driver/bson/primitive"
-	"go.mongodb.org/mongo-driver/x/bsonx/bsoncore"
-)
-
-var _ bsonrw.ValueReader = (*ValueReaderWriter)(nil)
-var _ bsonrw.ValueWriter = (*ValueReaderWriter)(nil)
-
-// Invoked is a type used to indicate what method was called last.
-type Invoked byte
-
-// These are the different methods that can be invoked.
-const (
-	Nothing Invoked = iota
-	ReadArray
-	ReadBinary
-	ReadBoolean
-	ReadDocument
-	ReadCodeWithScope
-	ReadDBPointer
-	ReadDateTime
-	ReadDecimal128
-	ReadDouble
-	ReadInt32
-	ReadInt64
-	ReadJavascript
-	ReadMaxKey
-	ReadMinKey
-	ReadNull
-	ReadObjectID
-	ReadRegex
-	ReadString
-	ReadSymbol
-	ReadTimestamp
-	ReadUndefined
-	ReadElement
-	ReadValue
-	WriteArray
-	WriteBinary
-	WriteBinaryWithSubtype
-	WriteBoolean
-	WriteCodeWithScope
-	WriteDBPointer
-	WriteDateTime
-	WriteDecimal128
-	WriteDouble
-	WriteInt32
-	WriteInt64
-	WriteJavascript
-	WriteMaxKey
-	WriteMinKey
-	WriteNull
-	WriteObjectID
-	WriteRegex
-	WriteString
-	WriteDocument
-	WriteSymbol
-	WriteTimestamp
-	WriteUndefined
-	WriteDocumentElement
-	WriteDocumentEnd
-	WriteArrayElement
-	WriteArrayEnd
-	Skip
-)
-
-func (i Invoked) String() string {
-	switch i {
-	case Nothing:
-		return "Nothing"
-	case ReadArray:
-		return "ReadArray"
-	case ReadBinary:
-		return "ReadBinary"
-	case ReadBoolean:
-		return "ReadBoolean"
-	case ReadDocument:
-		return "ReadDocument"
-	case ReadCodeWithScope:
-		return "ReadCodeWithScope"
-	case ReadDBPointer:
-		return "ReadDBPointer"
-	case ReadDateTime:
-		return "ReadDateTime"
-	case ReadDecimal128:
-		return "ReadDecimal128"
-	case ReadDouble:
-		return "ReadDouble"
-	case ReadInt32:
-		return "ReadInt32"
-	case ReadInt64:
-		return "ReadInt64"
-	case ReadJavascript:
-		return "ReadJavascript"
-	case ReadMaxKey:
-		return "ReadMaxKey"
-	case ReadMinKey:
-		return "ReadMinKey"
-	case ReadNull:
-		return "ReadNull"
-	case ReadObjectID:
-		return "ReadObjectID"
-	case ReadRegex:
-		return "ReadRegex"
-	case ReadString:
-		return "ReadString"
-	case ReadSymbol:
-		return "ReadSymbol"
-	case ReadTimestamp:
-		return "ReadTimestamp"
-	case ReadUndefined:
-		return "ReadUndefined"
-	case ReadElement:
-		return "ReadElement"
-	case ReadValue:
-		return "ReadValue"
-	case WriteArray:
-		return "WriteArray"
-	case WriteBinary:
-		return "WriteBinary"
-	case WriteBinaryWithSubtype:
-		return "WriteBinaryWithSubtype"
-	case WriteBoolean:
-		return "WriteBoolean"
-	case WriteCodeWithScope:
-		return "WriteCodeWithScope"
-	case WriteDBPointer:
-		return "WriteDBPointer"
-	case WriteDateTime:
-		return "WriteDateTime"
-	case WriteDecimal128:
-		return "WriteDecimal128"
-	case WriteDouble:
-		return "WriteDouble"
-	case WriteInt32:
-		return "WriteInt32"
-	case WriteInt64:
-		return "WriteInt64"
-	case WriteJavascript:
-		return "WriteJavascript"
-	case WriteMaxKey:
-		return "WriteMaxKey"
-	case WriteMinKey:
-		return "WriteMinKey"
-	case WriteNull:
-		return "WriteNull"
-	case WriteObjectID:
-		return "WriteObjectID"
-	case WriteRegex:
-		return "WriteRegex"
-	case WriteString:
-		return "WriteString"
-	case WriteDocument:
-		return "WriteDocument"
-	case WriteSymbol:
-		return "WriteSymbol"
-	case WriteTimestamp:
-		return "WriteTimestamp"
-	case WriteUndefined:
-		return "WriteUndefined"
-	case WriteDocumentElement:
-		return "WriteDocumentElement"
-	case WriteDocumentEnd:
-		return "WriteDocumentEnd"
-	case WriteArrayElement:
-		return "WriteArrayElement"
-	case WriteArrayEnd:
-		return "WriteArrayEnd"
-	default:
-		return "<unknown>"
-	}
-}
-
-// ValueReaderWriter is a test implementation of a bsonrw.ValueReader and bsonrw.ValueWriter
-type ValueReaderWriter struct {
-	T        *testing.T
-	Invoked  Invoked
-	Return   interface{} // Can be a primitive or a bsoncore.Value
-	BSONType bsontype.Type
-	Err      error
-	ErrAfter Invoked // error after this method is called
-	depth    uint64
-}
-
-// prevent infinite recursion.
-func (llvrw *ValueReaderWriter) checkdepth() {
-	llvrw.depth++
-	if llvrw.depth > 1000 {
-		panic("max depth exceeded")
-	}
-}
-
-// Type implements the bsonrw.ValueReader interface.
-func (llvrw *ValueReaderWriter) Type() bsontype.Type {
-	llvrw.checkdepth()
-	return llvrw.BSONType
-}
-
-// Skip implements the bsonrw.ValueReader interface.
-func (llvrw *ValueReaderWriter) Skip() error {
-	llvrw.checkdepth()
-	llvrw.Invoked = Skip
-	if llvrw.ErrAfter == llvrw.Invoked {
-		return llvrw.Err
-	}
-	return nil
-}
-
-// ReadArray implements the bsonrw.ValueReader interface.
-func (llvrw *ValueReaderWriter) ReadArray() (bsonrw.ArrayReader, error) {
-	llvrw.checkdepth()
-	llvrw.Invoked = ReadArray
-	if llvrw.ErrAfter == llvrw.Invoked {
-		return nil, llvrw.Err
-	}
-
-	return llvrw, nil
-}
-
-// ReadBinary implements the bsonrw.ValueReader interface.
-func (llvrw *ValueReaderWriter) ReadBinary() (b []byte, btype byte, err error) {
-	llvrw.checkdepth()
-	llvrw.Invoked = ReadBinary
-	if llvrw.ErrAfter == llvrw.Invoked {
-		return nil, 0x00, llvrw.Err
-	}
-
-	switch tt := llvrw.Return.(type) {
-	case bsoncore.Value:
-		subtype, data, _, ok := bsoncore.ReadBinary(tt.Data)
-		if !ok {
-			llvrw.T.Error("Invalid Value provided for return value of ReadBinary.")
-			return nil, 0x00, nil
-		}
-		return data, subtype, nil
-	default:
-		llvrw.T.Errorf("Incorrect type provided for return value of ReadBinary: %T", llvrw.Return)
-		return nil, 0x00, nil
-	}
-}
-
-// ReadBoolean implements the bsonrw.ValueReader interface.
-func (llvrw *ValueReaderWriter) ReadBoolean() (bool, error) {
-	llvrw.checkdepth()
-	llvrw.Invoked = ReadBoolean
-	if llvrw.ErrAfter == llvrw.Invoked {
-		return false, llvrw.Err
-	}
-
-	switch tt := llvrw.Return.(type) {
-	case bool:
-		return tt, nil
-	case bsoncore.Value:
-		b, _, ok := bsoncore.ReadBoolean(tt.Data)
-		if !ok {
-			llvrw.T.Error("Invalid Value provided for return value of ReadBoolean.")
-			return false, nil
-		}
-		return b, nil
-	default:
-		llvrw.T.Errorf("Incorrect type provided for return value of ReadBoolean: %T", llvrw.Return)
-		return false, nil
-	}
-}
-
-// ReadDocument implements the bsonrw.ValueReader interface.
-func (llvrw *ValueReaderWriter) ReadDocument() (bsonrw.DocumentReader, error) {
-	llvrw.checkdepth()
-	llvrw.Invoked = ReadDocument
-	if llvrw.ErrAfter == llvrw.Invoked {
-		return nil, llvrw.Err
-	}
-
-	return llvrw, nil
-}
-
-// ReadCodeWithScope implements the bsonrw.ValueReader interface.
-func (llvrw *ValueReaderWriter) ReadCodeWithScope() (code string, dr bsonrw.DocumentReader, err error) {
-	llvrw.checkdepth()
-	llvrw.Invoked = ReadCodeWithScope
-	if llvrw.ErrAfter == llvrw.Invoked {
-		return "", nil, llvrw.Err
-	}
-
-	return "", llvrw, nil
-}
-
-// ReadDBPointer implements the bsonrw.ValueReader interface.
-func (llvrw *ValueReaderWriter) ReadDBPointer() (ns string, oid primitive.ObjectID, err error) {
-	llvrw.checkdepth()
-	llvrw.Invoked = ReadDBPointer
-	if llvrw.ErrAfter == llvrw.Invoked {
-		return "", primitive.ObjectID{}, llvrw.Err
-	}
-
-	switch tt := llvrw.Return.(type) {
-	case bsoncore.Value:
-		ns, oid, _, ok := bsoncore.ReadDBPointer(tt.Data)
-		if !ok {
-			llvrw.T.Error("Invalid Value instance provided for return value of ReadDBPointer")
-			return "", primitive.ObjectID{}, nil
-		}
-		return ns, oid, nil
-	default:
-		llvrw.T.Errorf("Incorrect type provided for return value of ReadDBPointer: %T", llvrw.Return)
-		return "", primitive.ObjectID{}, nil
-	}
-}
-
-// ReadDateTime implements the bsonrw.ValueReader interface.
-func (llvrw *ValueReaderWriter) ReadDateTime() (int64, error) {
-	llvrw.checkdepth()
-	llvrw.Invoked = ReadDateTime
-	if llvrw.ErrAfter == llvrw.Invoked {
-		return 0, llvrw.Err
-	}
-
-	dt, ok := llvrw.Return.(int64)
-	if !ok {
-		llvrw.T.Errorf("Incorrect type provided for return value of ReadDateTime: %T", llvrw.Return)
-		return 0, nil
-	}
-
-	return dt, nil
-}
-
-// ReadDecimal128 implements the bsonrw.ValueReader interface.
-func (llvrw *ValueReaderWriter) ReadDecimal128() (primitive.Decimal128, error) {
-	llvrw.checkdepth()
-	llvrw.Invoked = ReadDecimal128
-	if llvrw.ErrAfter == llvrw.Invoked {
-		return primitive.Decimal128{}, llvrw.Err
-	}
-
-	d128, ok := llvrw.Return.(primitive.Decimal128)
-	if !ok {
-		llvrw.T.Errorf("Incorrect type provided for return value of ReadDecimal128: %T", llvrw.Return)
-		return primitive.Decimal128{}, nil
-	}
-
-	return d128, nil
-}
-
-// ReadDouble implements the bsonrw.ValueReader interface.
-func (llvrw *ValueReaderWriter) ReadDouble() (float64, error) {
-	llvrw.checkdepth()
-	llvrw.Invoked = ReadDouble
-	if llvrw.ErrAfter == llvrw.Invoked {
-		return 0, llvrw.Err
-	}
-
-	f64, ok := llvrw.Return.(float64)
-	if !ok {
-		llvrw.T.Errorf("Incorrect type provided for return value of ReadDouble: %T", llvrw.Return)
-		return 0, nil
-	}
-
-	return f64, nil
-}
-
-// ReadInt32 implements the bsonrw.ValueReader interface.
-func (llvrw *ValueReaderWriter) ReadInt32() (int32, error) {
-	llvrw.checkdepth()
-	llvrw.Invoked = ReadInt32
-	if llvrw.ErrAfter == llvrw.Invoked {
-		return 0, llvrw.Err
-	}
-
-	i32, ok := llvrw.Return.(int32)
-	if !ok {
-		llvrw.T.Errorf("Incorrect type provided for return value of ReadInt32: %T", llvrw.Return)
-		return 0, nil
-	}
-
-	return i32, nil
-}
-
-// ReadInt64 implements the bsonrw.ValueReader interface.
-func (llvrw *ValueReaderWriter) ReadInt64() (int64, error) {
-	llvrw.checkdepth()
-	llvrw.Invoked = ReadInt64
-	if llvrw.ErrAfter == llvrw.Invoked {
-		return 0, llvrw.Err
-	}
-	i64, ok := llvrw.Return.(int64)
-	if !ok {
-		llvrw.T.Errorf("Incorrect type provided for return value of ReadInt64: %T", llvrw.Return)
-		return 0, nil
-	}
-
-	return i64, nil
-}
-
-// ReadJavascript implements the bsonrw.ValueReader interface.
-func (llvrw *ValueReaderWriter) ReadJavascript() (code string, err error) {
-	llvrw.checkdepth()
-	llvrw.Invoked = ReadJavascript
-	if llvrw.ErrAfter == llvrw.Invoked {
-		return "", llvrw.Err
-	}
-	js, ok := llvrw.Return.(string)
-	if !ok {
-		llvrw.T.Errorf("Incorrect type provided for return value of ReadJavascript: %T", llvrw.Return)
-		return "", nil
-	}
-
-	return js, nil
-}
-
-// ReadMaxKey implements the bsonrw.ValueReader interface.
-func (llvrw *ValueReaderWriter) ReadMaxKey() error {
-	llvrw.checkdepth()
-	llvrw.Invoked = ReadMaxKey
-	if llvrw.ErrAfter == llvrw.Invoked {
-		return llvrw.Err
-	}
-
-	return nil
-}
-
-// ReadMinKey implements the bsonrw.ValueReader interface.
-func (llvrw *ValueReaderWriter) ReadMinKey() error {
-	llvrw.checkdepth()
-	llvrw.Invoked = ReadMinKey
-	if llvrw.ErrAfter == llvrw.Invoked {
-		return llvrw.Err
-	}
-
-	return nil
-}
-
-// ReadNull implements the bsonrw.ValueReader interface.
-func (llvrw *ValueReaderWriter) ReadNull() error {
-	llvrw.checkdepth()
-	llvrw.Invoked = ReadNull
-	if llvrw.ErrAfter == llvrw.Invoked {
-		return llvrw.Err
-	}
-
-	return nil
-}
-
-// ReadObjectID implements the bsonrw.ValueReader interface.
-func (llvrw *ValueReaderWriter) ReadObjectID() (primitive.ObjectID, error) {
-	llvrw.checkdepth()
-	llvrw.Invoked = ReadObjectID
-	if llvrw.ErrAfter == llvrw.Invoked {
-		return primitive.ObjectID{}, llvrw.Err
-	}
-	oid, ok := llvrw.Return.(primitive.ObjectID)
-	if !ok {
-		llvrw.T.Errorf("Incorrect type provided for return value of ReadObjectID: %T", llvrw.Return)
-		return primitive.ObjectID{}, nil
-	}
-
-	return oid, nil
-}
-
-// ReadRegex implements the bsonrw.ValueReader interface.
-func (llvrw *ValueReaderWriter) ReadRegex() (pattern string, options string, err error) {
-	llvrw.checkdepth()
-	llvrw.Invoked = ReadRegex
-	if llvrw.ErrAfter == llvrw.Invoked {
-		return "", "", llvrw.Err
-	}
-	switch tt := llvrw.Return.(type) {
-	case bsoncore.Value:
-		pattern, options, _, ok := bsoncore.ReadRegex(tt.Data)
-		if !ok {
-			llvrw.T.Error("Invalid Value instance provided for ReadRegex")
-			return "", "", nil
-		}
-		return pattern, options, nil
-	default:
-		llvrw.T.Errorf("Incorrect type provided for return value of ReadRegex: %T", llvrw.Return)
-		return "", "", nil
-	}
-}
-
-// ReadString implements the bsonrw.ValueReader interface.
-func (llvrw *ValueReaderWriter) ReadString() (string, error) {
-	llvrw.checkdepth()
-	llvrw.Invoked = ReadString
-	if llvrw.ErrAfter == llvrw.Invoked {
-		return "", llvrw.Err
-	}
-	str, ok := llvrw.Return.(string)
-	if !ok {
-		llvrw.T.Errorf("Incorrect type provided for return value of ReadString: %T", llvrw.Return)
-		return "", nil
-	}
-
-	return str, nil
-}
-
-// ReadSymbol implements the bsonrw.ValueReader interface.
-func (llvrw *ValueReaderWriter) ReadSymbol() (symbol string, err error) {
-	llvrw.checkdepth()
-	llvrw.Invoked = ReadSymbol
-	if llvrw.ErrAfter == llvrw.Invoked {
-		return "", llvrw.Err
-	}
-	switch tt := llvrw.Return.(type) {
-	case string:
-		return tt, nil
-	case bsoncore.Value:
-		symbol, _, ok := bsoncore.ReadSymbol(tt.Data)
-		if !ok {
-			llvrw.T.Error("Invalid Value instance provided for ReadSymbol")
-			return "", nil
-		}
-		return symbol, nil
-	default:
-		llvrw.T.Errorf("Incorrect type provided for return value of ReadSymbol: %T", llvrw.Return)
-		return "", nil
-	}
-}
-
-// ReadTimestamp implements the bsonrw.ValueReader interface.
-func (llvrw *ValueReaderWriter) ReadTimestamp() (t uint32, i uint32, err error) {
-	llvrw.checkdepth()
-	llvrw.Invoked = ReadTimestamp
-	if llvrw.ErrAfter == llvrw.Invoked {
-		return 0, 0, llvrw.Err
-	}
-	switch tt := llvrw.Return.(type) {
-	case bsoncore.Value:
-		t, i, _, ok := bsoncore.ReadTimestamp(tt.Data)
-		if !ok {
-			llvrw.T.Errorf("Invalid Value instance provided for return value of ReadTimestamp")
-			return 0, 0, nil
-		}
-		return t, i, nil
-	default:
-		llvrw.T.Errorf("Incorrect type provided for return value of ReadTimestamp: %T", llvrw.Return)
-		return 0, 0, nil
-	}
-}
-
-// ReadUndefined implements the bsonrw.ValueReader interface.
-func (llvrw *ValueReaderWriter) ReadUndefined() error {
-	llvrw.checkdepth()
-	llvrw.Invoked = ReadUndefined
-	if llvrw.ErrAfter == llvrw.Invoked {
-		return llvrw.Err
-	}
-
-	return nil
-}
-
-// WriteArray implements the bsonrw.ValueWriter interface.
-func (llvrw *ValueReaderWriter) WriteArray() (bsonrw.ArrayWriter, error) {
-	llvrw.checkdepth()
-	llvrw.Invoked = WriteArray
-	if llvrw.ErrAfter == llvrw.Invoked {
-		return nil, llvrw.Err
-	}
-	return llvrw, nil
-}
-
-// WriteBinary implements the bsonrw.ValueWriter interface.
-func (llvrw *ValueReaderWriter) WriteBinary(b []byte) error {
-	llvrw.checkdepth()
-	llvrw.Invoked = WriteBinary
-	if llvrw.ErrAfter == llvrw.Invoked {
-		return llvrw.Err
-	}
-	return nil
-}
-
-// WriteBinaryWithSubtype implements the bsonrw.ValueWriter interface.
-func (llvrw *ValueReaderWriter) WriteBinaryWithSubtype(b []byte, btype byte) error {
-	llvrw.checkdepth()
-	llvrw.Invoked = WriteBinaryWithSubtype
-	if llvrw.ErrAfter == llvrw.Invoked {
-		return llvrw.Err
-	}
-	return nil
-}
-
-// WriteBoolean implements the bsonrw.ValueWriter interface.
-func (llvrw *ValueReaderWriter) WriteBoolean(bool) error {
-	llvrw.checkdepth()
-	llvrw.Invoked = WriteBoolean
-	if llvrw.ErrAfter == llvrw.Invoked {
-		return llvrw.Err
-	}
-	return nil
-}
-
-// WriteCodeWithScope implements the bsonrw.ValueWriter interface.
-func (llvrw *ValueReaderWriter) WriteCodeWithScope(code string) (bsonrw.DocumentWriter, error) {
-	llvrw.checkdepth()
-	llvrw.Invoked = WriteCodeWithScope
-	if llvrw.ErrAfter == llvrw.Invoked {
-		return nil, llvrw.Err
-	}
-	return llvrw, nil
-}
-
-// WriteDBPointer implements the bsonrw.ValueWriter interface.
-func (llvrw *ValueReaderWriter) WriteDBPointer(ns string, oid primitive.ObjectID) error {
-	llvrw.checkdepth()
-	llvrw.Invoked = WriteDBPointer
-	if llvrw.ErrAfter == llvrw.Invoked {
-		return llvrw.Err
-	}
-	return nil
-}
-
-// WriteDateTime implements the bsonrw.ValueWriter interface.
-func (llvrw *ValueReaderWriter) WriteDateTime(dt int64) error {
-	llvrw.checkdepth()
-	llvrw.Invoked = WriteDateTime
-	if llvrw.ErrAfter == llvrw.Invoked {
-		return llvrw.Err
-	}
-	return nil
-}
-
-// WriteDecimal128 implements the bsonrw.ValueWriter interface.
-func (llvrw *ValueReaderWriter) WriteDecimal128(primitive.Decimal128) error {
-	llvrw.checkdepth()
-	llvrw.Invoked = WriteDecimal128
-	if llvrw.ErrAfter == llvrw.Invoked {
-		return llvrw.Err
-	}
-	return nil
-}
-
-// WriteDouble implements the bsonrw.ValueWriter interface.
-func (llvrw *ValueReaderWriter) WriteDouble(float64) error {
-	llvrw.checkdepth()
-	llvrw.Invoked = WriteDouble
-	if llvrw.ErrAfter == llvrw.Invoked {
-		return llvrw.Err
-	}
-	return nil
-}
-
-// WriteInt32 implements the bsonrw.ValueWriter interface.
-func (llvrw *ValueReaderWriter) WriteInt32(int32) error {
-	llvrw.checkdepth()
-	llvrw.Invoked = WriteInt32
-	if llvrw.ErrAfter == llvrw.Invoked {
-		return llvrw.Err
-	}
-	return nil
-}
-
-// WriteInt64 implements the bsonrw.ValueWriter interface.
-func (llvrw *ValueReaderWriter) WriteInt64(int64) error {
-	llvrw.checkdepth()
-	llvrw.Invoked = WriteInt64
-	if llvrw.ErrAfter == llvrw.Invoked {
-		return llvrw.Err
-	}
-	return nil
-}
-
-// WriteJavascript implements the bsonrw.ValueWriter interface.
-func (llvrw *ValueReaderWriter) WriteJavascript(code string) error {
-	llvrw.checkdepth()
-	llvrw.Invoked = WriteJavascript
-	if llvrw.ErrAfter == llvrw.Invoked {
-		return llvrw.Err
-	}
-	return nil
-}
-
-// WriteMaxKey implements the bsonrw.ValueWriter interface.
-func (llvrw *ValueReaderWriter) WriteMaxKey() error {
-	llvrw.checkdepth()
-	llvrw.Invoked = WriteMaxKey
-	if llvrw.ErrAfter == llvrw.Invoked {
-		return llvrw.Err
-	}
-	return nil
-}
-
-// WriteMinKey implements the bsonrw.ValueWriter interface.
-func (llvrw *ValueReaderWriter) WriteMinKey() error {
-	llvrw.checkdepth()
-	llvrw.Invoked = WriteMinKey
-	if llvrw.ErrAfter == llvrw.Invoked {
-		return llvrw.Err
-	}
-	return nil
-}
-
-// WriteNull implements the bsonrw.ValueWriter interface.
-func (llvrw *ValueReaderWriter) WriteNull() error {
-	llvrw.checkdepth()
-	llvrw.Invoked = WriteNull
-	if llvrw.ErrAfter == llvrw.Invoked {
-		return llvrw.Err
-	}
-	return nil
-}
-
-// WriteObjectID implements the bsonrw.ValueWriter interface.
-func (llvrw *ValueReaderWriter) WriteObjectID(primitive.ObjectID) error {
-	llvrw.checkdepth()
-	llvrw.Invoked = WriteObjectID
-	if llvrw.ErrAfter == llvrw.Invoked {
-		return llvrw.Err
-	}
-	return nil
-}
-
-// WriteRegex implements the bsonrw.ValueWriter interface.
-func (llvrw *ValueReaderWriter) WriteRegex(pattern string, options string) error {
-	llvrw.checkdepth()
-	llvrw.Invoked = WriteRegex
-	if llvrw.ErrAfter == llvrw.Invoked {
-		return llvrw.Err
-	}
-	return nil
-}
-
-// WriteString implements the bsonrw.ValueWriter interface.
-func (llvrw *ValueReaderWriter) WriteString(string) error {
-	llvrw.checkdepth()
-	llvrw.Invoked = WriteString
-	if llvrw.ErrAfter == llvrw.Invoked {
-		return llvrw.Err
-	}
-	return nil
-}
-
-// WriteDocument implements the bsonrw.ValueWriter interface.
-func (llvrw *ValueReaderWriter) WriteDocument() (bsonrw.DocumentWriter, error) {
-	llvrw.checkdepth()
-	llvrw.Invoked = WriteDocument
-	if llvrw.ErrAfter == llvrw.Invoked {
-		return nil, llvrw.Err
-	}
-	return llvrw, nil
-}
-
-// WriteSymbol implements the bsonrw.ValueWriter interface.
-func (llvrw *ValueReaderWriter) WriteSymbol(symbol string) error {
-	llvrw.checkdepth()
-	llvrw.Invoked = WriteSymbol
-	if llvrw.ErrAfter == llvrw.Invoked {
-		return llvrw.Err
-	}
-	return nil
-}
-
-// WriteTimestamp implements the bsonrw.ValueWriter interface.
-func (llvrw *ValueReaderWriter) WriteTimestamp(t uint32, i uint32) error {
-	llvrw.checkdepth()
-	llvrw.Invoked = WriteTimestamp
-	if llvrw.ErrAfter == llvrw.Invoked {
-		return llvrw.Err
-	}
-	return nil
-}
-
-// WriteUndefined implements the bsonrw.ValueWriter interface.
-func (llvrw *ValueReaderWriter) WriteUndefined() error {
-	llvrw.checkdepth()
-	llvrw.Invoked = WriteUndefined
-	if llvrw.ErrAfter == llvrw.Invoked {
-		return llvrw.Err
-	}
-	return nil
-}
-
-// ReadElement implements the bsonrw.DocumentReader interface.
-func (llvrw *ValueReaderWriter) ReadElement() (string, bsonrw.ValueReader, error) {
-	llvrw.checkdepth()
-	llvrw.Invoked = ReadElement
-	if llvrw.ErrAfter == llvrw.Invoked {
-		return "", nil, llvrw.Err
-	}
-
-	return "", llvrw, nil
-}
-
-// WriteDocumentElement implements the bsonrw.DocumentWriter interface.
-func (llvrw *ValueReaderWriter) WriteDocumentElement(string) (bsonrw.ValueWriter, error) {
-	llvrw.checkdepth()
-	llvrw.Invoked = WriteDocumentElement
-	if llvrw.ErrAfter == llvrw.Invoked {
-		return nil, llvrw.Err
-	}
-
-	return llvrw, nil
-}
-
-// WriteDocumentEnd implements the bsonrw.DocumentWriter interface.
-func (llvrw *ValueReaderWriter) WriteDocumentEnd() error {
-	llvrw.checkdepth()
-	llvrw.Invoked = WriteDocumentEnd
-	if llvrw.ErrAfter == llvrw.Invoked {
-		return llvrw.Err
-	}
-
-	return nil
-}
-
-// ReadValue implements the bsonrw.ArrayReader interface.
-func (llvrw *ValueReaderWriter) ReadValue() (bsonrw.ValueReader, error) {
-	llvrw.checkdepth()
-	llvrw.Invoked = ReadValue
-	if llvrw.ErrAfter == llvrw.Invoked {
-		return nil, llvrw.Err
-	}
-
-	return llvrw, nil
-}
-
-// WriteArrayElement implements the bsonrw.ArrayWriter interface.
-func (llvrw *ValueReaderWriter) WriteArrayElement() (bsonrw.ValueWriter, error) {
-	llvrw.checkdepth()
-	llvrw.Invoked = WriteArrayElement
-	if llvrw.ErrAfter == llvrw.Invoked {
-		return nil, llvrw.Err
-	}
-
-	return llvrw, nil
-}
-
-// WriteArrayEnd implements the bsonrw.ArrayWriter interface.
-func (llvrw *ValueReaderWriter) WriteArrayEnd() error {
-	llvrw.checkdepth()
-	llvrw.Invoked = WriteArrayEnd
-	if llvrw.ErrAfter == llvrw.Invoked {
-		return llvrw.Err
-	}
-
-	return nil
-}

+ 0 - 389
qyxy/src/mgoutil/go.mongodb.org/mongo-driver/bson/bsonrw/copier.go

@@ -1,389 +0,0 @@
-// Copyright (C) MongoDB, Inc. 2017-present.
-//
-// Licensed under the Apache License, Version 2.0 (the "License"); you may
-// not use this file except in compliance with the License. You may obtain
-// a copy of the License at http://www.apache.org/licenses/LICENSE-2.0
-
-package bsonrw
-
-import (
-	"fmt"
-	"io"
-
-	"go.mongodb.org/mongo-driver/bson/bsontype"
-	"go.mongodb.org/mongo-driver/bson/primitive"
-	"go.mongodb.org/mongo-driver/x/bsonx/bsoncore"
-)
-
-// Copier is a type that allows copying between ValueReaders, ValueWriters, and
-// []byte values.
-type Copier struct{}
-
-// NewCopier creates a new copier with the given registry. If a nil registry is provided
-// a default registry is used.
-func NewCopier() Copier {
-	return Copier{}
-}
-
-// CopyDocument handles copying a document from src to dst.
-func CopyDocument(dst ValueWriter, src ValueReader) error {
-	return Copier{}.CopyDocument(dst, src)
-}
-
-// CopyDocument handles copying one document from the src to the dst.
-func (c Copier) CopyDocument(dst ValueWriter, src ValueReader) error {
-	dr, err := src.ReadDocument()
-	if err != nil {
-		return err
-	}
-
-	dw, err := dst.WriteDocument()
-	if err != nil {
-		return err
-	}
-
-	return c.copyDocumentCore(dw, dr)
-}
-
-// CopyDocumentFromBytes copies the values from a BSON document represented as a
-// []byte to a ValueWriter.
-func (c Copier) CopyDocumentFromBytes(dst ValueWriter, src []byte) error {
-	dw, err := dst.WriteDocument()
-	if err != nil {
-		return err
-	}
-
-	err = c.CopyBytesToDocumentWriter(dw, src)
-	if err != nil {
-		return err
-	}
-
-	return dw.WriteDocumentEnd()
-}
-
-// CopyBytesToDocumentWriter copies the values from a BSON document represented as a []byte to a
-// DocumentWriter.
-func (c Copier) CopyBytesToDocumentWriter(dst DocumentWriter, src []byte) error {
-	// TODO(skriptble): Create errors types here. Anything thats a tag should be a property.
-	length, rem, ok := bsoncore.ReadLength(src)
-	if !ok {
-		return fmt.Errorf("couldn't read length from src, not enough bytes. length=%d", len(src))
-	}
-	if len(src) < int(length) {
-		return fmt.Errorf("length read exceeds number of bytes available. length=%d bytes=%d", len(src), length)
-	}
-	rem = rem[:length-4]
-
-	var t bsontype.Type
-	var key string
-	var val bsoncore.Value
-	for {
-		t, rem, ok = bsoncore.ReadType(rem)
-		if !ok {
-			return io.EOF
-		}
-		if t == bsontype.Type(0) {
-			if len(rem) != 0 {
-				return fmt.Errorf("document end byte found before end of document. remaining bytes=%v", rem)
-			}
-			break
-		}
-
-		key, rem, ok = bsoncore.ReadKey(rem)
-		if !ok {
-			return fmt.Errorf("invalid key found. remaining bytes=%v", rem)
-		}
-		dvw, err := dst.WriteDocumentElement(key)
-		if err != nil {
-			return err
-		}
-		val, rem, ok = bsoncore.ReadValue(rem, t)
-		if !ok {
-			return fmt.Errorf("not enough bytes available to read type. bytes=%d type=%s", len(rem), t)
-		}
-		err = c.CopyValueFromBytes(dvw, t, val.Data)
-		if err != nil {
-			return err
-		}
-	}
-	return nil
-}
-
-// CopyDocumentToBytes copies an entire document from the ValueReader and
-// returns it as bytes.
-func (c Copier) CopyDocumentToBytes(src ValueReader) ([]byte, error) {
-	return c.AppendDocumentBytes(nil, src)
-}
-
-// AppendDocumentBytes functions the same as CopyDocumentToBytes, but will
-// append the result to dst.
-func (c Copier) AppendDocumentBytes(dst []byte, src ValueReader) ([]byte, error) {
-	if br, ok := src.(BytesReader); ok {
-		_, dst, err := br.ReadValueBytes(dst)
-		return dst, err
-	}
-
-	vw := vwPool.Get().(*valueWriter)
-	defer vwPool.Put(vw)
-
-	vw.reset(dst)
-
-	err := c.CopyDocument(vw, src)
-	dst = vw.buf
-	return dst, err
-}
-
-// CopyValueFromBytes will write the value represtend by t and src to dst.
-func (c Copier) CopyValueFromBytes(dst ValueWriter, t bsontype.Type, src []byte) error {
-	if wvb, ok := dst.(BytesWriter); ok {
-		return wvb.WriteValueBytes(t, src)
-	}
-
-	vr := vrPool.Get().(*valueReader)
-	defer vrPool.Put(vr)
-
-	vr.reset(src)
-	vr.pushElement(t)
-
-	return c.CopyValue(dst, vr)
-}
-
-// CopyValueToBytes copies a value from src and returns it as a bsontype.Type and a
-// []byte.
-func (c Copier) CopyValueToBytes(src ValueReader) (bsontype.Type, []byte, error) {
-	return c.AppendValueBytes(nil, src)
-}
-
-// AppendValueBytes functions the same as CopyValueToBytes, but will append the
-// result to dst.
-func (c Copier) AppendValueBytes(dst []byte, src ValueReader) (bsontype.Type, []byte, error) {
-	if br, ok := src.(BytesReader); ok {
-		return br.ReadValueBytes(dst)
-	}
-
-	vw := vwPool.Get().(*valueWriter)
-	defer vwPool.Put(vw)
-
-	start := len(dst)
-
-	vw.reset(dst)
-	vw.push(mElement)
-
-	err := c.CopyValue(vw, src)
-	if err != nil {
-		return 0, dst, err
-	}
-
-	return bsontype.Type(vw.buf[start]), vw.buf[start+2:], nil
-}
-
-// CopyValue will copy a single value from src to dst.
-func (c Copier) CopyValue(dst ValueWriter, src ValueReader) error {
-	var err error
-	switch src.Type() {
-	case bsontype.Double:
-		var f64 float64
-		f64, err = src.ReadDouble()
-		if err != nil {
-			break
-		}
-		err = dst.WriteDouble(f64)
-	case bsontype.String:
-		var str string
-		str, err = src.ReadString()
-		if err != nil {
-			return err
-		}
-		err = dst.WriteString(str)
-	case bsontype.EmbeddedDocument:
-		err = c.CopyDocument(dst, src)
-	case bsontype.Array:
-		err = c.copyArray(dst, src)
-	case bsontype.Binary:
-		var data []byte
-		var subtype byte
-		data, subtype, err = src.ReadBinary()
-		if err != nil {
-			break
-		}
-		err = dst.WriteBinaryWithSubtype(data, subtype)
-	case bsontype.Undefined:
-		err = src.ReadUndefined()
-		if err != nil {
-			break
-		}
-		err = dst.WriteUndefined()
-	case bsontype.ObjectID:
-		var oid primitive.ObjectID
-		oid, err = src.ReadObjectID()
-		if err != nil {
-			break
-		}
-		err = dst.WriteObjectID(oid)
-	case bsontype.Boolean:
-		var b bool
-		b, err = src.ReadBoolean()
-		if err != nil {
-			break
-		}
-		err = dst.WriteBoolean(b)
-	case bsontype.DateTime:
-		var dt int64
-		dt, err = src.ReadDateTime()
-		if err != nil {
-			break
-		}
-		err = dst.WriteDateTime(dt)
-	case bsontype.Null:
-		err = src.ReadNull()
-		if err != nil {
-			break
-		}
-		err = dst.WriteNull()
-	case bsontype.Regex:
-		var pattern, options string
-		pattern, options, err = src.ReadRegex()
-		if err != nil {
-			break
-		}
-		err = dst.WriteRegex(pattern, options)
-	case bsontype.DBPointer:
-		var ns string
-		var pointer primitive.ObjectID
-		ns, pointer, err = src.ReadDBPointer()
-		if err != nil {
-			break
-		}
-		err = dst.WriteDBPointer(ns, pointer)
-	case bsontype.JavaScript:
-		var js string
-		js, err = src.ReadJavascript()
-		if err != nil {
-			break
-		}
-		err = dst.WriteJavascript(js)
-	case bsontype.Symbol:
-		var symbol string
-		symbol, err = src.ReadSymbol()
-		if err != nil {
-			break
-		}
-		err = dst.WriteSymbol(symbol)
-	case bsontype.CodeWithScope:
-		var code string
-		var srcScope DocumentReader
-		code, srcScope, err = src.ReadCodeWithScope()
-		if err != nil {
-			break
-		}
-
-		var dstScope DocumentWriter
-		dstScope, err = dst.WriteCodeWithScope(code)
-		if err != nil {
-			break
-		}
-		err = c.copyDocumentCore(dstScope, srcScope)
-	case bsontype.Int32:
-		var i32 int32
-		i32, err = src.ReadInt32()
-		if err != nil {
-			break
-		}
-		err = dst.WriteInt32(i32)
-	case bsontype.Timestamp:
-		var t, i uint32
-		t, i, err = src.ReadTimestamp()
-		if err != nil {
-			break
-		}
-		err = dst.WriteTimestamp(t, i)
-	case bsontype.Int64:
-		var i64 int64
-		i64, err = src.ReadInt64()
-		if err != nil {
-			break
-		}
-		err = dst.WriteInt64(i64)
-	case bsontype.Decimal128:
-		var d128 primitive.Decimal128
-		d128, err = src.ReadDecimal128()
-		if err != nil {
-			break
-		}
-		err = dst.WriteDecimal128(d128)
-	case bsontype.MinKey:
-		err = src.ReadMinKey()
-		if err != nil {
-			break
-		}
-		err = dst.WriteMinKey()
-	case bsontype.MaxKey:
-		err = src.ReadMaxKey()
-		if err != nil {
-			break
-		}
-		err = dst.WriteMaxKey()
-	default:
-		err = fmt.Errorf("Cannot copy unknown BSON type %s", src.Type())
-	}
-
-	return err
-}
-
-func (c Copier) copyArray(dst ValueWriter, src ValueReader) error {
-	ar, err := src.ReadArray()
-	if err != nil {
-		return err
-	}
-
-	aw, err := dst.WriteArray()
-	if err != nil {
-		return err
-	}
-
-	for {
-		vr, err := ar.ReadValue()
-		if err == ErrEOA {
-			break
-		}
-		if err != nil {
-			return err
-		}
-
-		vw, err := aw.WriteArrayElement()
-		if err != nil {
-			return err
-		}
-
-		err = c.CopyValue(vw, vr)
-		if err != nil {
-			return err
-		}
-	}
-
-	return aw.WriteArrayEnd()
-}
-
-func (c Copier) copyDocumentCore(dw DocumentWriter, dr DocumentReader) error {
-	for {
-		key, vr, err := dr.ReadElement()
-		if err == ErrEOD {
-			break
-		}
-		if err != nil {
-			return err
-		}
-
-		vw, err := dw.WriteDocumentElement(key)
-		if err != nil {
-			return err
-		}
-
-		err = c.CopyValue(vw, vr)
-		if err != nil {
-			return err
-		}
-	}
-
-	return dw.WriteDocumentEnd()
-}

+ 0 - 529
qyxy/src/mgoutil/go.mongodb.org/mongo-driver/bson/bsonrw/copier_test.go

@@ -1,529 +0,0 @@
-// Copyright (C) MongoDB, Inc. 2017-present.
-//
-// Licensed under the Apache License, Version 2.0 (the "License"); you may
-// not use this file except in compliance with the License. You may obtain
-// a copy of the License at http://www.apache.org/licenses/LICENSE-2.0
-
-package bsonrw
-
-import (
-	"bytes"
-	"errors"
-	"fmt"
-	"testing"
-
-	"go.mongodb.org/mongo-driver/bson/bsontype"
-	"go.mongodb.org/mongo-driver/bson/primitive"
-	"go.mongodb.org/mongo-driver/x/bsonx/bsoncore"
-)
-
-func TestCopier(t *testing.T) {
-	t.Run("CopyDocument", func(t *testing.T) {
-		t.Run("ReadDocument Error", func(t *testing.T) {
-			want := errors.New("ReadDocumentError")
-			src := &TestValueReaderWriter{t: t, err: want, errAfter: llvrwReadDocument}
-			got := Copier{}.CopyDocument(nil, src)
-			if !compareErrors(got, want) {
-				t.Errorf("Did not receive correct error. got %v; want %v", got, want)
-			}
-		})
-		t.Run("WriteDocument Error", func(t *testing.T) {
-			want := errors.New("WriteDocumentError")
-			src := &TestValueReaderWriter{}
-			dst := &TestValueReaderWriter{t: t, err: want, errAfter: llvrwWriteDocument}
-			got := Copier{}.CopyDocument(dst, src)
-			if !compareErrors(got, want) {
-				t.Errorf("Did not receive correct error. got %v; want %v", got, want)
-			}
-		})
-		t.Run("success", func(t *testing.T) {
-			idx, doc := bsoncore.AppendDocumentStart(nil)
-			doc = bsoncore.AppendStringElement(doc, "Hello", "world")
-			doc, err := bsoncore.AppendDocumentEnd(doc, idx)
-			noerr(t, err)
-			src := newValueReader(doc)
-			dst := newValueWriterFromSlice(make([]byte, 0))
-			want := doc
-			err = Copier{}.CopyDocument(dst, src)
-			noerr(t, err)
-			got := dst.buf
-			if !bytes.Equal(got, want) {
-				t.Errorf("Bytes are not equal. got %v; want %v", got, want)
-			}
-		})
-	})
-	t.Run("copyArray", func(t *testing.T) {
-		t.Run("ReadArray Error", func(t *testing.T) {
-			want := errors.New("ReadArrayError")
-			src := &TestValueReaderWriter{t: t, err: want, errAfter: llvrwReadArray}
-			got := Copier{}.copyArray(nil, src)
-			if !compareErrors(got, want) {
-				t.Errorf("Did not receive correct error. got %v; want %v", got, want)
-			}
-		})
-		t.Run("WriteArray Error", func(t *testing.T) {
-			want := errors.New("WriteArrayError")
-			src := &TestValueReaderWriter{}
-			dst := &TestValueReaderWriter{t: t, err: want, errAfter: llvrwWriteArray}
-			got := Copier{}.copyArray(dst, src)
-			if !compareErrors(got, want) {
-				t.Errorf("Did not receive correct error. got %v; want %v", got, want)
-			}
-		})
-		t.Run("success", func(t *testing.T) {
-			idx, doc := bsoncore.AppendDocumentStart(nil)
-			aidx, doc := bsoncore.AppendArrayElementStart(doc, "foo")
-			doc = bsoncore.AppendStringElement(doc, "0", "Hello, world!")
-			doc, err := bsoncore.AppendArrayEnd(doc, aidx)
-			noerr(t, err)
-			doc, err = bsoncore.AppendDocumentEnd(doc, idx)
-			noerr(t, err)
-			src := newValueReader(doc)
-
-			_, err = src.ReadDocument()
-			noerr(t, err)
-			_, _, err = src.ReadElement()
-			noerr(t, err)
-
-			dst := newValueWriterFromSlice(make([]byte, 0))
-			_, err = dst.WriteDocument()
-			noerr(t, err)
-			_, err = dst.WriteDocumentElement("foo")
-			noerr(t, err)
-			want := doc
-
-			err = Copier{}.copyArray(dst, src)
-			noerr(t, err)
-
-			err = dst.WriteDocumentEnd()
-			noerr(t, err)
-
-			got := dst.buf
-			if !bytes.Equal(got, want) {
-				t.Errorf("Bytes are not equal. got %v; want %v", got, want)
-			}
-		})
-	})
-	t.Run("CopyValue", func(t *testing.T) {
-		testCases := []struct {
-			name string
-			dst  *TestValueReaderWriter
-			src  *TestValueReaderWriter
-			err  error
-		}{
-			{
-				"Double/src/error",
-				&TestValueReaderWriter{},
-				&TestValueReaderWriter{bsontype: bsontype.Double, err: errors.New("1"), errAfter: llvrwReadDouble},
-				errors.New("1"),
-			},
-			{
-				"Double/dst/error",
-				&TestValueReaderWriter{bsontype: bsontype.Double, err: errors.New("2"), errAfter: llvrwWriteDouble},
-				&TestValueReaderWriter{bsontype: bsontype.Double, readval: float64(3.14159)},
-				errors.New("2"),
-			},
-			{
-				"String/src/error",
-				&TestValueReaderWriter{},
-				&TestValueReaderWriter{bsontype: bsontype.String, err: errors.New("1"), errAfter: llvrwReadString},
-				errors.New("1"),
-			},
-			{
-				"String/dst/error",
-				&TestValueReaderWriter{bsontype: bsontype.String, err: errors.New("2"), errAfter: llvrwWriteString},
-				&TestValueReaderWriter{bsontype: bsontype.String, readval: string("hello, world")},
-				errors.New("2"),
-			},
-			{
-				"Document/src/error",
-				&TestValueReaderWriter{},
-				&TestValueReaderWriter{bsontype: bsontype.EmbeddedDocument, err: errors.New("1"), errAfter: llvrwReadDocument},
-				errors.New("1"),
-			},
-			{
-				"Array/dst/error",
-				&TestValueReaderWriter{},
-				&TestValueReaderWriter{bsontype: bsontype.Array, err: errors.New("2"), errAfter: llvrwReadArray},
-				errors.New("2"),
-			},
-			{
-				"Binary/src/error",
-				&TestValueReaderWriter{},
-				&TestValueReaderWriter{bsontype: bsontype.Binary, err: errors.New("1"), errAfter: llvrwReadBinary},
-				errors.New("1"),
-			},
-			{
-				"Binary/dst/error",
-				&TestValueReaderWriter{bsontype: bsontype.Binary, err: errors.New("2"), errAfter: llvrwWriteBinaryWithSubtype},
-				&TestValueReaderWriter{
-					bsontype: bsontype.Binary,
-					readval: bsoncore.Value{
-						Type: bsontype.Binary,
-						Data: []byte{0x03, 0x00, 0x00, 0x00, 0xFF, 0x01, 0x02, 0x03},
-					},
-				},
-				errors.New("2"),
-			},
-			{
-				"Undefined/src/error",
-				&TestValueReaderWriter{},
-				&TestValueReaderWriter{bsontype: bsontype.Undefined, err: errors.New("1"), errAfter: llvrwReadUndefined},
-				errors.New("1"),
-			},
-			{
-				"Undefined/dst/error",
-				&TestValueReaderWriter{bsontype: bsontype.Undefined, err: errors.New("2"), errAfter: llvrwWriteUndefined},
-				&TestValueReaderWriter{bsontype: bsontype.Undefined},
-				errors.New("2"),
-			},
-			{
-				"ObjectID/src/error",
-				&TestValueReaderWriter{},
-				&TestValueReaderWriter{bsontype: bsontype.ObjectID, err: errors.New("1"), errAfter: llvrwReadObjectID},
-				errors.New("1"),
-			},
-			{
-				"ObjectID/dst/error",
-				&TestValueReaderWriter{bsontype: bsontype.ObjectID, err: errors.New("2"), errAfter: llvrwWriteObjectID},
-				&TestValueReaderWriter{bsontype: bsontype.ObjectID, readval: primitive.ObjectID{0x01, 0x02, 0x03}},
-				errors.New("2"),
-			},
-			{
-				"Boolean/src/error",
-				&TestValueReaderWriter{},
-				&TestValueReaderWriter{bsontype: bsontype.Boolean, err: errors.New("1"), errAfter: llvrwReadBoolean},
-				errors.New("1"),
-			},
-			{
-				"Boolean/dst/error",
-				&TestValueReaderWriter{bsontype: bsontype.Boolean, err: errors.New("2"), errAfter: llvrwWriteBoolean},
-				&TestValueReaderWriter{bsontype: bsontype.Boolean, readval: bool(true)},
-				errors.New("2"),
-			},
-			{
-				"DateTime/src/error",
-				&TestValueReaderWriter{},
-				&TestValueReaderWriter{bsontype: bsontype.DateTime, err: errors.New("1"), errAfter: llvrwReadDateTime},
-				errors.New("1"),
-			},
-			{
-				"DateTime/dst/error",
-				&TestValueReaderWriter{bsontype: bsontype.DateTime, err: errors.New("2"), errAfter: llvrwWriteDateTime},
-				&TestValueReaderWriter{bsontype: bsontype.DateTime, readval: int64(1234567890)},
-				errors.New("2"),
-			},
-			{
-				"Null/src/error",
-				&TestValueReaderWriter{},
-				&TestValueReaderWriter{bsontype: bsontype.Null, err: errors.New("1"), errAfter: llvrwReadNull},
-				errors.New("1"),
-			},
-			{
-				"Null/dst/error",
-				&TestValueReaderWriter{bsontype: bsontype.Null, err: errors.New("2"), errAfter: llvrwWriteNull},
-				&TestValueReaderWriter{bsontype: bsontype.Null},
-				errors.New("2"),
-			},
-			{
-				"Regex/src/error",
-				&TestValueReaderWriter{},
-				&TestValueReaderWriter{bsontype: bsontype.Regex, err: errors.New("1"), errAfter: llvrwReadRegex},
-				errors.New("1"),
-			},
-			{
-				"Regex/dst/error",
-				&TestValueReaderWriter{bsontype: bsontype.Regex, err: errors.New("2"), errAfter: llvrwWriteRegex},
-				&TestValueReaderWriter{
-					bsontype: bsontype.Regex,
-					readval: bsoncore.Value{
-						Type: bsontype.Regex,
-						Data: bsoncore.AppendRegex(nil, "hello", "world"),
-					},
-				},
-				errors.New("2"),
-			},
-			{
-				"DBPointer/src/error",
-				&TestValueReaderWriter{},
-				&TestValueReaderWriter{bsontype: bsontype.DBPointer, err: errors.New("1"), errAfter: llvrwReadDBPointer},
-				errors.New("1"),
-			},
-			{
-				"DBPointer/dst/error",
-				&TestValueReaderWriter{bsontype: bsontype.DBPointer, err: errors.New("2"), errAfter: llvrwWriteDBPointer},
-				&TestValueReaderWriter{
-					bsontype: bsontype.DBPointer,
-					readval: bsoncore.Value{
-						Type: bsontype.DBPointer,
-						Data: bsoncore.AppendDBPointer(nil, "foo", primitive.ObjectID{0x01, 0x02, 0x03}),
-					},
-				},
-				errors.New("2"),
-			},
-			{
-				"Javascript/src/error",
-				&TestValueReaderWriter{},
-				&TestValueReaderWriter{bsontype: bsontype.JavaScript, err: errors.New("1"), errAfter: llvrwReadJavascript},
-				errors.New("1"),
-			},
-			{
-				"Javascript/dst/error",
-				&TestValueReaderWriter{bsontype: bsontype.JavaScript, err: errors.New("2"), errAfter: llvrwWriteJavascript},
-				&TestValueReaderWriter{bsontype: bsontype.JavaScript, readval: string("hello, world")},
-				errors.New("2"),
-			},
-			{
-				"Symbol/src/error",
-				&TestValueReaderWriter{},
-				&TestValueReaderWriter{bsontype: bsontype.Symbol, err: errors.New("1"), errAfter: llvrwReadSymbol},
-				errors.New("1"),
-			},
-			{
-				"Symbol/dst/error",
-				&TestValueReaderWriter{bsontype: bsontype.Symbol, err: errors.New("2"), errAfter: llvrwWriteSymbol},
-				&TestValueReaderWriter{
-					bsontype: bsontype.Symbol,
-					readval: bsoncore.Value{
-						Type: bsontype.Symbol,
-						Data: bsoncore.AppendSymbol(nil, "hello, world"),
-					},
-				},
-				errors.New("2"),
-			},
-			{
-				"CodeWithScope/src/error",
-				&TestValueReaderWriter{},
-				&TestValueReaderWriter{bsontype: bsontype.CodeWithScope, err: errors.New("1"), errAfter: llvrwReadCodeWithScope},
-				errors.New("1"),
-			},
-			{
-				"CodeWithScope/dst/error",
-				&TestValueReaderWriter{bsontype: bsontype.CodeWithScope, err: errors.New("2"), errAfter: llvrwWriteCodeWithScope},
-				&TestValueReaderWriter{bsontype: bsontype.CodeWithScope},
-				errors.New("2"),
-			},
-			{
-				"CodeWithScope/dst/copyDocumentCore error",
-				&TestValueReaderWriter{err: errors.New("3"), errAfter: llvrwWriteDocumentElement},
-				&TestValueReaderWriter{bsontype: bsontype.CodeWithScope},
-				errors.New("3"),
-			},
-			{
-				"Int32/src/error",
-				&TestValueReaderWriter{},
-				&TestValueReaderWriter{bsontype: bsontype.Int32, err: errors.New("1"), errAfter: llvrwReadInt32},
-				errors.New("1"),
-			},
-			{
-				"Int32/dst/error",
-				&TestValueReaderWriter{bsontype: bsontype.Int32, err: errors.New("2"), errAfter: llvrwWriteInt32},
-				&TestValueReaderWriter{bsontype: bsontype.Int32, readval: int32(12345)},
-				errors.New("2"),
-			},
-			{
-				"Timestamp/src/error",
-				&TestValueReaderWriter{},
-				&TestValueReaderWriter{bsontype: bsontype.Timestamp, err: errors.New("1"), errAfter: llvrwReadTimestamp},
-				errors.New("1"),
-			},
-			{
-				"Timestamp/dst/error",
-				&TestValueReaderWriter{bsontype: bsontype.Timestamp, err: errors.New("2"), errAfter: llvrwWriteTimestamp},
-				&TestValueReaderWriter{
-					bsontype: bsontype.Timestamp,
-					readval: bsoncore.Value{
-						Type: bsontype.Timestamp,
-						Data: bsoncore.AppendTimestamp(nil, 12345, 67890),
-					},
-				},
-				errors.New("2"),
-			},
-			{
-				"Int64/src/error",
-				&TestValueReaderWriter{},
-				&TestValueReaderWriter{bsontype: bsontype.Int64, err: errors.New("1"), errAfter: llvrwReadInt64},
-				errors.New("1"),
-			},
-			{
-				"Int64/dst/error",
-				&TestValueReaderWriter{bsontype: bsontype.Int64, err: errors.New("2"), errAfter: llvrwWriteInt64},
-				&TestValueReaderWriter{bsontype: bsontype.Int64, readval: int64(1234567890)},
-				errors.New("2"),
-			},
-			{
-				"Decimal128/src/error",
-				&TestValueReaderWriter{},
-				&TestValueReaderWriter{bsontype: bsontype.Decimal128, err: errors.New("1"), errAfter: llvrwReadDecimal128},
-				errors.New("1"),
-			},
-			{
-				"Decimal128/dst/error",
-				&TestValueReaderWriter{bsontype: bsontype.Decimal128, err: errors.New("2"), errAfter: llvrwWriteDecimal128},
-				&TestValueReaderWriter{bsontype: bsontype.Decimal128, readval: primitive.NewDecimal128(12345, 67890)},
-				errors.New("2"),
-			},
-			{
-				"MinKey/src/error",
-				&TestValueReaderWriter{},
-				&TestValueReaderWriter{bsontype: bsontype.MinKey, err: errors.New("1"), errAfter: llvrwReadMinKey},
-				errors.New("1"),
-			},
-			{
-				"MinKey/dst/error",
-				&TestValueReaderWriter{bsontype: bsontype.MinKey, err: errors.New("2"), errAfter: llvrwWriteMinKey},
-				&TestValueReaderWriter{bsontype: bsontype.MinKey},
-				errors.New("2"),
-			},
-			{
-				"MaxKey/src/error",
-				&TestValueReaderWriter{},
-				&TestValueReaderWriter{bsontype: bsontype.MaxKey, err: errors.New("1"), errAfter: llvrwReadMaxKey},
-				errors.New("1"),
-			},
-			{
-				"MaxKey/dst/error",
-				&TestValueReaderWriter{bsontype: bsontype.MaxKey, err: errors.New("2"), errAfter: llvrwWriteMaxKey},
-				&TestValueReaderWriter{bsontype: bsontype.MaxKey},
-				errors.New("2"),
-			},
-			{
-				"Unknown BSON type error",
-				&TestValueReaderWriter{},
-				&TestValueReaderWriter{},
-				fmt.Errorf("Cannot copy unknown BSON type %s", bsontype.Type(0)),
-			},
-		}
-
-		for _, tc := range testCases {
-			t.Run(tc.name, func(t *testing.T) {
-				tc.dst.t, tc.src.t = t, t
-				err := Copier{}.CopyValue(tc.dst, tc.src)
-				if !compareErrors(err, tc.err) {
-					t.Errorf("Did not receive expected error. got %v; want %v", err, tc.err)
-				}
-			})
-		}
-	})
-	t.Run("CopyValueFromBytes", func(t *testing.T) {
-		t.Run("BytesWriter", func(t *testing.T) {
-			vw := newValueWriterFromSlice(make([]byte, 0))
-			_, err := vw.WriteDocument()
-			noerr(t, err)
-			_, err = vw.WriteDocumentElement("foo")
-			noerr(t, err)
-			err = Copier{}.CopyValueFromBytes(vw, bsontype.String, bsoncore.AppendString(nil, "bar"))
-			noerr(t, err)
-			err = vw.WriteDocumentEnd()
-			noerr(t, err)
-			var idx int32
-			want, err := bsoncore.AppendDocumentEnd(
-				bsoncore.AppendStringElement(
-					bsoncore.AppendDocumentStartInline(nil, &idx),
-					"foo", "bar",
-				),
-				idx,
-			)
-			noerr(t, err)
-			got := vw.buf
-			if !bytes.Equal(got, want) {
-				t.Errorf("Bytes are not equal. got %v; want %v", got, want)
-			}
-		})
-		t.Run("Non BytesWriter", func(t *testing.T) {
-			llvrw := &TestValueReaderWriter{t: t}
-			err := Copier{}.CopyValueFromBytes(llvrw, bsontype.String, bsoncore.AppendString(nil, "bar"))
-			noerr(t, err)
-			got, want := llvrw.invoked, llvrwWriteString
-			if got != want {
-				t.Errorf("Incorrect method invoked on llvrw. got %v; want %v", got, want)
-			}
-		})
-	})
-	t.Run("CopyValueToBytes", func(t *testing.T) {
-		t.Run("BytesReader", func(t *testing.T) {
-			var idx int32
-			b, err := bsoncore.AppendDocumentEnd(
-				bsoncore.AppendStringElement(
-					bsoncore.AppendDocumentStartInline(nil, &idx),
-					"hello", "world",
-				),
-				idx,
-			)
-			noerr(t, err)
-			vr := newValueReader(b)
-			_, err = vr.ReadDocument()
-			noerr(t, err)
-			_, _, err = vr.ReadElement()
-			noerr(t, err)
-			btype, got, err := Copier{}.CopyValueToBytes(vr)
-			noerr(t, err)
-			want := bsoncore.AppendString(nil, "world")
-			if btype != bsontype.String {
-				t.Errorf("Incorrect type returned. got %v; want %v", btype, bsontype.String)
-			}
-			if !bytes.Equal(got, want) {
-				t.Errorf("Bytes do not match. got %v; want %v", got, want)
-			}
-		})
-		t.Run("Non BytesReader", func(t *testing.T) {
-			llvrw := &TestValueReaderWriter{t: t, bsontype: bsontype.String, readval: string("Hello, world!")}
-			btype, got, err := Copier{}.CopyValueToBytes(llvrw)
-			noerr(t, err)
-			want := bsoncore.AppendString(nil, "Hello, world!")
-			if btype != bsontype.String {
-				t.Errorf("Incorrect type returned. got %v; want %v", btype, bsontype.String)
-			}
-			if !bytes.Equal(got, want) {
-				t.Errorf("Bytes do not match. got %v; want %v", got, want)
-			}
-		})
-	})
-	t.Run("AppendValueBytes", func(t *testing.T) {
-		t.Run("BytesReader", func(t *testing.T) {
-			var idx int32
-			b, err := bsoncore.AppendDocumentEnd(
-				bsoncore.AppendStringElement(
-					bsoncore.AppendDocumentStartInline(nil, &idx),
-					"hello", "world",
-				),
-				idx,
-			)
-			noerr(t, err)
-			vr := newValueReader(b)
-			_, err = vr.ReadDocument()
-			noerr(t, err)
-			_, _, err = vr.ReadElement()
-			noerr(t, err)
-			btype, got, err := Copier{}.AppendValueBytes(nil, vr)
-			noerr(t, err)
-			want := bsoncore.AppendString(nil, "world")
-			if btype != bsontype.String {
-				t.Errorf("Incorrect type returned. got %v; want %v", btype, bsontype.String)
-			}
-			if !bytes.Equal(got, want) {
-				t.Errorf("Bytes do not match. got %v; want %v", got, want)
-			}
-		})
-		t.Run("Non BytesReader", func(t *testing.T) {
-			llvrw := &TestValueReaderWriter{t: t, bsontype: bsontype.String, readval: string("Hello, world!")}
-			btype, got, err := Copier{}.AppendValueBytes(nil, llvrw)
-			noerr(t, err)
-			want := bsoncore.AppendString(nil, "Hello, world!")
-			if btype != bsontype.String {
-				t.Errorf("Incorrect type returned. got %v; want %v", btype, bsontype.String)
-			}
-			if !bytes.Equal(got, want) {
-				t.Errorf("Bytes do not match. got %v; want %v", got, want)
-			}
-		})
-		t.Run("CopyValue error", func(t *testing.T) {
-			want := errors.New("CopyValue error")
-			llvrw := &TestValueReaderWriter{t: t, bsontype: bsontype.String, err: want, errAfter: llvrwReadString}
-			_, _, got := Copier{}.AppendValueBytes(make([]byte, 0), llvrw)
-			if !compareErrors(got, want) {
-				t.Errorf("Errors do not match. got %v; want %v", got, want)
-			}
-		})
-	})
-}

+ 0 - 9
qyxy/src/mgoutil/go.mongodb.org/mongo-driver/bson/bsonrw/doc.go

@@ -1,9 +0,0 @@
-// Copyright (C) MongoDB, Inc. 2017-present.
-//
-// Licensed under the Apache License, Version 2.0 (the "License"); you may
-// not use this file except in compliance with the License. You may obtain
-// a copy of the License at http://www.apache.org/licenses/LICENSE-2.0
-
-// Package bsonrw contains abstractions for reading and writing
-// BSON and BSON like types from sources.
-package bsonrw // import "go.mongodb.org/mongo-driver/bson/bsonrw"

Някои файлове не бяха показани, защото твърде много файлове са промени