>

源码地址:
https://github.com/go-mgo/mgo

代码结构

最核心的 4个文件:

679 ./cluster.go
452 ./server.go
4722 ./session.go
707 ./socket.go

$ wc -l `find ./ -name "*.go"`
   467 ./auth.go
  1180 ./auth_test.go
   721 ./bson/bson.go
  1823 ./bson/bson_test.go
   844 ./bson/decode.go
   509 ./bson/encode.go
   241 ./bson/specdata_test.go
   351 ./bulk.go
   504 ./bulk_test.go
   679 ./cluster.go
  1978 ./cluster_test.go
   196 ./dbtest/dbserver.go
   108 ./dbtest/dbserver_test.go
    12 ./dbtest/export_test.go
    31 ./doc.go
    33 ./export_test.go
   761 ./gridfs.go
   708 ./gridfs_test.go
   138 ./internal/sasl/sasl.go
   140 ./internal/sasl/sasl_windows.go
   266 ./internal/scram/scram.go
    67 ./internal/scram/scram_test.go
   133 ./log.go
    91 ./queue.go
   101 ./queue_test.go
     5 ./raceoff.go
     5 ./raceon.go
    11 ./saslimpl.go
    11 ./saslstub.go
   452 ./server.go
  4722 ./session.go
  4127 ./session_test.go
   707 ./socket.go
   147 ./stats.go
   259 ./suite_test.go
    15 ./syscall_test.go
    11 ./syscall_windows_test.go
    12 ./testserver/export_test.go
   168 ./testserver/testserver.go
   108 ./testserver/testserver_test.go
    68 ./txn/chaos.go
   109 ./txn/debug.go
   205 ./txn/dockey_test.go
   985 ./txn/flusher.go
   101 ./txn/mgo_test.go
   388 ./txn/sim_test.go
    94 ./txn/tarjan.go
    44 ./txn/tarjan_test.go
   611 ./txn/txn.go
   753 ./txn/txn_test.go
 26200 total