├── src ├── github.com │ ├── dolotech │ │ ├── lib │ │ │ ├── README.md │ │ │ ├── utils │ │ │ │ ├── map_list_test.go │ │ │ │ ├── waitgroup.go │ │ │ │ ├── string_2_bytes.go │ │ │ │ ├── stack.go │ │ │ │ ├── sign.go │ │ │ │ ├── string_2_bytes_test.go │ │ │ │ ├── map.go │ │ │ │ ├── queue.go │ │ │ │ ├── aes.go │ │ │ │ ├── random.go │ │ │ │ └── structandmap.go │ │ │ ├── pse │ │ │ │ ├── pse_solaris.go │ │ │ │ ├── pse_rumprun.go │ │ │ │ ├── pse_darwin.go │ │ │ │ ├── pse_test.go │ │ │ │ └── pse_freebsd.go │ │ │ ├── route │ │ │ │ ├── router_test.go │ │ │ │ └── route_msg.go │ │ │ ├── filter │ │ │ │ └── readme.txt │ │ │ ├── db │ │ │ │ └── client_test.go │ │ │ └── csv │ │ │ │ ├── csv.go │ │ │ │ ├── example_marshal_test.go │ │ │ │ ├── example_test.go │ │ │ │ ├── csv_test.go │ │ │ │ ├── bench_test.go │ │ │ │ └── encode_test.go │ │ └── leaf │ │ │ ├── version.go │ │ │ ├── network │ │ │ ├── agent.go │ │ │ ├── conn.go │ │ │ └── processor.go │ │ │ ├── gate │ │ │ └── agent.go │ │ │ ├── conf │ │ │ └── conf.go │ │ │ ├── module │ │ │ ├── go_test.go │ │ │ └── module.go │ │ │ ├── leaf.go │ │ │ ├── README.md │ │ │ ├── room │ │ │ └── interface.go │ │ │ └── timer │ │ │ ├── example_test.go │ │ │ └── timer.go │ ├── go-xorm │ │ ├── xorm │ │ │ ├── VERSION │ │ │ ├── gen_reserved.sh │ │ │ ├── types.go │ │ │ ├── sqlite3_driver.go │ │ │ ├── error.go │ │ │ ├── odbc_driver.go │ │ │ ├── oci8_driver.go │ │ │ ├── memory_store.go │ │ │ ├── goracle_driver.go │ │ │ ├── processors.go │ │ │ ├── mysql_driver.go │ │ │ ├── LICENSE │ │ │ ├── mymysql_driver.go │ │ │ └── syslogger.go │ │ └── core │ │ │ ├── benchmark.sh │ │ │ ├── error.go │ │ │ ├── converstion.go │ │ │ ├── pk.go │ │ │ ├── driver.go │ │ │ ├── ilogger.go │ │ │ ├── scan.go │ │ │ ├── index.go │ │ │ ├── LICENSE │ │ │ └── filter.go │ ├── labstack │ │ └── gommon │ │ │ ├── gommon.go │ │ │ ├── log │ │ │ ├── README.md │ │ │ ├── white.go │ │ │ └── color.go │ │ │ ├── random │ │ │ ├── random_test.go │ │ │ └── random.go │ │ │ ├── bytes │ │ │ ├── README.md │ │ │ └── bytes_test.go │ │ │ └── color │ │ │ └── color_test.go │ ├── stretchr │ │ └── testify │ │ │ ├── http │ │ │ ├── doc.go │ │ │ ├── test_round_tripper.go │ │ │ └── test_response_writer.go │ │ │ ├── require │ │ │ ├── require_forward.go.tmpl │ │ │ ├── require.go.tmpl │ │ │ ├── forward_requirements.go │ │ │ ├── doc.go │ │ │ └── requirements.go │ │ │ ├── assert │ │ │ ├── assertion_format.go.tmpl │ │ │ ├── assertion_forward.go.tmpl │ │ │ ├── errors.go │ │ │ ├── forward_assertions.go │ │ │ └── doc.go │ │ │ ├── package_test.go │ │ │ ├── Gopkg.toml │ │ │ ├── vendor │ │ │ └── github.com │ │ │ │ ├── stretchr │ │ │ │ └── objx │ │ │ │ │ ├── constants.go │ │ │ │ │ ├── security.go │ │ │ │ │ ├── tests.go │ │ │ │ │ ├── LICENSE │ │ │ │ │ └── value.go │ │ │ │ ├── davecgh │ │ │ │ └── go-spew │ │ │ │ │ ├── LICENSE │ │ │ │ │ └── spew │ │ │ │ │ └── bypasssafe.go │ │ │ │ └── pmezard │ │ │ │ └── go-difflib │ │ │ │ └── LICENSE │ │ │ ├── Gopkg.lock │ │ │ ├── doc.go │ │ │ ├── LICENSE │ │ │ ├── suite │ │ │ └── interfaces.go │ │ │ └── mock │ │ │ └── doc.go │ ├── lib │ │ └── pq │ │ │ ├── oid │ │ │ ├── doc.go │ │ │ └── gen.go │ │ │ ├── user_posix.go │ │ │ ├── user_windows.go │ │ │ ├── LICENSE.md │ │ │ ├── CONTRIBUTING.md │ │ │ ├── url.go │ │ │ └── buf.go │ ├── golang │ │ └── protobuf │ │ │ ├── AUTHORS │ │ │ ├── CONTRIBUTORS │ │ │ ├── .gitignore │ │ │ ├── .travis.yml │ │ │ ├── descriptor │ │ │ └── descriptor_test.go │ │ │ ├── proto │ │ │ ├── map_test.go │ │ │ ├── Makefile │ │ │ └── testdata │ │ │ │ └── Makefile │ │ │ ├── ptypes │ │ │ ├── regen.sh │ │ │ └── doc.go │ │ │ ├── LICENSE │ │ │ ├── protoc-gen-go │ │ │ ├── Makefile │ │ │ ├── link_grpc.go │ │ │ ├── testdata │ │ │ │ ├── imp3.proto │ │ │ │ ├── extension_extra.proto │ │ │ │ ├── multi │ │ │ │ │ ├── multi3.proto │ │ │ │ │ ├── multi2.proto │ │ │ │ │ └── multi1.proto │ │ │ │ ├── imp2.proto │ │ │ │ ├── main_test.go │ │ │ │ └── extension_base.proto │ │ │ ├── generator │ │ │ │ └── Makefile │ │ │ └── descriptor │ │ │ │ └── Makefile │ │ │ ├── Make.protobuf │ │ │ └── jsonpb │ │ │ └── jsonpb_test_proto │ │ │ └── Makefile │ ├── gorilla │ │ └── websocket │ │ │ ├── AUTHORS │ │ │ ├── .gitignore │ │ │ ├── examples │ │ │ ├── autobahn │ │ │ │ ├── README.md │ │ │ │ └── fuzzingclient.json │ │ │ ├── filewatch │ │ │ │ └── README.md │ │ │ ├── echo │ │ │ │ ├── README.md │ │ │ │ └── client.go │ │ │ ├── command │ │ │ │ └── README.md │ │ │ └── chat │ │ │ │ ├── main.go │ │ │ │ └── hub.go │ │ │ ├── conn_write.go │ │ │ ├── mask_safe.go │ │ │ ├── client_clone.go │ │ │ ├── .travis.yml │ │ │ ├── conn_read.go │ │ │ ├── conn_write_legacy.go │ │ │ ├── conn_read_legacy.go │ │ │ ├── client_test.go │ │ │ ├── LICENSE │ │ │ ├── mask.go │ │ │ ├── example_test.go │ │ │ ├── client_clone_legacy.go │ │ │ ├── json.go │ │ │ └── mask_test.go │ └── davecgh │ │ └── go-spew │ │ ├── LICENSE │ │ └── spew │ │ └── bypasssafe.go ├── server │ ├── gate │ │ ├── external.go │ │ ├── router.go │ │ └── internal │ │ │ └── module.go │ ├── login │ │ ├── external.go │ │ └── internal │ │ │ ├── module.go │ │ │ └── handler.go │ ├── game │ │ ├── external.go │ │ └── internal │ │ │ ├── pot_test.go │ │ │ ├── chanrpc.go │ │ │ ├── room_test.go │ │ │ ├── module.go │ │ │ └── pot.go │ ├── algorithm │ │ ├── dealer_test.go │ │ ├── sort_test.go │ │ ├── dealer.go │ │ ├── pk.go │ │ └── constan.go │ ├── base │ │ └── skeleton.go │ ├── model │ │ ├── room_data_test.go │ │ ├── constan.go │ │ ├── room_list_test.go │ │ ├── user_data_test.go │ │ └── room_data.go │ └── conf │ │ └── conf.go └── main.go ├── .gitignore └── bin ├── client ├── README.md ├── project.json ├── .gitignore ├── assets │ ├── Scene │ │ └── main.fire.meta │ ├── resources │ │ ├── splash.gif │ │ ├── splash.png │ │ ├── game_cards.png │ │ ├── splash.gif.meta │ │ ├── GameMain_6p.png │ │ ├── game_desk_bg.jpg │ │ ├── audio │ │ │ ├── audio_check.wav.meta │ │ │ ├── audio_fold.wav.meta │ │ │ ├── audio_allinWin.wav.meta │ │ │ ├── audio_check.wav │ │ │ ├── audio_chipsToPot.wav.meta │ │ │ ├── audio_fold.wav │ │ │ ├── audio_normalWin.wav.meta │ │ │ ├── audio_pokerClick.caf.meta │ │ │ ├── audio_pokerClick.mp3.meta │ │ │ ├── audio_timeout.wav.meta │ │ │ ├── audio_yourTurn.wav.meta │ │ │ ├── audio_allinWin.wav │ │ │ ├── audio_chipsToTable.wav.meta │ │ │ ├── audio_distributeCard.wav.meta │ │ │ ├── audio_timeout.wav │ │ │ ├── audio_yourTurn.wav │ │ │ ├── audio_chipsToPot.wav │ │ │ ├── audio_normalWin.wav │ │ │ ├── audio_pokerClick.caf │ │ │ ├── audio_pokerClick.mp3 │ │ │ ├── audio_chipsToTable.wav │ │ │ └── audio_distributeCard.wav │ │ ├── game_cards_6p.png │ │ ├── game_desk_bg_6p.jpg │ │ ├── audio.meta │ │ ├── splash.png.meta │ │ ├── GameMain_6p.png.meta │ │ ├── game_desk_bg.jpg.meta │ │ ├── game_cards.png.meta │ │ ├── game_cards_6p.png.meta │ │ └── game_desk_bg_6p.jpg.meta │ ├── Scene.meta │ ├── Script.meta │ ├── resources.meta │ └── Script │ │ ├── Common.js.meta │ │ ├── main.js.meta │ │ ├── CountDown.js.meta │ │ └── Encoding.js.meta └── jsconfig.json ├── build-linux.sh └── build-win.sh /src/github.com/dolotech/lib/README.md: -------------------------------------------------------------------------------- 1 | -------------------------------------------------------------------------------- /src/github.com/go-xorm/xorm/VERSION: -------------------------------------------------------------------------------- 1 | xorm v0.5.5.0711 2 | -------------------------------------------------------------------------------- /.gitignore: -------------------------------------------------------------------------------- 1 | .idea/* 2 | pkg/* 3 | bin/game.exe 4 | bin/game 5 | -------------------------------------------------------------------------------- /bin/client/README.md: -------------------------------------------------------------------------------- 1 | # Cocos Creator 写的一个德州扑克的游戏回放,仅供参考 2 | -------------------------------------------------------------------------------- /src/github.com/labstack/gommon/gommon.go: -------------------------------------------------------------------------------- 1 | package gommon 2 | -------------------------------------------------------------------------------- /src/github.com/go-xorm/core/benchmark.sh: -------------------------------------------------------------------------------- 1 | go test -v -bench=. -run=XXX 2 | -------------------------------------------------------------------------------- /src/github.com/dolotech/leaf/version.go: -------------------------------------------------------------------------------- 1 | package leaf 2 | 3 | const version = "1.1.2" 4 | -------------------------------------------------------------------------------- /bin/client/project.json: -------------------------------------------------------------------------------- 1 | { 2 | "engine": "cocos-creator-js", 3 | "packages": "packages" 4 | } -------------------------------------------------------------------------------- /bin/client/.gitignore: -------------------------------------------------------------------------------- 1 | #IDE 2 | /library 3 | /local 4 | /build 5 | /temp 6 | /.idea 7 | /settings 8 | -------------------------------------------------------------------------------- /src/github.com/stretchr/testify/http/doc.go: -------------------------------------------------------------------------------- 1 | // Package http DEPRECATED USE net/http/httptest 2 | package http 3 | -------------------------------------------------------------------------------- /src/github.com/labstack/gommon/log/README.md: -------------------------------------------------------------------------------- 1 | ## WORK IN PROGRESS 2 | 3 | ### Usage 4 | 5 | [log_test.go](log_test.go) 6 | -------------------------------------------------------------------------------- /src/github.com/dolotech/leaf/network/agent.go: -------------------------------------------------------------------------------- 1 | package network 2 | 3 | type Agent interface { 4 | Run() 5 | OnClose() 6 | } 7 | -------------------------------------------------------------------------------- /bin/client/assets/Scene/main.fire.meta: -------------------------------------------------------------------------------- 1 | { 2 | "ver": "1.0.0", 3 | "uuid": "b1a3242c-6595-42df-a0fc-e177f727763d", 4 | "subMetas": {} 5 | } -------------------------------------------------------------------------------- /bin/client/assets/resources/splash.gif: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/dolotech/Texas-Hold-em-Poker/HEAD/bin/client/assets/resources/splash.gif -------------------------------------------------------------------------------- /bin/client/assets/resources/splash.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/dolotech/Texas-Hold-em-Poker/HEAD/bin/client/assets/resources/splash.png -------------------------------------------------------------------------------- /bin/client/assets/resources/game_cards.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/dolotech/Texas-Hold-em-Poker/HEAD/bin/client/assets/resources/game_cards.png -------------------------------------------------------------------------------- /bin/client/assets/resources/splash.gif.meta: -------------------------------------------------------------------------------- 1 | { 2 | "ver": "1.0.0", 3 | "uuid": "14855b17-56e8-473b-8923-ebbe56d4cc81", 4 | "subMetas": {} 5 | } -------------------------------------------------------------------------------- /bin/client/assets/resources/GameMain_6p.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/dolotech/Texas-Hold-em-Poker/HEAD/bin/client/assets/resources/GameMain_6p.png -------------------------------------------------------------------------------- /bin/client/assets/resources/game_desk_bg.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/dolotech/Texas-Hold-em-Poker/HEAD/bin/client/assets/resources/game_desk_bg.jpg -------------------------------------------------------------------------------- /bin/client/assets/Scene.meta: -------------------------------------------------------------------------------- 1 | { 2 | "ver": "1.0.1", 3 | "uuid": "a6716ca2-df58-41aa-b8d3-8ca203720a85", 4 | "isGroup": false, 5 | "subMetas": {} 6 | } -------------------------------------------------------------------------------- /bin/client/assets/Script.meta: -------------------------------------------------------------------------------- 1 | { 2 | "ver": "1.0.1", 3 | "uuid": "3af1e10d-442f-4956-9f83-2dec73688db7", 4 | "isGroup": false, 5 | "subMetas": {} 6 | } -------------------------------------------------------------------------------- /bin/client/assets/resources/audio/audio_check.wav.meta: -------------------------------------------------------------------------------- 1 | { 2 | "ver": "1.0.0", 3 | "uuid": "ae2e6fb2-2be9-4ced-a4e9-2ee56c9667ed", 4 | "subMetas": {} 5 | } -------------------------------------------------------------------------------- /bin/client/assets/resources/audio/audio_fold.wav.meta: -------------------------------------------------------------------------------- 1 | { 2 | "ver": "1.0.0", 3 | "uuid": "87dcf996-d47c-4b0e-a821-a1d034aad12b", 4 | "subMetas": {} 5 | } -------------------------------------------------------------------------------- /bin/client/assets/resources/game_cards_6p.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/dolotech/Texas-Hold-em-Poker/HEAD/bin/client/assets/resources/game_cards_6p.png -------------------------------------------------------------------------------- /bin/client/assets/resources/game_desk_bg_6p.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/dolotech/Texas-Hold-em-Poker/HEAD/bin/client/assets/resources/game_desk_bg_6p.jpg -------------------------------------------------------------------------------- /bin/client/assets/resources.meta: -------------------------------------------------------------------------------- 1 | { 2 | "ver": "1.0.1", 3 | "uuid": "1b5c7d50-37bb-4fb6-9e86-28af5dde70ef", 4 | "isGroup": false, 5 | "subMetas": {} 6 | } -------------------------------------------------------------------------------- /bin/client/assets/resources/audio/audio_allinWin.wav.meta: -------------------------------------------------------------------------------- 1 | { 2 | "ver": "1.0.0", 3 | "uuid": "0dd8cf6f-e146-4622-8b8e-7c9dc5f77a48", 4 | "subMetas": {} 5 | } -------------------------------------------------------------------------------- /bin/client/assets/resources/audio/audio_check.wav: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/dolotech/Texas-Hold-em-Poker/HEAD/bin/client/assets/resources/audio/audio_check.wav -------------------------------------------------------------------------------- /bin/client/assets/resources/audio/audio_chipsToPot.wav.meta: -------------------------------------------------------------------------------- 1 | { 2 | "ver": "1.0.0", 3 | "uuid": "97c76f08-6b20-4757-aefb-5a95e710cb13", 4 | "subMetas": {} 5 | } -------------------------------------------------------------------------------- /bin/client/assets/resources/audio/audio_fold.wav: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/dolotech/Texas-Hold-em-Poker/HEAD/bin/client/assets/resources/audio/audio_fold.wav -------------------------------------------------------------------------------- /bin/client/assets/resources/audio/audio_normalWin.wav.meta: -------------------------------------------------------------------------------- 1 | { 2 | "ver": "1.0.0", 3 | "uuid": "e32b382b-4248-4a95-9c83-6e170adb4aa4", 4 | "subMetas": {} 5 | } -------------------------------------------------------------------------------- /bin/client/assets/resources/audio/audio_pokerClick.caf.meta: -------------------------------------------------------------------------------- 1 | { 2 | "ver": "1.0.0", 3 | "uuid": "2f80411a-9257-4450-aa30-4e860f2ff54b", 4 | "subMetas": {} 5 | } -------------------------------------------------------------------------------- /bin/client/assets/resources/audio/audio_pokerClick.mp3.meta: -------------------------------------------------------------------------------- 1 | { 2 | "ver": "1.0.0", 3 | "uuid": "b3e3bc15-0e5e-4d16-932c-08651a89045d", 4 | "subMetas": {} 5 | } -------------------------------------------------------------------------------- /bin/client/assets/resources/audio/audio_timeout.wav.meta: -------------------------------------------------------------------------------- 1 | { 2 | "ver": "1.0.0", 3 | "uuid": "3ef5c879-e7cd-4121-be05-a98fa397e548", 4 | "subMetas": {} 5 | } -------------------------------------------------------------------------------- /bin/client/assets/resources/audio/audio_yourTurn.wav.meta: -------------------------------------------------------------------------------- 1 | { 2 | "ver": "1.0.0", 3 | "uuid": "85960017-45b4-40f2-a17e-75cdfda31054", 4 | "subMetas": {} 5 | } -------------------------------------------------------------------------------- /src/server/gate/external.go: -------------------------------------------------------------------------------- 1 | package gate 2 | 3 | import ( 4 | "server/gate/internal" 5 | ) 6 | 7 | var ( 8 | Module = new(internal.Module) 9 | ) 10 | -------------------------------------------------------------------------------- /bin/client/assets/Script/Common.js.meta: -------------------------------------------------------------------------------- 1 | { 2 | "ver": "1.0.2", 3 | "uuid": "b91d4d1c-d6e8-4abe-8ab4-226f9e1dce57", 4 | "isPlugin": false, 5 | "subMetas": {} 6 | } -------------------------------------------------------------------------------- /bin/client/assets/Script/main.js.meta: -------------------------------------------------------------------------------- 1 | { 2 | "ver": "1.0.2", 3 | "uuid": "ba49ca20-5856-400d-8933-bc1dfd520dc1", 4 | "isPlugin": false, 5 | "subMetas": {} 6 | } -------------------------------------------------------------------------------- /bin/client/assets/resources/audio.meta: -------------------------------------------------------------------------------- 1 | { 2 | "ver": "1.0.1", 3 | "uuid": "0a834482-9f57-4f53-af0e-98a99ad7438a", 4 | "isGroup": false, 5 | "subMetas": {} 6 | } -------------------------------------------------------------------------------- /bin/client/assets/resources/audio/audio_allinWin.wav: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/dolotech/Texas-Hold-em-Poker/HEAD/bin/client/assets/resources/audio/audio_allinWin.wav -------------------------------------------------------------------------------- /bin/client/assets/resources/audio/audio_chipsToTable.wav.meta: -------------------------------------------------------------------------------- 1 | { 2 | "ver": "1.0.0", 3 | "uuid": "2773b2b7-4482-4133-9900-7fdcd308d2f9", 4 | "subMetas": {} 5 | } -------------------------------------------------------------------------------- /bin/client/assets/resources/audio/audio_distributeCard.wav.meta: -------------------------------------------------------------------------------- 1 | { 2 | "ver": "1.0.0", 3 | "uuid": "0b5c008e-cf15-4b8c-be63-8b1197cb1789", 4 | "subMetas": {} 5 | } -------------------------------------------------------------------------------- /bin/client/assets/resources/audio/audio_timeout.wav: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/dolotech/Texas-Hold-em-Poker/HEAD/bin/client/assets/resources/audio/audio_timeout.wav -------------------------------------------------------------------------------- /bin/client/assets/resources/audio/audio_yourTurn.wav: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/dolotech/Texas-Hold-em-Poker/HEAD/bin/client/assets/resources/audio/audio_yourTurn.wav -------------------------------------------------------------------------------- /bin/client/assets/Script/CountDown.js.meta: -------------------------------------------------------------------------------- 1 | { 2 | "ver": "1.0.2", 3 | "uuid": "ac50a2dc-5c7b-450e-8387-93e1500ca396", 4 | "isPlugin": false, 5 | "subMetas": {} 6 | } -------------------------------------------------------------------------------- /bin/client/assets/Script/Encoding.js.meta: -------------------------------------------------------------------------------- 1 | { 2 | "ver": "1.0.2", 3 | "uuid": "2d3ef493-9e65-47f1-a3cc-c30517fcd563", 4 | "isPlugin": true, 5 | "subMetas": {} 6 | } -------------------------------------------------------------------------------- /bin/client/assets/resources/audio/audio_chipsToPot.wav: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/dolotech/Texas-Hold-em-Poker/HEAD/bin/client/assets/resources/audio/audio_chipsToPot.wav -------------------------------------------------------------------------------- /bin/client/assets/resources/audio/audio_normalWin.wav: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/dolotech/Texas-Hold-em-Poker/HEAD/bin/client/assets/resources/audio/audio_normalWin.wav -------------------------------------------------------------------------------- /bin/client/assets/resources/audio/audio_pokerClick.caf: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/dolotech/Texas-Hold-em-Poker/HEAD/bin/client/assets/resources/audio/audio_pokerClick.caf -------------------------------------------------------------------------------- /bin/client/assets/resources/audio/audio_pokerClick.mp3: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/dolotech/Texas-Hold-em-Poker/HEAD/bin/client/assets/resources/audio/audio_pokerClick.mp3 -------------------------------------------------------------------------------- /bin/client/assets/resources/audio/audio_chipsToTable.wav: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/dolotech/Texas-Hold-em-Poker/HEAD/bin/client/assets/resources/audio/audio_chipsToTable.wav -------------------------------------------------------------------------------- /bin/client/assets/resources/audio/audio_distributeCard.wav: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/dolotech/Texas-Hold-em-Poker/HEAD/bin/client/assets/resources/audio/audio_distributeCard.wav -------------------------------------------------------------------------------- /src/github.com/go-xorm/xorm/gen_reserved.sh: -------------------------------------------------------------------------------- 1 | #!/bin/bash 2 | if [ -f $1 ];then 3 | cat $1| awk '{printf("\""$1"\":true,\n")}' 4 | else 5 | echo "argument $1 if not a file!" 6 | fi 7 | -------------------------------------------------------------------------------- /src/github.com/lib/pq/oid/doc.go: -------------------------------------------------------------------------------- 1 | // Package oid contains OID constants 2 | // as defined by the Postgres server. 3 | package oid 4 | 5 | // Oid is a Postgres Object ID. 6 | type Oid uint32 7 | -------------------------------------------------------------------------------- /src/server/login/external.go: -------------------------------------------------------------------------------- 1 | package login 2 | 3 | import ( 4 | "server/login/internal" 5 | ) 6 | 7 | var ( 8 | Module = new(internal.Module) 9 | ChanRPC = internal.ChanRPC 10 | ) 11 | -------------------------------------------------------------------------------- /src/github.com/labstack/gommon/log/white.go: -------------------------------------------------------------------------------- 1 | // +build appengine 2 | 3 | package log 4 | 5 | import ( 6 | "io" 7 | "os" 8 | ) 9 | 10 | func output() io.Writer { 11 | return os.Stdout 12 | } 13 | -------------------------------------------------------------------------------- /src/server/game/external.go: -------------------------------------------------------------------------------- 1 | package game 2 | 3 | import ( 4 | "server/game/internal" 5 | ) 6 | 7 | var ( 8 | Module = new(internal.Module)//建立模块新的 9 | ChanRPC = internal.ChanRPC 10 | ) 11 | -------------------------------------------------------------------------------- /src/github.com/golang/protobuf/AUTHORS: -------------------------------------------------------------------------------- 1 | # This source code refers to The Go Authors for copyright purposes. 2 | # The master list of authors is in the main Go distribution, 3 | # visible at http://tip.golang.org/AUTHORS. 4 | -------------------------------------------------------------------------------- /src/github.com/golang/protobuf/CONTRIBUTORS: -------------------------------------------------------------------------------- 1 | # This source code was written by the Go contributors. 2 | # The master list of contributors is in the main Go distribution, 3 | # visible at http://tip.golang.org/CONTRIBUTORS. 4 | -------------------------------------------------------------------------------- /src/server/algorithm/dealer_test.go: -------------------------------------------------------------------------------- 1 | package algorithm 2 | 3 | import "testing" 4 | 5 | func Test_Dealer(t *testing.T) { 6 | d:= &Cards{} 7 | 8 | d.Shuffle() 9 | d.Shuffle() 10 | t.Logf("%#v ",d) 11 | 12 | } 13 | -------------------------------------------------------------------------------- /src/github.com/go-xorm/core/error.go: -------------------------------------------------------------------------------- 1 | package core 2 | 3 | import "errors" 4 | 5 | var ( 6 | ErrNoMapPointer = errors.New("mp should be a map's pointer") 7 | ErrNoStructPointer = errors.New("mp should be a struct's pointer") 8 | ) 9 | -------------------------------------------------------------------------------- /src/github.com/go-xorm/xorm/types.go: -------------------------------------------------------------------------------- 1 | package xorm 2 | 3 | import ( 4 | "reflect" 5 | 6 | "github.com/go-xorm/core" 7 | ) 8 | 9 | var ( 10 | ptrPkType = reflect.TypeOf(&core.PK{}) 11 | pkType = reflect.TypeOf(core.PK{}) 12 | ) 13 | -------------------------------------------------------------------------------- /src/github.com/stretchr/testify/require/require_forward.go.tmpl: -------------------------------------------------------------------------------- 1 | {{.CommentWithoutT "a"}} 2 | func (a *Assertions) {{.DocInfo.Name}}({{.Params}}) { 3 | if h, ok := a.t.(tHelper); ok { h.Helper() } 4 | {{.DocInfo.Name}}(a.t, {{.ForwardedParams}}) 5 | } 6 | -------------------------------------------------------------------------------- /src/github.com/gorilla/websocket/AUTHORS: -------------------------------------------------------------------------------- 1 | # This is the official list of Gorilla WebSocket authors for copyright 2 | # purposes. 3 | # 4 | # Please keep the list sorted. 5 | 6 | Gary Burd 7 | Joachim Bauch 8 | 9 | -------------------------------------------------------------------------------- /src/github.com/labstack/gommon/log/color.go: -------------------------------------------------------------------------------- 1 | // +build !appengine 2 | 3 | package log 4 | 5 | import ( 6 | "io" 7 | 8 | "github.com/mattn/go-colorable" 9 | ) 10 | 11 | func output() io.Writer { 12 | return colorable.NewColorableStdout() 13 | } 14 | -------------------------------------------------------------------------------- /src/github.com/stretchr/testify/assert/assertion_format.go.tmpl: -------------------------------------------------------------------------------- 1 | {{.CommentFormat}} 2 | func {{.DocInfo.Name}}f(t TestingT, {{.ParamsFormat}}) bool { 3 | if h, ok := t.(tHelper); ok { h.Helper() } 4 | return {{.DocInfo.Name}}(t, {{.ForwardedParamsFormat}}) 5 | } 6 | -------------------------------------------------------------------------------- /src/github.com/stretchr/testify/require/require.go.tmpl: -------------------------------------------------------------------------------- 1 | {{.Comment}} 2 | func {{.DocInfo.Name}}(t TestingT, {{.Params}}) { 3 | if h, ok := t.(tHelper); ok { h.Helper() } 4 | if !assert.{{.DocInfo.Name}}(t, {{.ForwardedParams}}) { 5 | t.FailNow() 6 | } 7 | } 8 | -------------------------------------------------------------------------------- /src/github.com/dolotech/lib/utils/map_list_test.go: -------------------------------------------------------------------------------- 1 | /** 2 | * Created by Michael on 2015/8/4. 3 | */ 4 | package utils 5 | 6 | import "testing" 7 | 8 | func Test_ran(t *testing.T) { 9 | list := &List{} 10 | t.Log(list) 11 | //m := NewMap() 12 | 13 | } 14 | -------------------------------------------------------------------------------- /src/github.com/stretchr/testify/assert/assertion_forward.go.tmpl: -------------------------------------------------------------------------------- 1 | {{.CommentWithoutT "a"}} 2 | func (a *Assertions) {{.DocInfo.Name}}({{.Params}}) bool { 3 | if h, ok := a.t.(tHelper); ok { h.Helper() } 4 | return {{.DocInfo.Name}}(a.t, {{.ForwardedParams}}) 5 | } 6 | -------------------------------------------------------------------------------- /src/github.com/golang/protobuf/.gitignore: -------------------------------------------------------------------------------- 1 | .DS_Store 2 | *.[568ao] 3 | *.ao 4 | *.so 5 | *.pyc 6 | ._* 7 | .nfs.* 8 | [568a].out 9 | *~ 10 | *.orig 11 | core 12 | _obj 13 | _test 14 | _testmain.go 15 | protoc-gen-go/testdata/multi/*.pb.go 16 | _conformance/_conformance 17 | -------------------------------------------------------------------------------- /bin/client/jsconfig.json: -------------------------------------------------------------------------------- 1 | { 2 | "compilerOptions": { 3 | "target": "es6", 4 | "module": "commonjs" 5 | }, 6 | "exclude": [ 7 | "node_modules", 8 | "library", 9 | "local", 10 | "settings", 11 | "temp" 12 | ] 13 | } -------------------------------------------------------------------------------- /src/github.com/stretchr/testify/package_test.go: -------------------------------------------------------------------------------- 1 | package testify 2 | 3 | import ( 4 | "github.com/stretchr/testify/assert" 5 | "testing" 6 | ) 7 | 8 | func TestImports(t *testing.T) { 9 | if assert.Equal(t, 1, 1) != true { 10 | t.Error("Something is wrong.") 11 | } 12 | } 13 | -------------------------------------------------------------------------------- /src/github.com/dolotech/leaf/network/conn.go: -------------------------------------------------------------------------------- 1 | package network 2 | 3 | import ( 4 | "net" 5 | ) 6 | 7 | type Conn interface { 8 | ReadMsg() ([]byte, error) 9 | WriteMsg(args ...[]byte) error 10 | LocalAddr() net.Addr 11 | RemoteAddr() net.Addr 12 | Close() 13 | Destroy() 14 | } 15 | -------------------------------------------------------------------------------- /src/github.com/dolotech/lib/utils/waitgroup.go: -------------------------------------------------------------------------------- 1 | package utils 2 | 3 | 4 | import ( 5 | "sync" 6 | ) 7 | 8 | type WaitGroupWrapper struct { 9 | sync.WaitGroup 10 | } 11 | 12 | func (w *WaitGroupWrapper) Wrap(cb func()) { 13 | w.Add(1) 14 | go func() { 15 | cb() 16 | w.Done() 17 | }() 18 | } -------------------------------------------------------------------------------- /src/github.com/go-xorm/core/converstion.go: -------------------------------------------------------------------------------- 1 | package core 2 | 3 | // Conversion is an interface. A type implements Conversion will according 4 | // the custom method to fill into database and retrieve from database. 5 | type Conversion interface { 6 | FromDB([]byte) error 7 | ToDB() ([]byte, error) 8 | } 9 | -------------------------------------------------------------------------------- /src/github.com/dolotech/lib/pse/pse_solaris.go: -------------------------------------------------------------------------------- 1 | // Copyright 2015-2016 Apcera Inc. All rights reserved. 2 | 3 | package pse 4 | 5 | // This is a placeholder for now. 6 | func ProcUsage(pcpu *float64, rss, vss *int64) error { 7 | *pcpu = 0.0 8 | *rss = 0 9 | *vss = 0 10 | 11 | return nil 12 | } 13 | -------------------------------------------------------------------------------- /src/github.com/dolotech/leaf/gate/agent.go: -------------------------------------------------------------------------------- 1 | package gate 2 | 3 | import ( 4 | "net" 5 | ) 6 | 7 | type Agent interface { 8 | WriteMsg(msg interface{}) 9 | LocalAddr() net.Addr 10 | RemoteAddr() net.Addr 11 | Close() 12 | Destroy() 13 | UserData() interface{} 14 | SetUserData(data interface{}) 15 | } 16 | -------------------------------------------------------------------------------- /src/github.com/labstack/gommon/random/random_test.go: -------------------------------------------------------------------------------- 1 | package random 2 | 3 | import ( 4 | "testing" 5 | 6 | "github.com/stretchr/testify/assert" 7 | ) 8 | 9 | func Test(t *testing.T) { 10 | assert.Len(t, String(32), 32) 11 | r := New() 12 | r.SetCharset(Numeric) 13 | assert.Len(t, r.String(8), 8) 14 | } 15 | -------------------------------------------------------------------------------- /src/github.com/dolotech/leaf/conf/conf.go: -------------------------------------------------------------------------------- 1 | package conf 2 | 3 | var ( 4 | LenStackBuf = 4096 5 | 6 | // console 7 | ConsolePort int 8 | ConsolePrompt string = "Leaf# " 9 | ProfilePath string 10 | 11 | // cluster 12 | ListenAddr string 13 | ConnAddrs []string 14 | PendingWriteNum int 15 | ) 16 | -------------------------------------------------------------------------------- /src/github.com/dolotech/lib/pse/pse_rumprun.go: -------------------------------------------------------------------------------- 1 | // Copyright 2015-2016 Apcera Inc. All rights reserved. 2 | // +build rumprun 3 | 4 | package pse 5 | 6 | // This is a placeholder for now. 7 | func ProcUsage(pcpu *float64, rss, vss *int64) error { 8 | *pcpu = 0.0 9 | *rss = 0 10 | *vss = 0 11 | 12 | return nil 13 | } 14 | -------------------------------------------------------------------------------- /src/github.com/dolotech/leaf/network/processor.go: -------------------------------------------------------------------------------- 1 | package network 2 | 3 | type Processor interface { 4 | // must goroutine safe 5 | Route(msg , userData interface{}) error 6 | // must goroutine safe 7 | Unmarshal(data []byte) (interface{}, error) 8 | // must goroutine safe 9 | Marshal(msg interface{}) ([][]byte, error) 10 | } 11 | -------------------------------------------------------------------------------- /src/github.com/dolotech/lib/route/router_test.go: -------------------------------------------------------------------------------- 1 | package route 2 | 3 | import "testing" 4 | 5 | func TestNewRoute(t *testing.T) { 6 | var r Route 7 | 8 | 9 | type msg struct { 10 | N int 11 | } 12 | 13 | r.Regist(&msg{}, func(m *msg) {t.Log("callback",m)}) 14 | 15 | r.Emit(&msg{123}) 16 | 17 | 18 | 19 | r.Emit(&msg{123}) 20 | } 21 | -------------------------------------------------------------------------------- /src/github.com/stretchr/testify/Gopkg.toml: -------------------------------------------------------------------------------- 1 | [prune] 2 | unused-packages = true 3 | non-go = true 4 | go-tests = true 5 | 6 | [[constraint]] 7 | name = "github.com/davecgh/go-spew" 8 | version = "~1.1.0" 9 | 10 | [[constraint]] 11 | name = "github.com/pmezard/go-difflib" 12 | version = "~1.0.0" 13 | 14 | [[constraint]] 15 | name = "github.com/stretchr/objx" 16 | version = "~0.1.0" 17 | -------------------------------------------------------------------------------- /src/github.com/stretchr/testify/assert/errors.go: -------------------------------------------------------------------------------- 1 | package assert 2 | 3 | import ( 4 | "errors" 5 | ) 6 | 7 | // AnError is an error instance useful for testing. If the code does not care 8 | // about error specifics, and only needs to return the error for example, this 9 | // error should be used to make the test code more readable. 10 | var AnError = errors.New("assert.AnError general error for testing") 11 | -------------------------------------------------------------------------------- /src/github.com/gorilla/websocket/.gitignore: -------------------------------------------------------------------------------- 1 | # Compiled Object files, Static and Dynamic libs (Shared Objects) 2 | *.o 3 | *.a 4 | *.so 5 | 6 | # Folders 7 | _obj 8 | _test 9 | 10 | # Architecture specific extensions/prefixes 11 | *.[568vq] 12 | [568vq].out 13 | 14 | *.cgo1.go 15 | *.cgo2.c 16 | _cgo_defun.c 17 | _cgo_gotypes.go 18 | _cgo_export.* 19 | 20 | _testmain.go 21 | 22 | *.exe 23 | 24 | .idea/ 25 | *.iml 26 | -------------------------------------------------------------------------------- /src/server/login/internal/module.go: -------------------------------------------------------------------------------- 1 | package internal 2 | 3 | import ( 4 | "github.com/dolotech/leaf/module" 5 | "server/base" 6 | ) 7 | 8 | var ( 9 | skeleton = base.NewSkeleton() 10 | ChanRPC = skeleton.ChanRPCServer 11 | ) 12 | 13 | type Module struct { 14 | *module.Skeleton 15 | } 16 | 17 | func (m *Module) OnInit() { 18 | m.Skeleton = skeleton 19 | } 20 | 21 | func (m *Module) OnDestroy() { 22 | 23 | } 24 | -------------------------------------------------------------------------------- /src/github.com/gorilla/websocket/examples/autobahn/README.md: -------------------------------------------------------------------------------- 1 | # Test Server 2 | 3 | This package contains a server for the [Autobahn WebSockets Test Suite](http://autobahn.ws/testsuite). 4 | 5 | To test the server, run 6 | 7 | go run server.go 8 | 9 | and start the client test driver 10 | 11 | wstest -m fuzzingclient -s fuzzingclient.json 12 | 13 | When the client completes, it writes a report to reports/clients/index.html. 14 | -------------------------------------------------------------------------------- /src/github.com/gorilla/websocket/conn_write.go: -------------------------------------------------------------------------------- 1 | // Copyright 2016 The Gorilla WebSocket Authors. All rights reserved. 2 | // Use of this source code is governed by a BSD-style 3 | // license that can be found in the LICENSE file. 4 | 5 | // +build go1.8 6 | 7 | package websocket 8 | 9 | import "net" 10 | 11 | func (c *Conn) writeBufs(bufs ...[]byte) error { 12 | b := net.Buffers(bufs) 13 | _, err := b.WriteTo(c.conn) 14 | return err 15 | } 16 | -------------------------------------------------------------------------------- /src/github.com/gorilla/websocket/mask_safe.go: -------------------------------------------------------------------------------- 1 | // Copyright 2016 The Gorilla WebSocket Authors. All rights reserved. Use of 2 | // this source code is governed by a BSD-style license that can be found in the 3 | // LICENSE file. 4 | 5 | // +build appengine 6 | 7 | package websocket 8 | 9 | func maskBytes(key [4]byte, pos int, b []byte) int { 10 | for i := range b { 11 | b[i] ^= key[pos&3] 12 | pos++ 13 | } 14 | return pos & 3 15 | } 16 | -------------------------------------------------------------------------------- /src/server/game/internal/pot_test.go: -------------------------------------------------------------------------------- 1 | package internal 2 | 3 | import "testing" 4 | 5 | func Test_Pot(t *testing.T) { 6 | bets := []uint32{60,80,90,0,0,0,0,0,0} 7 | res:=calcPot(bets) 8 | //[{180 [1 2 3]} {40 [2 3]} {10 [3]}] 9 | t.Log(res) 10 | 11 | 12 | bets = []uint32{60,60,60,0,0,0,0,0,0} 13 | res=calcPot(bets) 14 | //[{180 [1 2 3]}] 15 | t.Log(res) 16 | 17 | a:= []byte{} 18 | 19 | a = nil 20 | t.Log(len(a)) 21 | 22 | } 23 | -------------------------------------------------------------------------------- /src/github.com/stretchr/testify/vendor/github.com/stretchr/objx/constants.go: -------------------------------------------------------------------------------- 1 | package objx 2 | 3 | const ( 4 | // PathSeparator is the character used to separate the elements 5 | // of the keypath. 6 | // 7 | // For example, `location.address.city` 8 | PathSeparator string = "." 9 | 10 | // SignatureSeparator is the character that is used to 11 | // separate the Base64 string from the security signature. 12 | SignatureSeparator = "_" 13 | ) 14 | -------------------------------------------------------------------------------- /src/github.com/gorilla/websocket/client_clone.go: -------------------------------------------------------------------------------- 1 | // Copyright 2013 The Gorilla WebSocket Authors. All rights reserved. 2 | // Use of this source code is governed by a BSD-style 3 | // license that can be found in the LICENSE file. 4 | 5 | // +build go1.8 6 | 7 | package websocket 8 | 9 | import "crypto/tls" 10 | 11 | func cloneTLSConfig(cfg *tls.Config) *tls.Config { 12 | if cfg == nil { 13 | return &tls.Config{} 14 | } 15 | return cfg.Clone() 16 | } 17 | -------------------------------------------------------------------------------- /src/github.com/stretchr/testify/vendor/github.com/stretchr/objx/security.go: -------------------------------------------------------------------------------- 1 | package objx 2 | 3 | import ( 4 | "crypto/sha1" 5 | "encoding/hex" 6 | ) 7 | 8 | // HashWithKey hashes the specified string using the security 9 | // key. 10 | func HashWithKey(data, key string) string { 11 | hash := sha1.New() 12 | _, err := hash.Write([]byte(data + ":" + key)) 13 | if err != nil { 14 | return "" 15 | } 16 | return hex.EncodeToString(hash.Sum(nil)) 17 | } 18 | -------------------------------------------------------------------------------- /src/github.com/golang/protobuf/.travis.yml: -------------------------------------------------------------------------------- 1 | sudo: false 2 | language: go 3 | go: 4 | - 1.6.x 5 | - 1.7.x 6 | - 1.8.x 7 | - 1.9.x 8 | 9 | install: 10 | - go get -v -d -t github.com/golang/protobuf/... 11 | - curl -L https://github.com/google/protobuf/releases/download/v3.3.0/protoc-3.3.0-linux-x86_64.zip -o /tmp/protoc.zip 12 | - unzip /tmp/protoc.zip -d $HOME/protoc 13 | 14 | env: 15 | - PATH=$HOME/protoc/bin:$PATH 16 | 17 | script: 18 | - make all test 19 | -------------------------------------------------------------------------------- /src/github.com/gorilla/websocket/examples/filewatch/README.md: -------------------------------------------------------------------------------- 1 | # File Watch example. 2 | 3 | This example sends a file to the browser client for display whenever the file is modified. 4 | 5 | $ go get github.com/gorilla/websocket 6 | $ cd `go list -f '{{.Dir}}' github.com/gorilla/websocket/examples/filewatch` 7 | $ go run main.go 8 | # Open http://localhost:8080/ . 9 | # Modify the file to see it update in the browser. 10 | -------------------------------------------------------------------------------- /src/github.com/dolotech/leaf/module/go_test.go: -------------------------------------------------------------------------------- 1 | package module 2 | 3 | import ( 4 | "testing" 5 | "time" 6 | ) 7 | 8 | func TestSkeleton_Go(t *testing.T) { 9 | 10 | s := Skeleton{} 11 | s.Init() 12 | f := func() { 13 | <-time.After(time.Second) 14 | t.Log("ffff") 15 | } 16 | 17 | ch:= make(chan int) 18 | c := func() { 19 | <-time.After(time.Second) 20 | t.Log("ccc") 21 | 22 | ch <- 0 23 | } 24 | 25 | s.Go(f, c) 26 | 27 | t.Log("end",<-ch) 28 | 29 | } 30 | -------------------------------------------------------------------------------- /src/github.com/gorilla/websocket/.travis.yml: -------------------------------------------------------------------------------- 1 | language: go 2 | sudo: false 3 | 4 | matrix: 5 | include: 6 | - go: 1.4 7 | - go: 1.5.x 8 | - go: 1.6.x 9 | - go: 1.7.x 10 | - go: 1.8.x 11 | - go: 1.9.x 12 | - go: 1.10.x 13 | - go: tip 14 | allow_failures: 15 | - go: tip 16 | 17 | script: 18 | - go get -t -v ./... 19 | - diff -u <(echo -n) <(gofmt -d .) 20 | - go vet $(go list ./... | grep -v /vendor/) 21 | - go test -v -race ./... 22 | -------------------------------------------------------------------------------- /src/server/algorithm/sort_test.go: -------------------------------------------------------------------------------- 1 | package algorithm 2 | 3 | import "testing" 4 | 5 | func Test11Base(t *testing.T) { 6 | 7 | cards := Cards{0x12, 0x03, 0x24, 0x35, 0x26, 0x17, 0x33} 8 | var a ValueCounter 9 | a.Set(cards) 10 | ASort(cards, 0, int8(len(cards) -1), &a) 11 | 12 | t.Logf("%#v ",cards) 13 | } 14 | func Test10Base(t *testing.T) { 15 | arr := Cards([]byte{1, 2, 3, 4, 4, 5, 6}) 16 | 17 | arr.Shuffle() 18 | 19 | t.Logf("%#v ", arr) 20 | 21 | t.Logf("%#v ", arr) 22 | } 23 | -------------------------------------------------------------------------------- /src/github.com/gorilla/websocket/conn_read.go: -------------------------------------------------------------------------------- 1 | // Copyright 2016 The Gorilla WebSocket Authors. All rights reserved. 2 | // Use of this source code is governed by a BSD-style 3 | // license that can be found in the LICENSE file. 4 | 5 | // +build go1.5 6 | 7 | package websocket 8 | 9 | import "io" 10 | 11 | func (c *Conn) read(n int) ([]byte, error) { 12 | p, err := c.br.Peek(n) 13 | if err == io.EOF { 14 | err = errUnexpectedEOF 15 | } 16 | c.br.Discard(len(p)) 17 | return p, err 18 | } 19 | -------------------------------------------------------------------------------- /src/server/base/skeleton.go: -------------------------------------------------------------------------------- 1 | package base 2 | 3 | import ( 4 | "github.com/dolotech/leaf/chanrpc" 5 | "github.com/dolotech/leaf/module" 6 | "server/conf" 7 | ) 8 | 9 | func NewSkeleton() *module.Skeleton { 10 | skeleton := &module.Skeleton{ 11 | GoLen: conf.GoLen, 12 | TimerDispatcherLen: conf.TimerDispatcherLen, 13 | AsynCallLen: conf.AsynCallLen, 14 | ChanRPCServer: chanrpc.NewServer(conf.ChanRPCLen), 15 | } 16 | skeleton.Init() 17 | return skeleton 18 | } 19 | -------------------------------------------------------------------------------- /src/github.com/stretchr/testify/http/test_round_tripper.go: -------------------------------------------------------------------------------- 1 | package http 2 | 3 | import ( 4 | "github.com/stretchr/testify/mock" 5 | "net/http" 6 | ) 7 | 8 | // TestRoundTripper DEPRECATED USE net/http/httptest 9 | type TestRoundTripper struct { 10 | mock.Mock 11 | } 12 | 13 | // RoundTrip DEPRECATED USE net/http/httptest 14 | func (t *TestRoundTripper) RoundTrip(req *http.Request) (*http.Response, error) { 15 | args := t.Called(req) 16 | return args.Get(0).(*http.Response), args.Error(1) 17 | } 18 | -------------------------------------------------------------------------------- /src/github.com/stretchr/testify/vendor/github.com/stretchr/objx/tests.go: -------------------------------------------------------------------------------- 1 | package objx 2 | 3 | // Has gets whether there is something at the specified selector 4 | // or not. 5 | // 6 | // If m is nil, Has will always return false. 7 | func (m Map) Has(selector string) bool { 8 | if m == nil { 9 | return false 10 | } 11 | return !m.Get(selector).IsNil() 12 | } 13 | 14 | // IsNil gets whether the data is nil or not. 15 | func (v *Value) IsNil() bool { 16 | return v == nil || v.data == nil 17 | } 18 | -------------------------------------------------------------------------------- /src/server/model/room_data_test.go: -------------------------------------------------------------------------------- 1 | package model 2 | 3 | import ( 4 | "testing" 5 | "github.com/dolotech/lib/db" 6 | ) 7 | 8 | func init() { 9 | db.Init("postgres://postgres:haosql@127.0.0.1:5432/postgres?sslmode=disable") 10 | } 11 | 12 | func TestUser_UpdateChips(t *testing.T) { 13 | room := &Room{ 14 | } 15 | 16 | t.Log(room.Insert()) 17 | 18 | room = &Room{Rid: 5} 19 | 20 | 21 | id,err:= room.GetById() 22 | 23 | t.Log(room.CreatedAt) 24 | t.Logf("%v %v %#+v",id,err, room) 25 | } 26 | -------------------------------------------------------------------------------- /src/github.com/stretchr/testify/assert/forward_assertions.go: -------------------------------------------------------------------------------- 1 | package assert 2 | 3 | // Assertions provides assertion methods around the 4 | // TestingT interface. 5 | type Assertions struct { 6 | t TestingT 7 | } 8 | 9 | // New makes a new Assertions object for the specified TestingT. 10 | func New(t TestingT) *Assertions { 11 | return &Assertions{ 12 | t: t, 13 | } 14 | } 15 | 16 | //go:generate go run ../_codegen/main.go -output-package=assert -template=assertion_forward.go.tmpl -include-format-funcs 17 | -------------------------------------------------------------------------------- /src/github.com/stretchr/testify/require/forward_requirements.go: -------------------------------------------------------------------------------- 1 | package require 2 | 3 | // Assertions provides assertion methods around the 4 | // TestingT interface. 5 | type Assertions struct { 6 | t TestingT 7 | } 8 | 9 | // New makes a new Assertions object for the specified TestingT. 10 | func New(t TestingT) *Assertions { 11 | return &Assertions{ 12 | t: t, 13 | } 14 | } 15 | 16 | //go:generate go run ../_codegen/main.go -output-package=require -template=require_forward.go.tmpl -include-format-funcs 17 | -------------------------------------------------------------------------------- /src/github.com/gorilla/websocket/conn_write_legacy.go: -------------------------------------------------------------------------------- 1 | // Copyright 2016 The Gorilla WebSocket Authors. All rights reserved. 2 | // Use of this source code is governed by a BSD-style 3 | // license that can be found in the LICENSE file. 4 | 5 | // +build !go1.8 6 | 7 | package websocket 8 | 9 | func (c *Conn) writeBufs(bufs ...[]byte) error { 10 | for _, buf := range bufs { 11 | if len(buf) > 0 { 12 | if _, err := c.conn.Write(buf); err != nil { 13 | return err 14 | } 15 | } 16 | } 17 | return nil 18 | } 19 | -------------------------------------------------------------------------------- /src/server/algorithm/dealer.go: -------------------------------------------------------------------------------- 1 | package algorithm 2 | 3 | import ( 4 | "time" 5 | "math/rand" 6 | ) 7 | 8 | 9 | 10 | //var n int64 11 | //var a int64= 1<<62 12 | // 洗牌 13 | func (this *Cards) Shuffle() { 14 | *this = make([]byte, TOTAL) 15 | copy(*this, CARDS) 16 | source := rand.NewSource(time.Now().UnixNano() ) 17 | //n ++ 18 | //n %=a 19 | r := rand.New(source) 20 | for i := TOTAL - 1; i > 0; i-- { 21 | index := r.Int() % i 22 | (*this)[i], (*this)[index] = (*this)[index], (*this)[i] 23 | } 24 | 25 | } 26 | -------------------------------------------------------------------------------- /src/server/model/constan.go: -------------------------------------------------------------------------------- 1 | package model 2 | 3 | const ( 4 | MaxN = 10 5 | MaxLevel = 40 6 | Timeout = 10 // 下注超时 7 | ) 8 | 9 | const ( 10 | Agent_Login = "LoginAgent" // 登录 11 | Agent_New = "NewAgent" // 新建链接 12 | Agent_Close = "CloseAgent" //链接关闭 13 | ) 14 | 15 | const ( 16 | BET_CALL = "call" //跟注:等于单注额 (call) 17 | BET_FOLD = "fold" //弃牌: <0 (fold) 18 | BET_CHECK = "check" //看注:= 0 表示看注 (check) 19 | BET_RAISE = "raise" //加注:大于单注额 (raise) 20 | BET_ALLIN = "allin" //全押:等于玩家手中所有筹码 (allin) 21 | ) 22 | -------------------------------------------------------------------------------- /src/github.com/lib/pq/user_posix.go: -------------------------------------------------------------------------------- 1 | // Package pq is a pure Go Postgres driver for the database/sql package. 2 | 3 | // +build darwin dragonfly freebsd linux nacl netbsd openbsd solaris 4 | 5 | package pq 6 | 7 | import ( 8 | "os" 9 | "os/user" 10 | ) 11 | 12 | func userCurrent() (string, error) { 13 | u, err := user.Current() 14 | if err == nil { 15 | return u.Username, nil 16 | } 17 | 18 | name := os.Getenv("USER") 19 | if name != "" { 20 | return name, nil 21 | } 22 | 23 | return "", ErrCouldNotDetectUsername 24 | } 25 | -------------------------------------------------------------------------------- /src/github.com/gorilla/websocket/examples/echo/README.md: -------------------------------------------------------------------------------- 1 | # Client and server example 2 | 3 | This example shows a simple client and server. 4 | 5 | The server echoes messages sent to it. The client sends a message every second 6 | and prints all messages received. 7 | 8 | To run the example, start the server: 9 | 10 | $ go run server.go 11 | 12 | Next, start the client: 13 | 14 | $ go run client.go 15 | 16 | The server includes a simple web client. To use the client, open 17 | http://127.0.0.1:8080 in the browser and follow the instructions on the page. 18 | -------------------------------------------------------------------------------- /src/github.com/labstack/gommon/bytes/README.md: -------------------------------------------------------------------------------- 1 | # Bytes 2 | 3 | - Format bytes integer to human readable bytes string. 4 | - Parse human readable bytes string to bytes integer. 5 | 6 | ## Installation 7 | 8 | ```go 9 | go get github.com/labstack/gommon/bytes 10 | ``` 11 | 12 | ## [Usage](https://github.com/labstack/gommon/blob/master/bytes/bytes_test.go) 13 | 14 | ### Format 15 | 16 | ```go 17 | println(bytes.Format(13231323)) 18 | ``` 19 | 20 | `12.62MB` 21 | 22 | ### Parse 23 | 24 | ```go 25 | b, _ = Parse("2M") 26 | println(b) 27 | ``` 28 | 29 | `2097152` 30 | -------------------------------------------------------------------------------- /src/github.com/go-xorm/core/pk.go: -------------------------------------------------------------------------------- 1 | package core 2 | 3 | import ( 4 | "bytes" 5 | "encoding/gob" 6 | ) 7 | 8 | type PK []interface{} 9 | 10 | func NewPK(pks ...interface{}) *PK { 11 | p := PK(pks) 12 | return &p 13 | } 14 | 15 | func (p *PK) ToString() (string, error) { 16 | buf := new(bytes.Buffer) 17 | enc := gob.NewEncoder(buf) 18 | err := enc.Encode(*p) 19 | return buf.String(), err 20 | } 21 | 22 | func (p *PK) FromString(content string) error { 23 | dec := gob.NewDecoder(bytes.NewBufferString(content)) 24 | err := dec.Decode(p) 25 | return err 26 | } 27 | -------------------------------------------------------------------------------- /src/github.com/gorilla/websocket/conn_read_legacy.go: -------------------------------------------------------------------------------- 1 | // Copyright 2016 The Gorilla WebSocket Authors. All rights reserved. 2 | // Use of this source code is governed by a BSD-style 3 | // license that can be found in the LICENSE file. 4 | 5 | // +build !go1.5 6 | 7 | package websocket 8 | 9 | import "io" 10 | 11 | func (c *Conn) read(n int) ([]byte, error) { 12 | p, err := c.br.Peek(n) 13 | if err == io.EOF { 14 | err = errUnexpectedEOF 15 | } 16 | if len(p) > 0 { 17 | // advance over the bytes just read 18 | io.ReadFull(c.br, p) 19 | } 20 | return p, err 21 | } 22 | -------------------------------------------------------------------------------- /src/github.com/dolotech/leaf/leaf.go: -------------------------------------------------------------------------------- 1 | package leaf 2 | 3 | import ( 4 | "github.com/golang/glog" 5 | "github.com/dolotech/leaf/module" 6 | "os" 7 | "os/signal" 8 | ) 9 | 10 | func Run(mods ...module.Module) { 11 | 12 | glog.Errorf("Leaf %v starting up", version) 13 | 14 | // module 15 | for i := 0; i < len(mods); i++ { 16 | module.Register(mods[i]) 17 | } 18 | module.Init() 19 | 20 | // close 21 | c := make(chan os.Signal, 1) 22 | signal.Notify(c, os.Interrupt, os.Kill) 23 | sig := <-c 24 | glog.Errorf("Leaf closing down (signal: %v)", sig) 25 | module.Destroy() 26 | } 27 | -------------------------------------------------------------------------------- /src/server/model/room_list_test.go: -------------------------------------------------------------------------------- 1 | package model 2 | 3 | import ( 4 | "testing" 5 | "time" 6 | ) 7 | 8 | func BenchmarkCreateNumber(b *testing.B) { 9 | for i:=0;i 10 | # Open http://localhost:8080/ . 11 | 12 | Try the following commands. 13 | 14 | # Echo sent messages to the output area. 15 | $ go run main.go cat 16 | 17 | # Run a shell.Try sending "ls" and "cat main.go". 18 | $ go run main.go sh 19 | 20 | -------------------------------------------------------------------------------- /src/github.com/gorilla/websocket/examples/autobahn/fuzzingclient.json: -------------------------------------------------------------------------------- 1 | 2 | { 3 | "options": {"failByDrop": false}, 4 | "outdir": "./reports/clients", 5 | "servers": [ 6 | {"agent": "ReadAllWriteMessage", "url": "ws://localhost:9000/m", "options": {"version": 18}}, 7 | {"agent": "ReadAllWritePreparedMessage", "url": "ws://localhost:9000/p", "options": {"version": 18}}, 8 | {"agent": "ReadAllWrite", "url": "ws://localhost:9000/r", "options": {"version": 18}}, 9 | {"agent": "CopyFull", "url": "ws://localhost:9000/f", "options": {"version": 18}}, 10 | {"agent": "CopyWriterOnly", "url": "ws://localhost:9000/c", "options": {"version": 18}} 11 | ], 12 | "cases": ["*"], 13 | "exclude-cases": [], 14 | "exclude-agent-cases": {} 15 | } 16 | -------------------------------------------------------------------------------- /src/server/gate/router.go: -------------------------------------------------------------------------------- 1 | package gate 2 | 3 | import ( 4 | "server/protocol" 5 | "server/game" 6 | "server/login" 7 | ) 8 | 9 | func init() { 10 | protocol.Processor.SetRouter(&protocol.UserLoginInfo{}, login.ChanRPC) 11 | protocol.Processor.SetRouter(&protocol.Version{}, login.ChanRPC) 12 | protocol.Processor.SetRouter(&protocol.RoomList{}, login.ChanRPC) 13 | 14 | protocol.Processor.SetRouter(&protocol.JoinRoom{}, game.ChanRPC) 15 | protocol.Processor.SetRouter(&protocol.LeaveRoom{}, game.ChanRPC) 16 | protocol.Processor.SetRouter(&protocol.SitDown{}, game.ChanRPC) 17 | protocol.Processor.SetRouter(&protocol.StandUp{}, game.ChanRPC) 18 | protocol.Processor.SetRouter(&protocol.Bet{}, game.ChanRPC) 19 | protocol.Processor.SetRouter(&protocol.Chat{}, game.ChanRPC) 20 | } 21 | -------------------------------------------------------------------------------- /src/server/game/internal/chanrpc.go: -------------------------------------------------------------------------------- 1 | package internal 2 | 3 | import ( 4 | "github.com/dolotech/leaf/gate" 5 | "github.com/golang/glog" 6 | "server/model" 7 | "github.com/dolotech/leaf/room" 8 | ) 9 | 10 | func init() { 11 | skeleton.RegisterChanRPC(model.Agent_New, rpcNewAgent) 12 | skeleton.RegisterChanRPC(model.Agent_Close, rpcCloseAgent) 13 | skeleton.RegisterChanRPC(model.Agent_Login, rpcLoginAgent) 14 | } 15 | 16 | func rpcNewAgent(a gate.Agent) { 17 | glog.Errorln("新建链接 ", a) 18 | } 19 | 20 | func rpcCloseAgent(a gate.Agent) { 21 | glog.Errorln("链接关闭 ", a) 22 | } 23 | 24 | func rpcLoginAgent(u *model.User, a gate.Agent) { 25 | 26 | o := NewOccupant(u, a) 27 | a.SetUserData(o) 28 | 29 | if len(u.RoomID) > 0 { 30 | o.room = room.GetRoom(u.RoomID) 31 | } 32 | glog.Errorln("rpcLoginAgent", u) 33 | } 34 | -------------------------------------------------------------------------------- /src/github.com/davecgh/go-spew/LICENSE: -------------------------------------------------------------------------------- 1 | Copyright (c) 2012-2013 Dave Collins 2 | 3 | Permission to use, copy, modify, and distribute this software for any 4 | purpose with or without fee is hereby granted, provided that the above 5 | copyright notice and this permission notice appear in all copies. 6 | 7 | THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES 8 | WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF 9 | MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR 10 | ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES 11 | WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN 12 | ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF 13 | OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. 14 | -------------------------------------------------------------------------------- /src/github.com/dolotech/lib/filter/readme.txt: -------------------------------------------------------------------------------- 1 | Aho-Corasick is a multiple string matching algorithm 2 | I implement the algorithm in trie.go 3 | In filter.go, I use the built trie to search sensitive words,and filter them out 4 | In test1.go, I test the filter function 5 | In test2.go, I implement a simple http server, and the dictionary can be asynchronously hot-updated and hot-reloading using command: 'kill -1 pid' 6 | 7 | go run test1.go 8 | go run test2.go 9 | 10 | I tested for a dictionary file which contains 140W lines of diffrent sensitive phrases and 2100W charactors and totally 35M in size. It takes 50s to build the according trie, and it takes 1.5s to filter the all phrases out from a given text file which is the same to the dictionary file ( the worst case ) in a routine. And the total memory usage of the process is 2.4G 11 | -------------------------------------------------------------------------------- /bin/client/assets/resources/splash.png.meta: -------------------------------------------------------------------------------- 1 | { 2 | "ver": "1.0.0", 3 | "uuid": "ac7ab283-08d2-456d-b2fc-0a9ffe60330e", 4 | "type": "sprite", 5 | "wrapMode": "clamp", 6 | "filterMode": "bilinear", 7 | "subMetas": { 8 | "splash": { 9 | "ver": "1.0.3", 10 | "uuid": "ff6660f1-fbd2-4dad-901b-ba8dd3fe5acc", 11 | "rawTextureUuid": "ac7ab283-08d2-456d-b2fc-0a9ffe60330e", 12 | "trimType": "auto", 13 | "trimThreshold": 1, 14 | "rotated": false, 15 | "offsetX": 0, 16 | "offsetY": 0, 17 | "trimX": 0, 18 | "trimY": 0, 19 | "width": 687, 20 | "height": 324, 21 | "rawWidth": 687, 22 | "rawHeight": 324, 23 | "borderTop": 0, 24 | "borderBottom": 0, 25 | "borderLeft": 0, 26 | "borderRight": 0, 27 | "subMetas": {} 28 | } 29 | } 30 | } -------------------------------------------------------------------------------- /bin/build-linux.sh: -------------------------------------------------------------------------------- 1 | #!/bin/bash 2 | # usage ./build-linux.sh 1.0.13 3 | curDir=`pwd` 4 | GREEN="\e[1;32m" 5 | RESET="\e[0m" 6 | echo -e "${GREEN} current dir is $curDir ${RESET}" 7 | 8 | d=`date "+%Y-%m-%d-%H-%M-%S"` 9 | echo -e "${GREEN} mkpkg_time is $d ${RESET}" 10 | 11 | pkg_version=$1 12 | echo -e "${GREEN} pkg_version is $pkg_version ${RESET}" 13 | 14 | cd $curDir/.. 15 | STRING_GAME=`git log | head -n 1 | awk '{print $2}'` 16 | echo -e "${GREEN} game commit is $STRING_GAME ${RESET}" 17 | 18 | cd $curDir/.. 19 | echo `pwd` 20 | 21 | cd $curDir/.. 22 | 23 | export GOPATH=`pwd` 24 | export GOARCH=amd64 25 | export GOOS=linux 26 | cd bin 27 | 28 | 29 | go build -o game -ldflags "-X main.Commit=$STRING_GAME -X 'main.BUILD_TIME=`date`' -X main.VERSION=$1 -s -w" ../src/main.go 30 | 31 | 32 | read -p "Press any key to continue." var -------------------------------------------------------------------------------- /src/github.com/dolotech/lib/db/client_test.go: -------------------------------------------------------------------------------- 1 | package db 2 | 3 | import ( 4 | //"game/player" 5 | //"github.com/bmizerany/assert" 6 | _ "github.com/lib/pq" 7 | //l4g "lib/log4go" 8 | "testing" 9 | ) 10 | 11 | const UCDBURL = "postgres://postgres:postgres@192.168.1.240:3021/postgres?sslmode=disable" 12 | 13 | func Test_NewClient(t *testing.T) { 14 | //l4g.Info("test client ...") 15 | 16 | //client, err := NewClient("postgres", UCDBURL) 17 | //client.engine.ShowSQL(true) 18 | //assert.Equal(t, err, nil) 19 | //defer client.Close() 20 | 21 | //l4g.Info("Start New Client", client) 22 | } 23 | 24 | func Test_Insert(t *testing.T) { 25 | //client, err := NewClient("postgres", UCDBURL) 26 | //assert.Equal(t, err, nil) 27 | //defer client.Close() 28 | // 29 | //l4g.Info("XXXXX", client) 30 | //client.Insert(&player.User{},) 31 | } 32 | -------------------------------------------------------------------------------- /bin/build-win.sh: -------------------------------------------------------------------------------- 1 | #!/bin/bash 2 | # usage ./build-linux.sh 1.0.13 3 | curDir=`pwd` 4 | GREEN="\e[1;32m" 5 | RESET="\e[0m" 6 | echo -e "${GREEN} current dir is $curDir ${RESET}" 7 | 8 | d=`date "+%Y-%m-%d-%H-%M-%S"` 9 | echo -e "${GREEN} mkpkg_time is $d ${RESET}" 10 | 11 | pkg_version=$1 12 | echo -e "${GREEN} pkg_version is $pkg_version ${RESET}" 13 | 14 | cd $curDir/.. 15 | STRING_GAME=`git log | head -n 1 | awk '{print $2}'` 16 | echo -e "${GREEN} game commit is $STRING_GAME ${RESET}" 17 | 18 | cd $curDir/.. 19 | echo `pwd` 20 | 21 | cd $curDir/.. 22 | 23 | export GOPATH=`pwd` 24 | #export GOARCH=amd64 25 | #export GOOS=linux 26 | cd bin 27 | 28 | 29 | go build -o game.exe -ldflags "-X main.Commit=$STRING_GAME -X 'main.BUILD_TIME=`date`' -X main.VERSION=$1 -s -w" ../src/main.go 30 | 31 | 32 | read -p "Press any key to continue." var -------------------------------------------------------------------------------- /src/github.com/dolotech/lib/utils/sign.go: -------------------------------------------------------------------------------- 1 | package utils 2 | 3 | import ( 4 | "crypto/md5" 5 | "encoding/hex" 6 | "fmt" 7 | "sort" 8 | "strings" 9 | ) 10 | 11 | //生成签名 12 | func LoginSign(gameid string, device string) (string, error) { 13 | parra := fmt.Sprintf("gameid=%s&deviceId=%s", gameid, device) 14 | parameters := strings.Split(parra, "&") 15 | sort_parameters := sort.StringSlice(parameters) 16 | sort.Sort(sort_parameters) 17 | parameter := "" 18 | for i := 0; i < len(sort_parameters); i++ { 19 | parameter += "&" + sort_parameters[i] 20 | } 21 | parameter = string([]byte(parameter)[1:]) 22 | 23 | h := md5.New() 24 | 25 | _, err := h.Write([]byte(parameter + "&key=" + "19a87399fde1bccbf04a5eaa018ea0df")) 26 | if err != nil { 27 | return "", err 28 | } 29 | return strings.ToUpper(hex.EncodeToString(h.Sum(nil))), nil 30 | } 31 | -------------------------------------------------------------------------------- /bin/client/assets/resources/GameMain_6p.png.meta: -------------------------------------------------------------------------------- 1 | { 2 | "ver": "1.0.0", 3 | "uuid": "9645f4c7-099e-4bac-9779-ac372a798d1b", 4 | "type": "sprite", 5 | "wrapMode": "clamp", 6 | "filterMode": "bilinear", 7 | "subMetas": { 8 | "GameMain_6p": { 9 | "ver": "1.0.3", 10 | "uuid": "2bd24592-8fab-4bf3-bb32-5774b2b60782", 11 | "rawTextureUuid": "9645f4c7-099e-4bac-9779-ac372a798d1b", 12 | "trimType": "auto", 13 | "trimThreshold": 1, 14 | "rotated": false, 15 | "offsetX": -1, 16 | "offsetY": 0, 17 | "trimX": 2, 18 | "trimY": 2, 19 | "width": 2042, 20 | "height": 2044, 21 | "rawWidth": 2048, 22 | "rawHeight": 2048, 23 | "borderTop": 0, 24 | "borderBottom": 0, 25 | "borderLeft": 0, 26 | "borderRight": 0, 27 | "subMetas": {} 28 | } 29 | } 30 | } -------------------------------------------------------------------------------- /bin/client/assets/resources/game_desk_bg.jpg.meta: -------------------------------------------------------------------------------- 1 | { 2 | "ver": "1.0.0", 3 | "uuid": "e1084d70-0b00-4041-8ccc-62b69fbf1716", 4 | "type": "sprite", 5 | "wrapMode": "clamp", 6 | "filterMode": "bilinear", 7 | "subMetas": { 8 | "game_desk_bg": { 9 | "ver": "1.0.3", 10 | "uuid": "433c3791-25ed-4e94-8894-72e7dad6af14", 11 | "rawTextureUuid": "e1084d70-0b00-4041-8ccc-62b69fbf1716", 12 | "trimType": "auto", 13 | "trimThreshold": 1, 14 | "rotated": false, 15 | "offsetX": 0, 16 | "offsetY": 0, 17 | "trimX": 0, 18 | "trimY": 0, 19 | "width": 750, 20 | "height": 1334, 21 | "rawWidth": 750, 22 | "rawHeight": 1334, 23 | "borderTop": 0, 24 | "borderBottom": 0, 25 | "borderLeft": 0, 26 | "borderRight": 0, 27 | "subMetas": {} 28 | } 29 | } 30 | } -------------------------------------------------------------------------------- /bin/client/assets/resources/game_cards.png.meta: -------------------------------------------------------------------------------- 1 | { 2 | "ver": "1.0.0", 3 | "uuid": "24e07000-e189-4c09-8859-47cc25581533", 4 | "type": "sprite", 5 | "wrapMode": "clamp", 6 | "filterMode": "bilinear", 7 | "subMetas": { 8 | "game_cards": { 9 | "ver": "1.0.3", 10 | "uuid": "6d4aeaa5-b8e2-498e-9abc-f59b2acf5d75", 11 | "rawTextureUuid": "24e07000-e189-4c09-8859-47cc25581533", 12 | "trimType": "auto", 13 | "trimThreshold": 1, 14 | "rotated": false, 15 | "offsetX": -16.5, 16 | "offsetY": 7.5, 17 | "trimX": 2, 18 | "trimY": 2, 19 | "width": 987, 20 | "height": 1005, 21 | "rawWidth": 1024, 22 | "rawHeight": 1024, 23 | "borderTop": 0, 24 | "borderBottom": 0, 25 | "borderLeft": 0, 26 | "borderRight": 0, 27 | "subMetas": {} 28 | } 29 | } 30 | } -------------------------------------------------------------------------------- /bin/client/assets/resources/game_cards_6p.png.meta: -------------------------------------------------------------------------------- 1 | { 2 | "ver": "1.0.0", 3 | "uuid": "d3175df2-92cf-41d8-9e71-1fd53833ccb5", 4 | "type": "sprite", 5 | "wrapMode": "clamp", 6 | "filterMode": "bilinear", 7 | "subMetas": { 8 | "game_cards_6p": { 9 | "ver": "1.0.3", 10 | "uuid": "a559bb08-bc8b-4bfb-b05b-c571d3af1144", 11 | "rawTextureUuid": "d3175df2-92cf-41d8-9e71-1fd53833ccb5", 12 | "trimType": "auto", 13 | "trimThreshold": 1, 14 | "rotated": false, 15 | "offsetX": -21, 16 | "offsetY": 1.5, 17 | "trimX": 2, 18 | "trimY": 2, 19 | "width": 978, 20 | "height": 2041, 21 | "rawWidth": 1024, 22 | "rawHeight": 2048, 23 | "borderTop": 0, 24 | "borderBottom": 0, 25 | "borderLeft": 0, 26 | "borderRight": 0, 27 | "subMetas": {} 28 | } 29 | } 30 | } -------------------------------------------------------------------------------- /bin/client/assets/resources/game_desk_bg_6p.jpg.meta: -------------------------------------------------------------------------------- 1 | { 2 | "ver": "1.0.0", 3 | "uuid": "8eb63dd6-6d9b-47d8-8021-077beaf0c174", 4 | "type": "sprite", 5 | "wrapMode": "clamp", 6 | "filterMode": "bilinear", 7 | "subMetas": { 8 | "game_desk_bg_6p": { 9 | "ver": "1.0.3", 10 | "uuid": "d5e079ed-488b-4fd5-8bc3-b3e082b34d96", 11 | "rawTextureUuid": "8eb63dd6-6d9b-47d8-8021-077beaf0c174", 12 | "trimType": "auto", 13 | "trimThreshold": 1, 14 | "rotated": false, 15 | "offsetX": 0, 16 | "offsetY": 0, 17 | "trimX": 0, 18 | "trimY": 0, 19 | "width": 1242, 20 | "height": 2208, 21 | "rawWidth": 1242, 22 | "rawHeight": 2208, 23 | "borderTop": 0, 24 | "borderBottom": 0, 25 | "borderLeft": 0, 26 | "borderRight": 0, 27 | "subMetas": {} 28 | } 29 | } 30 | } -------------------------------------------------------------------------------- /src/github.com/dolotech/lib/utils/string_2_bytes_test.go: -------------------------------------------------------------------------------- 1 | package utils 2 | 3 | import ( 4 | "testing" 5 | ) 6 | 7 | /*func BenchmarkBytes2String(t *testing.B) { 8 | for i := 1; i < N; i++ { 9 | b := []byte("34asdfasdfasdfasdfasdfasdfasdfasdf12") 10 | t.Log(Bytes2String(b)) 11 | } 12 | }*/ 13 | func BenchmarkTestString2Bytes(t *testing.B) { 14 | for i := 1; i < N; i++ { 15 | b := "34asdfasdfasdfasdfasdfasdfasdfasdf12" 16 | t.Log(Bytes2String(String2Bytes(b))) 17 | } 18 | } 19 | 20 | const N = 30000 21 | /*func BenchmarkBytes2String1(t *testing.B) { 22 | for i := 1; i < N; i++ { 23 | b := []byte("34asdfasdfasdfasdfasdfasdfasdfasdf12") 24 | t.Log(Bytes2String(b)) 25 | } 26 | }*/ 27 | func BenchmarkTestString2Bytes1(t *testing.B) { 28 | for i := 1; i < N; i++ { 29 | b := "34asdfasdfasdfasdfasdfasdfasdfasdf12" 30 | t.Log(string([]byte(b))) 31 | } 32 | } 33 | -------------------------------------------------------------------------------- /src/server/model/user_data_test.go: -------------------------------------------------------------------------------- 1 | package model 2 | 3 | import ( 4 | "testing" 5 | "time" 6 | "math/rand" 7 | ) 8 | 9 | func TestUser_UpdateChips2(t *testing.T) { 10 | user:= &User{Uid:35} 11 | t.Log(user.UpdateChips(100),user) 12 | } 13 | 14 | func TestUser_Insert(t *testing.T) { 15 | user:= &User{Nickname:"Michael",UnionId:"aaasdfasd"} 16 | t.Log(user.Insert(),user) 17 | } 18 | 19 | func BenchmarkUser_Insert(b *testing.B) { 20 | r:=rand.New(rand.NewSource(time.Now().UnixNano())) 21 | for i:=0;i 4 | 5 | Permission to use, copy, modify, and distribute this software for any 6 | purpose with or without fee is hereby granted, provided that the above 7 | copyright notice and this permission notice appear in all copies. 8 | 9 | THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES 10 | WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF 11 | MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR 12 | ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES 13 | WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN 14 | ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF 15 | OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. 16 | -------------------------------------------------------------------------------- /src/github.com/stretchr/testify/Gopkg.lock: -------------------------------------------------------------------------------- 1 | # This file is autogenerated, do not edit; changes may be undone by the next 'dep ensure'. 2 | 3 | 4 | [[projects]] 5 | name = "github.com/davecgh/go-spew" 6 | packages = ["spew"] 7 | revision = "346938d642f2ec3594ed81d874461961cd0faa76" 8 | version = "v1.1.0" 9 | 10 | [[projects]] 11 | name = "github.com/pmezard/go-difflib" 12 | packages = ["difflib"] 13 | revision = "792786c7400a136282c1664665ae0a8db921c6c2" 14 | version = "v1.0.0" 15 | 16 | [[projects]] 17 | name = "github.com/stretchr/objx" 18 | packages = ["."] 19 | revision = "facf9a85c22f48d2f52f2380e4efce1768749a89" 20 | version = "v0.1" 21 | 22 | [solve-meta] 23 | analyzer-name = "dep" 24 | analyzer-version = 1 25 | inputs-digest = "448ddae4702c6aded2555faafd390c537789bb1c483f70b0431e6634f73f2090" 26 | solver-name = "gps-cdcl" 27 | solver-version = 1 28 | -------------------------------------------------------------------------------- /src/github.com/go-xorm/xorm/odbc_driver.go: -------------------------------------------------------------------------------- 1 | // Copyright 2015 The Xorm Authors. All rights reserved. 2 | // Use of this source code is governed by a BSD-style 3 | // license that can be found in the LICENSE file. 4 | 5 | package xorm 6 | 7 | import ( 8 | "errors" 9 | "strings" 10 | 11 | "github.com/go-xorm/core" 12 | ) 13 | 14 | type odbcDriver struct { 15 | } 16 | 17 | func (p *odbcDriver) Parse(driverName, dataSourceName string) (*core.Uri, error) { 18 | kv := strings.Split(dataSourceName, ";") 19 | var dbName string 20 | 21 | for _, c := range kv { 22 | vv := strings.Split(strings.TrimSpace(c), "=") 23 | if len(vv) == 2 { 24 | switch strings.ToLower(vv[0]) { 25 | case "database": 26 | dbName = vv[1] 27 | } 28 | } 29 | } 30 | if dbName == "" { 31 | return nil, errors.New("no db name provided") 32 | } 33 | return &core.Uri{DbName: dbName, DbType: core.MSSQL}, nil 34 | } 35 | -------------------------------------------------------------------------------- /src/server/gate/internal/module.go: -------------------------------------------------------------------------------- 1 | package internal 2 | 3 | import ( 4 | "github.com/dolotech/leaf/gate" 5 | "server/conf" 6 | "server/game" 7 | "server/protocol" 8 | "github.com/golang/glog" 9 | ) 10 | 11 | type Module struct { 12 | *gate.Gate 13 | } 14 | 15 | func (m *Module) OnInit() { 16 | m.Gate = &gate.Gate{ 17 | MaxConnNum: conf.Server.MaxConnNum, 18 | PendingWriteNum: conf.PendingWriteNum, 19 | MaxMsgLen: conf.MaxMsgLen, 20 | WSAddr: conf.Server.WSAddr, 21 | HTTPTimeout: conf.HTTPTimeout, 22 | CertFile: conf.Server.CertFile, 23 | KeyFile: conf.Server.KeyFile, 24 | TCPAddr: conf.Server.TCPAddr, 25 | LenMsgLen: conf.LenMsgLen, 26 | LittleEndian: conf.LittleEndian, 27 | Processor: protocol.Processor, 28 | AgentChanRPC: game.ChanRPC, 29 | } 30 | } 31 | func (gate *Module) OnDestroy() { 32 | glog.Errorln("OnDestroy") 33 | } 34 | 35 | 36 | -------------------------------------------------------------------------------- /src/github.com/dolotech/lib/csv/csv.go: -------------------------------------------------------------------------------- 1 | /********************************************************** 2 | * Author : Michael 3 | * Email : dolotech@163.com 4 | * Last modified : 2016-07-07 23:41 5 | * Filename : csv.go 6 | * Description : 7 | * *******************************************************/ 8 | // Package csv provides `Marshal` and `UnMarshal` encoding functions for CSV(Comma Seperated Value) data. 9 | // This package is built on the the standard library's encoding/csv. 10 | package csv 11 | 12 | import ( 13 | "reflect" 14 | ) 15 | 16 | // fieldHeaderName returns the header name to use for the given StructField 17 | // This can be a user defined name (via the Tag) or a default name. 18 | func fieldHeaderName(f reflect.StructField) (string, bool) { 19 | h := f.Tag.Get("csv") 20 | 21 | if h == "-" { 22 | return "", false 23 | } 24 | 25 | // If there is no tag set, use a default name 26 | if h == "" { 27 | return f.Name, true 28 | } 29 | 30 | return h, true 31 | } 32 | -------------------------------------------------------------------------------- /src/github.com/lib/pq/user_windows.go: -------------------------------------------------------------------------------- 1 | // Package pq is a pure Go Postgres driver for the database/sql package. 2 | package pq 3 | 4 | import ( 5 | "path/filepath" 6 | "syscall" 7 | ) 8 | 9 | // Perform Windows user name lookup identically to libpq. 10 | // 11 | // The PostgreSQL code makes use of the legacy Win32 function 12 | // GetUserName, and that function has not been imported into stock Go. 13 | // GetUserNameEx is available though, the difference being that a 14 | // wider range of names are available. To get the output to be the 15 | // same as GetUserName, only the base (or last) component of the 16 | // result is returned. 17 | func userCurrent() (string, error) { 18 | pw_name := make([]uint16, 128) 19 | pwname_size := uint32(len(pw_name)) - 1 20 | err := syscall.GetUserNameEx(syscall.NameSamCompatible, &pw_name[0], &pwname_size) 21 | if err != nil { 22 | return "", ErrCouldNotDetectUsername 23 | } 24 | s := syscall.UTF16ToString(pw_name) 25 | u := filepath.Base(s) 26 | return u, nil 27 | } 28 | -------------------------------------------------------------------------------- /src/github.com/stretchr/testify/require/doc.go: -------------------------------------------------------------------------------- 1 | // Package require implements the same assertions as the `assert` package but 2 | // stops test execution when a test fails. 3 | // 4 | // Example Usage 5 | // 6 | // The following is a complete example using require in a standard test function: 7 | // import ( 8 | // "testing" 9 | // "github.com/stretchr/testify/require" 10 | // ) 11 | // 12 | // func TestSomething(t *testing.T) { 13 | // 14 | // var a string = "Hello" 15 | // var b string = "Hello" 16 | // 17 | // require.Equal(t, a, b, "The two words should be the same.") 18 | // 19 | // } 20 | // 21 | // Assertions 22 | // 23 | // The `require` package have same global functions as in the `assert` package, 24 | // but instead of returning a boolean result they call `t.FailNow()`. 25 | // 26 | // Every assertion function also takes an optional string message as the final argument, 27 | // allowing custom error messages to be appended to the message the assertion method outputs. 28 | package require 29 | -------------------------------------------------------------------------------- /src/github.com/dolotech/lib/csv/example_marshal_test.go: -------------------------------------------------------------------------------- 1 | /********************************************************** 2 | * Author : Michael 3 | * Email : dolotech@163.com 4 | * Last modified : 2016-07-07 23:42 5 | * Filename : example_marshal_test.go 6 | * Description : 7 | * *******************************************************/ 8 | package csv 9 | 10 | import ( 11 | "fmt" 12 | "github.com/golang/glog" 13 | ) 14 | 15 | func ExampleMarshal() { 16 | type Person struct { 17 | Name string `csv:"FullName"` 18 | Gender string 19 | Age int 20 | Wallet float32 `csv:"Bank Account"` 21 | Happy bool `true:"Yes!" false:"Sad"` 22 | private int `csv:"-"` 23 | } 24 | 25 | people := []Person{ 26 | Person{ 27 | Name: "Smith, Joe", 28 | Gender: "M", 29 | Age: 23, 30 | Wallet: 19.07, 31 | Happy: false, 32 | }, 33 | } 34 | 35 | out, _ := Marshal(people) 36 | glog.Infof("%s", out) 37 | // Output: 38 | // FullName,Gender,Age,Bank Account,Happy 39 | // "Smith, Joe",M,23,19.07,Sad 40 | } 41 | -------------------------------------------------------------------------------- /src/github.com/stretchr/testify/doc.go: -------------------------------------------------------------------------------- 1 | // Package testify is a set of packages that provide many tools for testifying that your code will behave as you intend. 2 | // 3 | // testify contains the following packages: 4 | // 5 | // The assert package provides a comprehensive set of assertion functions that tie in to the Go testing system. 6 | // 7 | // The http package contains tools to make it easier to test http activity using the Go testing system. 8 | // 9 | // The mock package provides a system by which it is possible to mock your objects and verify calls are happening as expected. 10 | // 11 | // The suite package provides a basic structure for using structs as testing suites, and methods on those structs as tests. It includes setup/teardown functionality in the way of interfaces. 12 | package testify 13 | 14 | // blank imports help docs. 15 | import ( 16 | // assert package 17 | _ "github.com/stretchr/testify/assert" 18 | // http package 19 | _ "github.com/stretchr/testify/http" 20 | // mock package 21 | _ "github.com/stretchr/testify/mock" 22 | ) 23 | -------------------------------------------------------------------------------- /src/github.com/labstack/gommon/random/random.go: -------------------------------------------------------------------------------- 1 | package random 2 | 3 | import ( 4 | "math/rand" 5 | "time" 6 | ) 7 | 8 | type ( 9 | Random struct { 10 | charset Charset 11 | } 12 | 13 | Charset string 14 | ) 15 | 16 | const ( 17 | Alphanumeric Charset = Alphabetic + Numeric 18 | Alphabetic Charset = "abcdefghijklmnopqrstuvwxyz" + "ABCDEFGHIJKLMNOPQRSTUVWXYZ" 19 | Numeric Charset = "0123456789" 20 | Hex Charset = Numeric + "abcdef" 21 | ) 22 | 23 | var ( 24 | global = New() 25 | ) 26 | 27 | func New() *Random { 28 | rand.Seed(time.Now().UnixNano()) 29 | return &Random{ 30 | charset: Alphanumeric, 31 | } 32 | } 33 | 34 | func (r *Random) SetCharset(c Charset) { 35 | r.charset = c 36 | } 37 | 38 | func (r *Random) String(length uint8) string { 39 | b := make([]byte, length) 40 | for i := range b { 41 | b[i] = r.charset[rand.Int63()%int64(len(r.charset))] 42 | } 43 | return string(b) 44 | } 45 | 46 | func SetCharset(c Charset) { 47 | global.SetCharset(c) 48 | } 49 | 50 | func String(length uint8) string { 51 | return global.String(length) 52 | } 53 | -------------------------------------------------------------------------------- /src/github.com/golang/protobuf/descriptor/descriptor_test.go: -------------------------------------------------------------------------------- 1 | package descriptor_test 2 | 3 | import ( 4 | "fmt" 5 | "testing" 6 | 7 | "github.com/golang/protobuf/descriptor" 8 | tpb "github.com/golang/protobuf/proto/testdata" 9 | protobuf "github.com/golang/protobuf/protoc-gen-go/descriptor" 10 | ) 11 | 12 | func TestMessage(t *testing.T) { 13 | var msg *protobuf.DescriptorProto 14 | fd, md := descriptor.ForMessage(msg) 15 | if pkg, want := fd.GetPackage(), "google.protobuf"; pkg != want { 16 | t.Errorf("descriptor.ForMessage(%T).GetPackage() = %q; want %q", msg, pkg, want) 17 | } 18 | if name, want := md.GetName(), "DescriptorProto"; name != want { 19 | t.Fatalf("descriptor.ForMessage(%T).GetName() = %q; want %q", msg, name, want) 20 | } 21 | } 22 | 23 | func Example_Options() { 24 | var msg *tpb.MyMessageSet 25 | _, md := descriptor.ForMessage(msg) 26 | if md.GetOptions().GetMessageSetWireFormat() { 27 | fmt.Printf("%v uses option message_set_wire_format.\n", md.GetName()) 28 | } 29 | 30 | // Output: 31 | // MyMessageSet uses option message_set_wire_format. 32 | } 33 | -------------------------------------------------------------------------------- /src/github.com/gorilla/websocket/examples/chat/main.go: -------------------------------------------------------------------------------- 1 | // Copyright 2013 The Gorilla WebSocket Authors. All rights reserved. 2 | // Use of this source code is governed by a BSD-style 3 | // license that can be found in the LICENSE file. 4 | 5 | package main 6 | 7 | import ( 8 | "flag" 9 | "log" 10 | "net/http" 11 | ) 12 | 13 | var addr = flag.String("addr", ":8080", "http service address") 14 | 15 | func serveHome(w http.ResponseWriter, r *http.Request) { 16 | log.Println(r.URL) 17 | if r.URL.Path != "/" { 18 | http.Error(w, "Not found", http.StatusNotFound) 19 | return 20 | } 21 | if r.Method != "GET" { 22 | http.Error(w, "Method not allowed", http.StatusMethodNotAllowed) 23 | return 24 | } 25 | http.ServeFile(w, r, "home.html") 26 | } 27 | 28 | func main() { 29 | flag.Parse() 30 | hub := newHub() 31 | go hub.run() 32 | http.HandleFunc("/", serveHome) 33 | http.HandleFunc("/ws", func(w http.ResponseWriter, r *http.Request) { 34 | serveWs(hub, w, r) 35 | }) 36 | err := http.ListenAndServe(*addr, nil) 37 | if err != nil { 38 | log.Fatal("ListenAndServe: ", err) 39 | } 40 | } 41 | -------------------------------------------------------------------------------- /src/github.com/go-xorm/xorm/oci8_driver.go: -------------------------------------------------------------------------------- 1 | // Copyright 2015 The Xorm Authors. All rights reserved. 2 | // Use of this source code is governed by a BSD-style 3 | // license that can be found in the LICENSE file. 4 | 5 | package xorm 6 | 7 | import ( 8 | "errors" 9 | "regexp" 10 | 11 | "github.com/go-xorm/core" 12 | ) 13 | 14 | type oci8Driver struct { 15 | } 16 | 17 | //dataSourceName=user/password@ipv4:port/dbname 18 | //dataSourceName=user/password@[ipv6]:port/dbname 19 | func (p *oci8Driver) Parse(driverName, dataSourceName string) (*core.Uri, error) { 20 | db := &core.Uri{DbType: core.ORACLE} 21 | dsnPattern := regexp.MustCompile( 22 | `^(?P.*)\/(?P.*)@` + // user:password@ 23 | `(?P.*)` + // ip:port 24 | `\/(?P.*)`) // dbname 25 | matches := dsnPattern.FindStringSubmatch(dataSourceName) 26 | names := dsnPattern.SubexpNames() 27 | for i, match := range matches { 28 | switch names[i] { 29 | case "dbname": 30 | db.DbName = match 31 | } 32 | } 33 | if db.DbName == "" { 34 | return nil, errors.New("dbname is empty") 35 | } 36 | return db, nil 37 | } 38 | -------------------------------------------------------------------------------- /src/github.com/dolotech/leaf/module/module.go: -------------------------------------------------------------------------------- 1 | package module 2 | 3 | import ( 4 | "sync" 5 | "github.com/dolotech/lib/utils" 6 | ) 7 | 8 | type Module interface { 9 | OnInit() 10 | OnDestroy() 11 | Run(closeSig chan bool) 12 | } 13 | 14 | type module struct { 15 | mi Module 16 | closeSig chan bool 17 | wg sync.WaitGroup 18 | } 19 | 20 | var mods []*module 21 | 22 | func Register(mi Module) { 23 | m := new(module) 24 | m.mi = mi 25 | m.closeSig = make(chan bool, 1) 26 | 27 | mods = append(mods, m) 28 | } 29 | 30 | func Init() { 31 | for i := 0; i < len(mods); i++ { 32 | mods[i].mi.OnInit() 33 | } 34 | 35 | for i := 0; i < len(mods); i++ { 36 | m := mods[i] 37 | m.wg.Add(1) 38 | go run(m) 39 | } 40 | } 41 | 42 | func Destroy() { 43 | for i := len(mods) - 1; i >= 0; i-- { 44 | m := mods[i] 45 | m.closeSig <- true 46 | m.wg.Wait() 47 | destroy(m) 48 | } 49 | } 50 | 51 | func run(m *module) { 52 | defer utils.PrintPanicStack() 53 | m.mi.Run(m.closeSig) 54 | m.wg.Done() 55 | } 56 | 57 | func destroy(m *module) { 58 | defer utils.PrintPanicStack() 59 | 60 | m.mi.OnDestroy() 61 | } 62 | -------------------------------------------------------------------------------- /src/github.com/dolotech/lib/route/route_msg.go: -------------------------------------------------------------------------------- 1 | package route 2 | 3 | import ( 4 | "reflect" 5 | "github.com/golang/glog" 6 | ) 7 | 8 | type Route map[string]*reflect.Value 9 | 10 | func (this *Route) Emit(msg interface{}, arg ...interface{}) { 11 | if *this != nil { 12 | msgID := reflect.TypeOf(msg).Elem().Name() 13 | if f, ok := (*this)[msgID]; ok { 14 | array := make([]reflect.Value, len(arg)+1) 15 | array[0] = reflect.ValueOf(msg) 16 | for i := 0; i < len(arg); i++ { 17 | array[i+1] = reflect.ValueOf(arg[i]) 18 | } 19 | f.Call(array) 20 | } 21 | } 22 | } 23 | func (this *Route) Regist(msg, f interface{}) { 24 | if *this == nil { 25 | *this = make(map[string]*reflect.Value, 18) 26 | } 27 | msgType := reflect.TypeOf(msg) 28 | if msgType == nil || msgType.Kind() != reflect.Ptr { 29 | glog.Error("message pointer required") 30 | } 31 | msgID := msgType.Elem().Name() 32 | if msgID == "" { 33 | glog.Error("unnamed message") 34 | } 35 | if _, ok := (*this)[msgID]; ok { 36 | glog.Errorf("message %v is already registered", msgID) 37 | } 38 | v := reflect.ValueOf(f) 39 | (*this)[msgID] = &v 40 | } 41 | -------------------------------------------------------------------------------- /src/github.com/lib/pq/LICENSE.md: -------------------------------------------------------------------------------- 1 | Copyright (c) 2011-2013, 'pq' Contributors 2 | Portions Copyright (C) 2011 Blake Mizerany 3 | 4 | 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: 5 | 6 | The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software. 7 | 8 | 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. 9 | -------------------------------------------------------------------------------- /src/github.com/go-xorm/xorm/memory_store.go: -------------------------------------------------------------------------------- 1 | // Copyright 2015 The Xorm Authors. All rights reserved. 2 | // Use of this source code is governed by a BSD-style 3 | // license that can be found in the LICENSE file. 4 | 5 | package xorm 6 | 7 | import ( 8 | "sync" 9 | 10 | "github.com/go-xorm/core" 11 | ) 12 | 13 | var _ core.CacheStore = NewMemoryStore() 14 | 15 | // memory store 16 | type MemoryStore struct { 17 | store map[interface{}]interface{} 18 | mutex sync.RWMutex 19 | } 20 | 21 | func NewMemoryStore() *MemoryStore { 22 | return &MemoryStore{store: make(map[interface{}]interface{})} 23 | } 24 | 25 | func (s *MemoryStore) Put(key string, value interface{}) error { 26 | s.mutex.Lock() 27 | defer s.mutex.Unlock() 28 | s.store[key] = value 29 | return nil 30 | } 31 | 32 | func (s *MemoryStore) Get(key string) (interface{}, error) { 33 | s.mutex.RLock() 34 | defer s.mutex.RUnlock() 35 | if v, ok := s.store[key]; ok { 36 | return v, nil 37 | } 38 | 39 | return nil, ErrNotExist 40 | } 41 | 42 | func (s *MemoryStore) Del(key string) error { 43 | s.mutex.Lock() 44 | defer s.mutex.Unlock() 45 | delete(s.store, key) 46 | return nil 47 | } 48 | -------------------------------------------------------------------------------- /src/github.com/golang/protobuf/proto/map_test.go: -------------------------------------------------------------------------------- 1 | package proto_test 2 | 3 | import ( 4 | "fmt" 5 | "testing" 6 | 7 | "github.com/golang/protobuf/proto" 8 | ppb "github.com/golang/protobuf/proto/proto3_proto" 9 | ) 10 | 11 | func marshalled() []byte { 12 | m := &ppb.IntMaps{} 13 | for i := 0; i < 1000; i++ { 14 | m.Maps = append(m.Maps, &ppb.IntMap{ 15 | Rtt: map[int32]int32{1: 2}, 16 | }) 17 | } 18 | b, err := proto.Marshal(m) 19 | if err != nil { 20 | panic(fmt.Sprintf("Can't marshal %+v: %v", m, err)) 21 | } 22 | return b 23 | } 24 | 25 | func BenchmarkConcurrentMapUnmarshal(b *testing.B) { 26 | in := marshalled() 27 | b.RunParallel(func(pb *testing.PB) { 28 | for pb.Next() { 29 | var out ppb.IntMaps 30 | if err := proto.Unmarshal(in, &out); err != nil { 31 | b.Errorf("Can't unmarshal ppb.IntMaps: %v", err) 32 | } 33 | } 34 | }) 35 | } 36 | 37 | func BenchmarkSequentialMapUnmarshal(b *testing.B) { 38 | in := marshalled() 39 | b.ResetTimer() 40 | for i := 0; i < b.N; i++ { 41 | var out ppb.IntMaps 42 | if err := proto.Unmarshal(in, &out); err != nil { 43 | b.Errorf("Can't unmarshal ppb.IntMaps: %v", err) 44 | } 45 | } 46 | } 47 | -------------------------------------------------------------------------------- /src/server/algorithm/pk.go: -------------------------------------------------------------------------------- 1 | package algorithm 2 | 3 | func (this *Cards) Counter() *ValueCounter { 4 | var counter ValueCounter 5 | counter.Set(*this) 6 | return &counter 7 | } 8 | func (this *Cards) GetType() uint32 { 9 | if len(*this) == 0 { 10 | return 0 11 | } 12 | 13 | counter := this.Counter() 14 | ASort(*this, 0, int8(len(*this))-1, counter) 15 | 16 | if res := this.royalFlush(); res > 0 { 17 | return res 18 | } 19 | 20 | if res := this.straightFlush(); res > 0 { 21 | return res 22 | } 23 | 24 | if res := this.four(counter); res > 0 { 25 | return res 26 | } 27 | 28 | if res := this.fullFouse(counter); res > 0 { 29 | return res 30 | } 31 | 32 | if res := this.flush(); res > 0 { 33 | return res 34 | } 35 | 36 | if res := this.straight(); res > 0 { 37 | return res 38 | } 39 | if res := this.three(counter); res > 0 { 40 | return res 41 | } 42 | if res := this.twoPair(); res > 0 { 43 | return res 44 | } 45 | 46 | if res := this.onePair(); res > 0 { 47 | return res 48 | } 49 | //高牌(high card) 50 | //既不是同一花色也不是同一点数的五张牌组成。 51 | //平手牌:如果不止一人抓到此牌,则比较点数最大者, 52 | //如果点数最大的相同,则比较第二、第三、第四和第五大的,如果所有牌都相同,则平分彩池。 53 | return En(HIGH_CARD, ToValue(*this)) 54 | } 55 | -------------------------------------------------------------------------------- /src/github.com/go-xorm/core/scan.go: -------------------------------------------------------------------------------- 1 | package core 2 | 3 | import ( 4 | "database/sql/driver" 5 | "fmt" 6 | "time" 7 | ) 8 | 9 | type NullTime time.Time 10 | 11 | var ( 12 | _ driver.Valuer = NullTime{} 13 | ) 14 | 15 | func (ns *NullTime) Scan(value interface{}) error { 16 | if value == nil { 17 | return nil 18 | } 19 | return convertTime(ns, value) 20 | } 21 | 22 | // Value implements the driver Valuer interface. 23 | func (ns NullTime) Value() (driver.Value, error) { 24 | if (time.Time)(ns).IsZero() { 25 | return nil, nil 26 | } 27 | return (time.Time)(ns).Format("2006-01-02 15:04:05"), nil 28 | } 29 | 30 | func convertTime(dest *NullTime, src interface{}) error { 31 | // Common cases, without reflect. 32 | switch s := src.(type) { 33 | case string: 34 | t, err := time.Parse("2006-01-02 15:04:05", s) 35 | if err != nil { 36 | return err 37 | } 38 | *dest = NullTime(t) 39 | return nil 40 | case []uint8: 41 | t, err := time.Parse("2006-01-02 15:04:05", string(s)) 42 | if err != nil { 43 | return err 44 | } 45 | *dest = NullTime(t) 46 | return nil 47 | case nil: 48 | default: 49 | return fmt.Errorf("unsupported driver -> Scan pair: %T -> %T", src, dest) 50 | } 51 | return nil 52 | } 53 | -------------------------------------------------------------------------------- /src/github.com/gorilla/websocket/client_test.go: -------------------------------------------------------------------------------- 1 | // Copyright 2014 The Gorilla WebSocket Authors. All rights reserved. 2 | // Use of this source code is governed by a BSD-style 3 | // license that can be found in the LICENSE file. 4 | 5 | package websocket 6 | 7 | import ( 8 | "net/url" 9 | "testing" 10 | ) 11 | 12 | var hostPortNoPortTests = []struct { 13 | u *url.URL 14 | hostPort, hostNoPort string 15 | }{ 16 | {&url.URL{Scheme: "ws", Host: "example.com"}, "example.com:80", "example.com"}, 17 | {&url.URL{Scheme: "wss", Host: "example.com"}, "example.com:443", "example.com"}, 18 | {&url.URL{Scheme: "ws", Host: "example.com:7777"}, "example.com:7777", "example.com"}, 19 | {&url.URL{Scheme: "wss", Host: "example.com:7777"}, "example.com:7777", "example.com"}, 20 | } 21 | 22 | func TestHostPortNoPort(t *testing.T) { 23 | for _, tt := range hostPortNoPortTests { 24 | hostPort, hostNoPort := hostPortNoPort(tt.u) 25 | if hostPort != tt.hostPort { 26 | t.Errorf("hostPortNoPort(%v) returned hostPort %q, want %q", tt.u, hostPort, tt.hostPort) 27 | } 28 | if hostNoPort != tt.hostNoPort { 29 | t.Errorf("hostPortNoPort(%v) returned hostNoPort %q, want %q", tt.u, hostNoPort, tt.hostNoPort) 30 | } 31 | } 32 | } 33 | -------------------------------------------------------------------------------- /src/github.com/stretchr/testify/require/requirements.go: -------------------------------------------------------------------------------- 1 | package require 2 | 3 | // TestingT is an interface wrapper around *testing.T 4 | type TestingT interface { 5 | Errorf(format string, args ...interface{}) 6 | FailNow() 7 | } 8 | 9 | type tHelper interface { 10 | Helper() 11 | } 12 | 13 | // ComparisonAssertionFunc is a common function prototype when comparing two values. Can be useful 14 | // for table driven tests. 15 | type ComparisonAssertionFunc func(TestingT, interface{}, interface{}, ...interface{}) 16 | 17 | // ValueAssertionFunc is a common function prototype when validating a single value. Can be useful 18 | // for table driven tests. 19 | type ValueAssertionFunc func(TestingT, interface{}, ...interface{}) 20 | 21 | // BoolAssertionFunc is a common function prototype when validating a bool value. Can be useful 22 | // for table driven tests. 23 | type BoolAssertionFunc func(TestingT, bool, ...interface{}) 24 | 25 | // ValuesAssertionFunc is a common function prototype when validating an error value. Can be useful 26 | // for table driven tests. 27 | type ErrorAssertionFunc func(TestingT, error, ...interface{}) 28 | 29 | //go:generate go run ../_codegen/main.go -output-package=require -template=require.go.tmpl -include-format-funcs 30 | -------------------------------------------------------------------------------- /src/github.com/dolotech/leaf/timer/example_test.go: -------------------------------------------------------------------------------- 1 | package timer 2 | 3 | import ( 4 | "time" 5 | "testing" 6 | ) 7 | 8 | func TestTimer(t *testing.T) { 9 | d := NewDispatcher(10) 10 | 11 | // timer 1 12 | d.AfterFunc(1, func() { 13 | t.Log("My name is Leaf") 14 | }) 15 | 16 | // timer 2 17 | tim := d.AfterFunc(1, func() { 18 | t.Log("will not print") 19 | }) 20 | tim.Stop() 21 | 22 | // dispatch 23 | (<-d.ChanTimer).Cb() 24 | 25 | // Output: 26 | // My name is Leaf 27 | } 28 | 29 | func TestNewCronExpr(t *testing.T) { 30 | cronExpr, err := NewCronExpr("0 * * * *") 31 | if err != nil { 32 | return 33 | } 34 | 35 | t.Log(cronExpr.Next(time.Date( 36 | 2000, 1, 1, 37 | 20, 10, 5, 38 | 0, time.UTC, 39 | ))) 40 | 41 | // Output: 42 | // 2000-01-01 21:00:00 +0000 UTC 43 | } 44 | 45 | func TestDispatcher_CronFunc(t *testing.T) { 46 | d := NewDispatcher(10) 47 | 48 | // cron expr 49 | cronExpr, err := NewCronExpr("* * * * * *") 50 | if err != nil { 51 | t.Log(err) 52 | return 53 | } 54 | 55 | // cron 56 | var c *Cron 57 | c = d.CronFunc(cronExpr, func() { 58 | t.Log("My name is Leaf") 59 | c.Stop() 60 | }) 61 | 62 | // dispatch 63 | (<-d.ChanTimer).Cb() 64 | 65 | // Output: 66 | // My name is Leaf 67 | } 68 | -------------------------------------------------------------------------------- /src/github.com/stretchr/testify/LICENSE: -------------------------------------------------------------------------------- 1 | Copyright (c) 2012 - 2013 Mat Ryer and Tyler Bunnell 2 | 3 | Please consider promoting this project if you find it useful. 4 | 5 | Permission is hereby granted, free of charge, to any person 6 | obtaining a copy of this software and associated documentation 7 | files (the "Software"), to deal in the Software without restriction, 8 | including without limitation the rights to use, copy, modify, merge, 9 | publish, distribute, sublicense, and/or sell copies of the Software, 10 | and to permit persons to whom the Software is furnished to do so, 11 | subject to the following conditions: 12 | 13 | The above copyright notice and this permission notice shall be included 14 | in all copies or substantial portions of the Software. 15 | 16 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, 17 | EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES 18 | OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. 19 | IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, 20 | DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT 21 | OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE 22 | OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. 23 | -------------------------------------------------------------------------------- /src/github.com/stretchr/testify/vendor/github.com/stretchr/objx/LICENSE: -------------------------------------------------------------------------------- 1 | The MIT License 2 | 3 | Copyright (c) 2014 Stretchr, Inc. 4 | Copyright (c) 2017-2018 objx contributors 5 | 6 | Permission is hereby granted, free of charge, to any person obtaining a copy 7 | of this software and associated documentation files (the "Software"), to deal 8 | in the Software without restriction, including without limitation the rights 9 | to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 10 | copies of the Software, and to permit persons to whom the Software is 11 | furnished to do so, subject to the following conditions: 12 | 13 | The above copyright notice and this permission notice shall be included in all 14 | copies or substantial portions of the Software. 15 | 16 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 17 | IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 18 | FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 19 | AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 20 | LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 21 | OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE 22 | SOFTWARE. 23 | -------------------------------------------------------------------------------- /src/server/game/internal/room_test.go: -------------------------------------------------------------------------------- 1 | package internal 2 | 3 | import ( 4 | "testing" 5 | "time" 6 | "reflect" 7 | ) 8 | 9 | func TestRoom_Value(t *testing.T) { 10 | t.Log(reflect.ValueOf(12)) 11 | } 12 | func TestRoom_RecvMsg(t *testing.T) { 13 | 14 | /*room:= NewRoom(&model.Room{}) 15 | 16 | 17 | protocol:= &msg2.JoinRoom{RoomNumber:"9999"} 18 | 19 | 20 | room.Send(12,protocol) 21 | 22 | */ 23 | //msg1:= &msg2.LeaveRoom{RoomNumber:"9999"} 24 | //room.RecvMsg(12,msg1) 25 | 26 | time.Sleep(time.Second * 2) 27 | } 28 | func TestClose(t *testing.T) { 29 | 30 | c:= make(chan struct{},1) 31 | 32 | 33 | go func() { 34 | select { 35 | case <-c: 36 | default: 37 | t.Log("default") 38 | } 39 | }() 40 | <- time.After(time.Second) 41 | close(c) 42 | 43 | select { 44 | case c<- struct{}{}: 45 | default: 46 | t.Log("default") 47 | } 48 | 49 | <- time.After(time.Second) 50 | 51 | } 52 | func BenchmarkCloseRoom(t *testing.B) { 53 | 54 | /* 55 | 56 | for i:=0;i.*?)(?::(?P.*))?@)?` + // [user[:password]@] 25 | `(?:(?P[^\(]*)(?:\((?P[^\)]*)\))?)?` + // [net[(addr)]] 26 | `\/(?P.*?)` + // /dbname 27 | `(?:\?(?P[^\?]*))?$`) // [?param1=value1¶mN=valueN] 28 | matches := dsnPattern.FindStringSubmatch(dataSourceName) 29 | //tlsConfigRegister := make(map[string]*tls.Config) 30 | names := dsnPattern.SubexpNames() 31 | 32 | for i, match := range matches { 33 | switch names[i] { 34 | case "dbname": 35 | db.DbName = match 36 | } 37 | } 38 | if db.DbName == "" { 39 | return nil, errors.New("dbname is empty") 40 | } 41 | return db, nil 42 | } 43 | -------------------------------------------------------------------------------- /src/github.com/dolotech/lib/utils/map.go: -------------------------------------------------------------------------------- 1 | package utils 2 | 3 | import ( 4 | "sync" 5 | ) 6 | 7 | func NewMap() *Map { 8 | return &Map{elems: map[interface{}]interface{}{}} 9 | } 10 | 11 | type Map struct { 12 | sync.RWMutex 13 | elems map[interface{}]interface{} 14 | } 15 | 16 | func (this *Map) Get(key interface{}) interface{} { 17 | this.RLock() 18 | defer this.RUnlock() 19 | if value, ok := this.elems[key]; ok { 20 | return value 21 | } else { 22 | return nil 23 | } 24 | } 25 | func (this *Map) Set(key interface{}, value interface{}) { 26 | this.Lock() 27 | defer this.Unlock() 28 | this.elems[key] = value 29 | } 30 | 31 | func (this *Map) Del(key interface{}) { 32 | this.Lock() 33 | defer this.Unlock() 34 | delete(this.elems, key) 35 | } 36 | 37 | func (this *Map) Len() int { 38 | this.RLock() 39 | defer this.RUnlock() 40 | return len(this.elems) 41 | } 42 | 43 | func (this *Map) Range(f func(interface{}, interface{}) bool) { 44 | this.RLock() 45 | defer this.RUnlock() 46 | for k, v := range this.elems { 47 | if f(k, v) { 48 | break 49 | } 50 | } 51 | } 52 | 53 | func (this *Map) LRange(f func(interface{}, interface{}) bool) { 54 | this.Lock() 55 | defer this.Unlock() 56 | for k, v := range this.elems { 57 | if f(k, v) { 58 | break 59 | } 60 | } 61 | } 62 | -------------------------------------------------------------------------------- /src/github.com/dolotech/lib/utils/queue.go: -------------------------------------------------------------------------------- 1 | package utils 2 | 3 | type Queue struct { 4 | elems []interface{} 5 | nelems, popi, pushi int 6 | } 7 | 8 | func (q *Queue) Len() int { 9 | return q.nelems 10 | } 11 | 12 | func (q *Queue) Push(elem interface{}) { 13 | if q.nelems == len(q.elems) { 14 | q.expand() 15 | } 16 | q.elems[q.pushi] = elem 17 | q.nelems++ 18 | q.pushi = (q.pushi + 1) % len(q.elems) 19 | } 20 | 21 | func (q *Queue) Pop() (elem interface{}) { 22 | if q.nelems == 0 { 23 | return nil 24 | } 25 | elem = q.elems[q.popi] 26 | q.elems[q.popi] = nil // Help GC. 27 | q.nelems-- 28 | q.popi = (q.popi + 1) % len(q.elems) 29 | return elem 30 | } 31 | 32 | func (q *Queue) expand() { 33 | curcap := len(q.elems) 34 | var newcap int 35 | if curcap == 0 { 36 | newcap = 8 37 | } else if curcap < 1024 { 38 | newcap = curcap * 2 39 | } else { 40 | newcap = curcap + (curcap / 4) 41 | } 42 | elems := make([]interface{}, newcap) 43 | 44 | if q.popi == 0 { 45 | copy(elems, q.elems) 46 | q.pushi = curcap 47 | } else { 48 | newpopi := newcap - (curcap - q.popi) 49 | copy(elems, q.elems[:q.popi]) 50 | copy(elems[newpopi:], q.elems[q.popi:]) 51 | q.popi = newpopi 52 | } 53 | for i := range q.elems { 54 | q.elems[i] = nil // Help GC. 55 | } 56 | q.elems = elems 57 | } 58 | -------------------------------------------------------------------------------- /src/github.com/lib/pq/CONTRIBUTING.md: -------------------------------------------------------------------------------- 1 | ## Contributing to pq 2 | 3 | `pq` has a backlog of pull requests, but contributions are still very 4 | much welcome. You can help with patch review, submitting bug reports, 5 | or adding new functionality. There is no formal style guide, but 6 | please conform to the style of existing code and general Go formatting 7 | conventions when submitting patches. 8 | 9 | ### Patch review 10 | 11 | Help review existing open pull requests by commenting on the code or 12 | proposed functionality. 13 | 14 | ### Bug reports 15 | 16 | We appreciate any bug reports, but especially ones with self-contained 17 | (doesn't depend on code outside of pq), minimal (can't be simplified 18 | further) test cases. It's especially helpful if you can submit a pull 19 | request with just the failing test case (you'll probably want to 20 | pattern it after the tests in 21 | [conn_test.go](https://github.com/lib/pq/blob/master/conn_test.go). 22 | 23 | ### New functionality 24 | 25 | There are a number of pending patches for new functionality, so 26 | additional feature patches will take a while to merge. Still, patches 27 | are generally reviewed based on usefulness and complexity in addition 28 | to time-in-queue, so if you have a knockout idea, take a shot. Feel 29 | free to open an issue discussion your proposed patch beforehand. 30 | -------------------------------------------------------------------------------- /src/main.go: -------------------------------------------------------------------------------- 1 | package main 2 | 3 | import ( 4 | "github.com/dolotech/leaf" 5 | "server/conf" 6 | "server/gate" 7 | "server/login" 8 | "net/http" 9 | "flag" 10 | "github.com/golang/glog" 11 | "github.com/dolotech/lib/db" 12 | "server/model" 13 | "server/game" 14 | ) 15 | 16 | var Commit = "" 17 | var BUILD_TIME = "" 18 | var VERSION = "" 19 | 20 | var createdb bool 21 | 22 | func init() { 23 | flag.StringVar(&conf.Server.WSAddr, "addr", ":8989", "websocket port") 24 | flag.IntVar(&conf.Server.MaxConnNum, "maxconn", 20000, "Max Conn Num") 25 | flag.StringVar(&conf.Server.DBUrl, "pg", "postgres://postgres:haosql@127.0.0.1:5432/postgres?sslmode=disable", "pg addr") 26 | flag.BoolVar(&createdb, "createdb", false, "initial database") 27 | 28 | flag.Parse() 29 | 30 | db.Init(conf.Server.DBUrl) 31 | if createdb { 32 | createDb() 33 | } 34 | } 35 | 36 | func main() { 37 | 38 | go leaf.Run( 39 | game.Module, 40 | gate.Module, 41 | login.Module, 42 | ) 43 | 44 | // for test client 45 | http.Handle("/", http.StripPrefix("/", http.FileServer(http.Dir("./")))) 46 | err := http.ListenAndServe(":12345", nil) 47 | if err != nil { 48 | glog.Fatalf("ListenAndServe: %v ", err) 49 | } 50 | } 51 | 52 | func createDb() { 53 | // 建表,只维护和服务器game里面有关的表 54 | err := db.C().Sync(model.User{}, model.Room{}) 55 | if err != nil { 56 | glog.Errorln(err) 57 | } 58 | } 59 | -------------------------------------------------------------------------------- /src/github.com/dolotech/lib/csv/example_test.go: -------------------------------------------------------------------------------- 1 | /********************************************************** 2 | * Author : Michael 3 | * Email : dolotech@163.com 4 | * Last modified : 2016-07-07 23:42 5 | * Filename : example_test.go 6 | * Description : 7 | * *******************************************************/ 8 | package csv 9 | 10 | import ( 11 | "fmt" 12 | "github.com/golang/glog" 13 | ) 14 | 15 | type Person struct { 16 | Name string `csv:"Full Name"` 17 | income string // unexported fields are not Unmarshalled 18 | Age int `csv:"-"` // skip this field 19 | Address Address `csv:"Street"` // skip this field 20 | } 21 | 22 | type Address struct { 23 | City string 24 | Street string 25 | } 26 | 27 | func (a *Address) UnmarshalCSV(val string, row *Row) error { 28 | c, _ := row.Named("City") 29 | s, _ := row.Named("Street") 30 | 31 | a.Street = s 32 | a.City = c 33 | 34 | return nil 35 | } 36 | 37 | func ExampleUnmarshal() { 38 | people := []Person{} 39 | 40 | sample := []byte( 41 | `Full Name,income,Age,City,Street 42 | John Doe,"32,000",45,Brooklyn,"7th Street" 43 | `) 44 | 45 | err := Unmarshal(sample, &people) 46 | 47 | if err != nil { 48 | glog.Infoln("Error: ", err) 49 | } 50 | 51 | glog.Infof("%+v", people) 52 | 53 | // Output: 54 | // [{Name:John Doe income: Age:0 Address:{City:Brooklyn Street:7th Street}}] 55 | } 56 | -------------------------------------------------------------------------------- /src/github.com/golang/protobuf/ptypes/regen.sh: -------------------------------------------------------------------------------- 1 | #!/bin/bash -e 2 | # 3 | # This script fetches and rebuilds the "well-known types" protocol buffers. 4 | # To run this you will need protoc and goprotobuf installed; 5 | # see https://github.com/golang/protobuf for instructions. 6 | # You also need Go and Git installed. 7 | 8 | PKG=github.com/golang/protobuf/ptypes 9 | UPSTREAM=https://github.com/google/protobuf 10 | UPSTREAM_SUBDIR=src/google/protobuf 11 | PROTO_FILES=(any duration empty struct timestamp wrappers) 12 | 13 | function die() { 14 | echo 1>&2 $* 15 | exit 1 16 | } 17 | 18 | # Sanity check that the right tools are accessible. 19 | for tool in go git protoc protoc-gen-go; do 20 | q=$(which $tool) || die "didn't find $tool" 21 | echo 1>&2 "$tool: $q" 22 | done 23 | 24 | tmpdir=$(mktemp -d -t regen-wkt.XXXXXX) 25 | trap 'rm -rf $tmpdir' EXIT 26 | 27 | echo -n 1>&2 "finding package dir... " 28 | pkgdir=$(go list -f '{{.Dir}}' $PKG) 29 | echo 1>&2 $pkgdir 30 | base=$(echo $pkgdir | sed "s,/$PKG\$,,") 31 | echo 1>&2 "base: $base" 32 | cd "$base" 33 | 34 | echo 1>&2 "fetching latest protos... " 35 | git clone -q $UPSTREAM $tmpdir 36 | 37 | for file in ${PROTO_FILES[@]}; do 38 | echo 1>&2 "* $file" 39 | protoc --go_out=. -I$tmpdir/src $tmpdir/src/google/protobuf/$file.proto || die 40 | cp $tmpdir/src/google/protobuf/$file.proto $PKG/$file 41 | done 42 | 43 | echo 1>&2 "All OK" 44 | -------------------------------------------------------------------------------- /src/github.com/go-xorm/xorm/processors.go: -------------------------------------------------------------------------------- 1 | // Copyright 2015 The Xorm Authors. All rights reserved. 2 | // Use of this source code is governed by a BSD-style 3 | // license that can be found in the LICENSE file. 4 | 5 | package xorm 6 | 7 | // Executed before an object is initially persisted to the database 8 | type BeforeInsertProcessor interface { 9 | BeforeInsert() 10 | } 11 | 12 | // Executed before an object is updated 13 | type BeforeUpdateProcessor interface { 14 | BeforeUpdate() 15 | } 16 | 17 | // Executed before an object is deleted 18 | type BeforeDeleteProcessor interface { 19 | BeforeDelete() 20 | } 21 | 22 | type BeforeSetProcessor interface { 23 | BeforeSet(string, Cell) 24 | } 25 | 26 | type AfterSetProcessor interface { 27 | AfterSet(string, Cell) 28 | } 29 | 30 | // !nashtsai! TODO enable BeforeValidateProcessor when xorm start to support validations 31 | //// Executed before an object is validated 32 | //type BeforeValidateProcessor interface { 33 | // BeforeValidate() 34 | //} 35 | // -- 36 | 37 | // Executed after an object is persisted to the database 38 | type AfterInsertProcessor interface { 39 | AfterInsert() 40 | } 41 | 42 | // Executed after an object has been updated 43 | type AfterUpdateProcessor interface { 44 | AfterUpdate() 45 | } 46 | 47 | // Executed after an object has been deleted 48 | type AfterDeleteProcessor interface { 49 | AfterDelete() 50 | } 51 | -------------------------------------------------------------------------------- /src/server/model/room_data.go: -------------------------------------------------------------------------------- 1 | package model 2 | 3 | import ( 4 | "time" 5 | "github.com/dolotech/lib/db" 6 | ) 7 | 8 | //房间基本信息 9 | 10 | type Room struct { 11 | Rid uint32 `xorm:"'rid' pk autoincr BIGINT"` 12 | Number string `xorm:"'number' index not null VARCHAR(8)"` // 给玩家展示的房间号 13 | Pwd string `xorm:"'pwd' VARCHAR(16)"` //房间锁--密码 14 | State uint8 `xorm:"'state' smallint"` //房间状态 0默认可用 1不可用 15 | Name string `xorm:"'name' VARCHAR(16)"` //房间名字 16 | CreatedAt time.Time `xorm:"'created_at' index created"` //创建时间 17 | OriginalOwnerID uint32 `xorm:"'original_owner_id'"` //原始创建人的信息 18 | Owner uint32 `xorm:"'owner'"` //房管 19 | Kind uint32 `xorm:"'kind'"` //游戏类型 即玩法 20 | DraginChips uint32 `xorm:"'dragin_chips'"` //带入筹码 21 | 22 | //Occupants []*uint32 `xorm:"'occupants'"` // 玩家列表,列表第一项为庄家 23 | } 24 | 25 | func (u *Room) Insert() (int64, error) { 26 | return db.C().Engine().InsertOne(u) 27 | } 28 | 29 | func (this *Room) GetById() (bool, error) { 30 | return db.C().Engine().Where("uid = ?", this.Rid).Get(this) 31 | } 32 | 33 | 34 | func (r *Room) CreatedTime() uint32 { 35 | return uint32(r.CreatedAt.Unix()) 36 | } -------------------------------------------------------------------------------- /src/github.com/dolotech/lib/pse/pse_test.go: -------------------------------------------------------------------------------- 1 | // Copyright 2015-2016 Apcera Inc. All rights reserved. 2 | 3 | package pse 4 | 5 | import ( 6 | "fmt" 7 | "os" 8 | "os/exec" 9 | "runtime" 10 | "testing" 11 | ) 12 | 13 | func TestPSEmulation(t *testing.T) { 14 | if runtime.GOOS == "windows" { 15 | t.Skipf("Skipping this test on Windows") 16 | } 17 | var rss, vss, psRss, psVss int64 18 | var pcpu, psPcpu float64 19 | 20 | runtime.GC() 21 | 22 | // PS version first 23 | pidStr := fmt.Sprintf("%d", os.Getpid()) 24 | out, err := exec.Command("ps", "o", "pcpu=,rss=,vsz=", "-p", pidStr).Output() 25 | if err != nil { 26 | t.Fatalf("Failed to execute ps command: %v\n", err) 27 | } 28 | 29 | fmt.Sscanf(string(out), "%f %d %d", &psPcpu, &psRss, &psVss) 30 | psRss *= 1024 // 1k blocks, want bytes. 31 | psVss *= 1024 // 1k blocks, want bytes. 32 | 33 | runtime.GC() 34 | 35 | // Our internal version 36 | ProcUsage(&pcpu, &rss, &vss) 37 | 38 | if pcpu != psPcpu { 39 | delta := int64(pcpu - psPcpu) 40 | if delta < 0 { 41 | delta = -delta 42 | } 43 | if delta > 30 { // 30%? 44 | t.Fatalf("CPUs did not match close enough: %f vs %f", pcpu, psPcpu) 45 | } 46 | } 47 | if rss != psRss { 48 | delta := rss - psRss 49 | if delta < 0 { 50 | delta = -delta 51 | } 52 | if delta > 1024*1024 { // 1MB 53 | t.Fatalf("RSSs did not match close enough: %d vs %d", rss, psRss) 54 | } 55 | } 56 | } 57 | -------------------------------------------------------------------------------- /src/github.com/gorilla/websocket/LICENSE: -------------------------------------------------------------------------------- 1 | Copyright (c) 2013 The Gorilla WebSocket Authors. All rights reserved. 2 | 3 | Redistribution and use in source and binary forms, with or without 4 | modification, are permitted provided that the following conditions are met: 5 | 6 | Redistributions of source code must retain the above copyright notice, this 7 | list of conditions and the following disclaimer. 8 | 9 | Redistributions in binary form must reproduce the above copyright notice, 10 | this list of conditions and the following disclaimer in the documentation 11 | and/or other materials provided with the distribution. 12 | 13 | THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND 14 | ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED 15 | WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE 16 | DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE 17 | FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL 18 | DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR 19 | SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER 20 | CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, 21 | OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE 22 | OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 23 | -------------------------------------------------------------------------------- /src/github.com/gorilla/websocket/examples/chat/hub.go: -------------------------------------------------------------------------------- 1 | // Copyright 2013 The Gorilla WebSocket Authors. All rights reserved. 2 | // Use of this source code is governed by a BSD-style 3 | // license that can be found in the LICENSE file. 4 | 5 | package main 6 | 7 | // hub maintains the set of active clients and broadcasts messages to the 8 | // clients. 9 | type Hub struct { 10 | // Registered clients. 11 | clients map[*Client]bool 12 | 13 | // Inbound messages from the clients. 14 | broadcast chan []byte 15 | 16 | // Register requests from the clients. 17 | register chan *Client 18 | 19 | // Unregister requests from clients. 20 | unregister chan *Client 21 | } 22 | 23 | func newHub() *Hub { 24 | return &Hub{ 25 | broadcast: make(chan []byte), 26 | register: make(chan *Client), 27 | unregister: make(chan *Client), 28 | clients: make(map[*Client]bool), 29 | } 30 | } 31 | 32 | func (h *Hub) run() { 33 | for { 34 | select { 35 | case client := <-h.register: 36 | h.clients[client] = true 37 | case client := <-h.unregister: 38 | if _, ok := h.clients[client]; ok { 39 | delete(h.clients, client) 40 | close(client.send) 41 | } 42 | case message := <-h.broadcast: 43 | for client := range h.clients { 44 | select { 45 | case client.send <- message: 46 | default: 47 | close(client.send) 48 | delete(h.clients, client) 49 | } 50 | } 51 | } 52 | } 53 | } 54 | -------------------------------------------------------------------------------- /src/github.com/gorilla/websocket/mask.go: -------------------------------------------------------------------------------- 1 | // Copyright 2016 The Gorilla WebSocket Authors. All rights reserved. Use of 2 | // this source code is governed by a BSD-style license that can be found in the 3 | // LICENSE file. 4 | 5 | // +build !appengine 6 | 7 | package websocket 8 | 9 | import "unsafe" 10 | 11 | const wordSize = int(unsafe.Sizeof(uintptr(0))) 12 | 13 | func maskBytes(key [4]byte, pos int, b []byte) int { 14 | // Mask one byte at a time for small buffers. 15 | if len(b) < 2*wordSize { 16 | for i := range b { 17 | b[i] ^= key[pos&3] 18 | pos++ 19 | } 20 | return pos & 3 21 | } 22 | 23 | // Mask one byte at a time to word boundary. 24 | if n := int(uintptr(unsafe.Pointer(&b[0]))) % wordSize; n != 0 { 25 | n = wordSize - n 26 | for i := range b[:n] { 27 | b[i] ^= key[pos&3] 28 | pos++ 29 | } 30 | b = b[n:] 31 | } 32 | 33 | // Create aligned word size key. 34 | var k [wordSize]byte 35 | for i := range k { 36 | k[i] = key[(pos+i)&3] 37 | } 38 | kw := *(*uintptr)(unsafe.Pointer(&k)) 39 | 40 | // Mask one word at a time. 41 | n := (len(b) / wordSize) * wordSize 42 | for i := 0; i < n; i += wordSize { 43 | *(*uintptr)(unsafe.Pointer(uintptr(unsafe.Pointer(&b[0])) + uintptr(i))) ^= kw 44 | } 45 | 46 | // Mask one byte at a time for remaining bytes. 47 | b = b[n:] 48 | for i := range b { 49 | b[i] ^= key[pos&3] 50 | pos++ 51 | } 52 | 53 | return pos & 3 54 | } 55 | -------------------------------------------------------------------------------- /src/github.com/stretchr/testify/suite/interfaces.go: -------------------------------------------------------------------------------- 1 | package suite 2 | 3 | import "testing" 4 | 5 | // TestingSuite can store and return the current *testing.T context 6 | // generated by 'go test'. 7 | type TestingSuite interface { 8 | T() *testing.T 9 | SetT(*testing.T) 10 | } 11 | 12 | // SetupAllSuite has a SetupSuite method, which will run before the 13 | // tests in the suite are run. 14 | type SetupAllSuite interface { 15 | SetupSuite() 16 | } 17 | 18 | // SetupTestSuite has a SetupTest method, which will run before each 19 | // test in the suite. 20 | type SetupTestSuite interface { 21 | SetupTest() 22 | } 23 | 24 | // TearDownAllSuite has a TearDownSuite method, which will run after 25 | // all the tests in the suite have been run. 26 | type TearDownAllSuite interface { 27 | TearDownSuite() 28 | } 29 | 30 | // TearDownTestSuite has a TearDownTest method, which will run after 31 | // each test in the suite. 32 | type TearDownTestSuite interface { 33 | TearDownTest() 34 | } 35 | 36 | // BeforeTest has a function to be executed right before the test 37 | // starts and receives the suite and test names as input 38 | type BeforeTest interface { 39 | BeforeTest(suiteName, testName string) 40 | } 41 | 42 | // AfterTest has a function to be executed right after the test 43 | // finishes and receives the suite and test names as input 44 | type AfterTest interface { 45 | AfterTest(suiteName, testName string) 46 | } 47 | -------------------------------------------------------------------------------- /src/github.com/go-xorm/core/index.go: -------------------------------------------------------------------------------- 1 | package core 2 | 3 | import ( 4 | "fmt" 5 | "sort" 6 | "strings" 7 | ) 8 | 9 | const ( 10 | IndexType = iota + 1 11 | UniqueType 12 | ) 13 | 14 | // database index 15 | type Index struct { 16 | IsRegular bool 17 | Name string 18 | Type int 19 | Cols []string 20 | } 21 | 22 | func (index *Index) XName(tableName string) string { 23 | if !strings.HasPrefix(index.Name, "UQE_") && 24 | !strings.HasPrefix(index.Name, "IDX_") { 25 | if index.Type == UniqueType { 26 | return fmt.Sprintf("UQE_%v_%v", tableName, index.Name) 27 | } 28 | return fmt.Sprintf("IDX_%v_%v", tableName, index.Name) 29 | } 30 | return index.Name 31 | } 32 | 33 | // add columns which will be composite index 34 | func (index *Index) AddColumn(cols ...string) { 35 | for _, col := range cols { 36 | index.Cols = append(index.Cols, col) 37 | } 38 | } 39 | 40 | func (index *Index) Equal(dst *Index) bool { 41 | if index.Type != dst.Type { 42 | return false 43 | } 44 | if len(index.Cols) != len(dst.Cols) { 45 | return false 46 | } 47 | sort.StringSlice(index.Cols).Sort() 48 | sort.StringSlice(dst.Cols).Sort() 49 | 50 | for i := 0; i < len(index.Cols); i++ { 51 | if index.Cols[i] != dst.Cols[i] { 52 | return false 53 | } 54 | } 55 | return true 56 | } 57 | 58 | // new an index 59 | func NewIndex(name string, indexType int) *Index { 60 | return &Index{true, name, indexType, make([]string, 0)} 61 | } 62 | -------------------------------------------------------------------------------- /src/github.com/go-xorm/xorm/mysql_driver.go: -------------------------------------------------------------------------------- 1 | // Copyright 2015 The Xorm Authors. All rights reserved. 2 | // Use of this source code is governed by a BSD-style 3 | // license that can be found in the LICENSE file. 4 | 5 | package xorm 6 | 7 | import ( 8 | "regexp" 9 | "strings" 10 | 11 | "github.com/go-xorm/core" 12 | ) 13 | 14 | type mysqlDriver struct { 15 | } 16 | 17 | func (p *mysqlDriver) Parse(driverName, dataSourceName string) (*core.Uri, error) { 18 | dsnPattern := regexp.MustCompile( 19 | `^(?:(?P.*?)(?::(?P.*))?@)?` + // [user[:password]@] 20 | `(?:(?P[^\(]*)(?:\((?P[^\)]*)\))?)?` + // [net[(addr)]] 21 | `\/(?P.*?)` + // /dbname 22 | `(?:\?(?P[^\?]*))?$`) // [?param1=value1¶mN=valueN] 23 | matches := dsnPattern.FindStringSubmatch(dataSourceName) 24 | //tlsConfigRegister := make(map[string]*tls.Config) 25 | names := dsnPattern.SubexpNames() 26 | 27 | uri := &core.Uri{DbType: core.MYSQL} 28 | 29 | for i, match := range matches { 30 | switch names[i] { 31 | case "dbname": 32 | uri.DbName = match 33 | case "params": 34 | if len(match) > 0 { 35 | kvs := strings.Split(match, "&") 36 | for _, kv := range kvs { 37 | splits := strings.Split(kv, "=") 38 | if len(splits) == 2 { 39 | switch splits[0] { 40 | case "charset": 41 | uri.Charset = splits[1] 42 | } 43 | } 44 | } 45 | } 46 | 47 | } 48 | } 49 | return uri, nil 50 | } 51 | -------------------------------------------------------------------------------- /src/github.com/stretchr/testify/http/test_response_writer.go: -------------------------------------------------------------------------------- 1 | package http 2 | 3 | import ( 4 | "net/http" 5 | ) 6 | 7 | // TestResponseWriter DEPRECATED: We recommend you use http://golang.org/pkg/net/http/httptest instead. 8 | type TestResponseWriter struct { 9 | 10 | // StatusCode is the last int written by the call to WriteHeader(int) 11 | StatusCode int 12 | 13 | // Output is a string containing the written bytes using the Write([]byte) func. 14 | Output string 15 | 16 | // header is the internal storage of the http.Header object 17 | header http.Header 18 | } 19 | 20 | // Header DEPRECATED: We recommend you use http://golang.org/pkg/net/http/httptest instead. 21 | func (rw *TestResponseWriter) Header() http.Header { 22 | 23 | if rw.header == nil { 24 | rw.header = make(http.Header) 25 | } 26 | 27 | return rw.header 28 | } 29 | 30 | // Write DEPRECATED: We recommend you use http://golang.org/pkg/net/http/httptest instead. 31 | func (rw *TestResponseWriter) Write(bytes []byte) (int, error) { 32 | 33 | // assume 200 success if no header has been set 34 | if rw.StatusCode == 0 { 35 | rw.WriteHeader(200) 36 | } 37 | 38 | // add these bytes to the output string 39 | rw.Output = rw.Output + string(bytes) 40 | 41 | // return normal values 42 | return 0, nil 43 | 44 | } 45 | 46 | // WriteHeader DEPRECATED: We recommend you use http://golang.org/pkg/net/http/httptest instead. 47 | func (rw *TestResponseWriter) WriteHeader(i int) { 48 | rw.StatusCode = i 49 | } 50 | -------------------------------------------------------------------------------- /src/github.com/dolotech/lib/csv/csv_test.go: -------------------------------------------------------------------------------- 1 | /********************************************************** 2 | * Author : Michael 3 | * Email : dolotech@163.com 4 | * Last modified : 2016-07-07 23:41 5 | * Filename : csv_test.go 6 | * Description : 7 | * *******************************************************/ 8 | package csv 9 | 10 | import ( 11 | "fmt" 12 | "reflect" 13 | "testing" 14 | ) 15 | 16 | type simple struct { 17 | Name string `csv:"FullName"` 18 | Gender string 19 | private int `csv:"-"` 20 | Ignore string `csv:"-"` 21 | Age int 22 | } 23 | 24 | func TestHeader(t *testing.T) { 25 | x := reflect.TypeOf(simple{}) 26 | 27 | // Get the header when defined via a tag 28 | f, _ := x.FieldByName("Name") 29 | h, _ := fieldHeaderName(f) 30 | 31 | if h != "FullName" { 32 | t.Error("header does not match") 33 | } 34 | 35 | // Use the field FullName when there is no tag 36 | f, _ = x.FieldByName("Gender") 37 | h, _ = fieldHeaderName(f) 38 | 39 | if h != "Gender" { 40 | t.Error("Default header FullName not created") 41 | } 42 | 43 | // Get the header when defined via a tag 44 | f, _ = x.FieldByName("Ignore") 45 | _, ok := fieldHeaderName(f) 46 | 47 | if ok == true { 48 | t.Error("Omitted field returned ok") 49 | } 50 | } 51 | 52 | func TestHeaders(t *testing.T) { 53 | x := reflect.TypeOf(simple{}) 54 | 55 | hh := colNames(x) 56 | 57 | if "[FullName Gender Age]" != fmt.Sprintf("%v", hh) { 58 | t.Errorf("Incorrected headers: %v", hh) 59 | } 60 | } 61 | -------------------------------------------------------------------------------- /src/github.com/dolotech/lib/pse/pse_freebsd.go: -------------------------------------------------------------------------------- 1 | // Copyright 2015-2016 Apcera Inc. All rights reserved. 2 | 3 | package pse 4 | 5 | /* 6 | #include 7 | #include 8 | #include 9 | #include 10 | #include 11 | 12 | long pagetok(long size) 13 | { 14 | int pageshift, pagesize; 15 | 16 | pagesize = getpagesize(); 17 | pageshift = 0; 18 | 19 | while (pagesize > 1) { 20 | pageshift++; 21 | pagesize >>= 1; 22 | } 23 | 24 | return (size << pageshift); 25 | } 26 | 27 | int getusage(double *pcpu, unsigned int *rss, unsigned int *vss) 28 | { 29 | int mib[4], ret; 30 | size_t len; 31 | struct kinfo_proc kp; 32 | 33 | len = 4; 34 | sysctlnametomib("kern.proc.pid", mib, &len); 35 | 36 | mib[3] = getpid(); 37 | len = sizeof(kp); 38 | 39 | ret = sysctl(mib, 4, &kp, &len, NULL, 0); 40 | if (ret != 0) { 41 | return (errno); 42 | } 43 | 44 | *rss = pagetok(kp.ki_rssize); 45 | *vss = kp.ki_size; 46 | *pcpu = kp.ki_pctcpu; 47 | 48 | return 0; 49 | } 50 | 51 | */ 52 | import "C" 53 | 54 | import ( 55 | "syscall" 56 | ) 57 | 58 | // This is a placeholder for now. 59 | func ProcUsage(pcpu *float64, rss, vss *int64) error { 60 | var r, v C.uint 61 | var c C.double 62 | 63 | if ret := C.getusage(&c, &r, &v); ret != 0 { 64 | return syscall.Errno(ret) 65 | } 66 | 67 | *pcpu = float64(c) 68 | *rss = int64(r) 69 | *vss = int64(v) 70 | 71 | return nil 72 | } 73 | -------------------------------------------------------------------------------- /src/server/game/internal/module.go: -------------------------------------------------------------------------------- 1 | package internal 2 | 3 | import ( 4 | "github.com/dolotech/leaf/module" 5 | "server/base" 6 | "github.com/golang/glog" 7 | "server/protocol" 8 | "github.com/dolotech/leaf/room" 9 | "reflect" 10 | "server/model" 11 | ) 12 | 13 | var ( 14 | skeleton = base.NewSkeleton() 15 | ChanRPC = skeleton.ChanRPCServer 16 | ) 17 | 18 | func handler(m interface{}, h interface{}) { 19 | skeleton.RegisterChanRPC(reflect.TypeOf(m), h) 20 | } 21 | func init() { 22 | handler(&protocol.JoinRoom{}, room.OnMessage) 23 | handler(&protocol.LeaveRoom{}, room.OnMessage) 24 | handler(&protocol.Bet{}, room.OnMessage) 25 | handler(&protocol.SitDown{}, room.OnMessage) // 26 | handler(&protocol.StandUp{}, room.OnMessage) // 27 | handler(&protocol.Chat{}, room.OnMessage) // 28 | } 29 | 30 | type Module struct { 31 | *module.Skeleton 32 | } 33 | 34 | func (m *Module) OnInit() { 35 | m.Skeleton = skeleton 36 | room.Init(&Creator{}) 37 | } 38 | 39 | func (m *Module) OnDestroy() { 40 | glog.Errorln("OnDestroy") 41 | } 42 | 43 | type Creator struct{} 44 | 45 | // 对玩家未进入房间,或者没房间数据的处理 46 | func (this *Creator) Create(m interface{}) room.IRoom { 47 | if msg, ok := m.(*protocol.JoinRoom); ok { 48 | if len(msg.RoomNumber) == 0 { 49 | r := room.FindRoom() 50 | return r 51 | } 52 | r := room.GetRoom(msg.RoomNumber) 53 | if r != nil { 54 | return r 55 | } 56 | room := NewRoom(9, 5, 10, 1000, model.Timeout) 57 | room.Insert() 58 | return room 59 | } 60 | return nil 61 | } 62 | -------------------------------------------------------------------------------- /src/github.com/dolotech/lib/csv/bench_test.go: -------------------------------------------------------------------------------- 1 | /********************************************************** 2 | * Author : Michael 3 | * Email : dolotech@163.com 4 | * Last modified : 2016-07-07 23:40 5 | * Filename : bench_test.go 6 | * Description : 7 | * *******************************************************/ 8 | package csv 9 | 10 | import ( 11 | "bytes" 12 | "compress/gzip" 13 | "io/ioutil" 14 | "os" 15 | "testing" 16 | ) 17 | 18 | // Benchmark with large CSV data set 19 | 20 | func loadData() []byte { 21 | f, err := os.Open("testdata/ercot-dam.csv.gz") 22 | if err != nil { 23 | panic(err) 24 | } 25 | defer f.Close() 26 | 27 | gz, err := gzip.NewReader(f) 28 | if err != nil { 29 | panic(err) 30 | } 31 | 32 | data, err := ioutil.ReadAll(gz) 33 | if err != nil { 34 | panic(err) 35 | } 36 | 37 | return data 38 | } 39 | 40 | type Price struct { 41 | DeliveryDate string 42 | HourEnding string 43 | BusName string 44 | LMP float32 45 | DSTFlag bool `true:"Y" false:"N"` 46 | } 47 | 48 | func BenchmarkUnmarshal(b *testing.B) { 49 | b.StopTimer() 50 | data := loadData() 51 | b.StartTimer() 52 | 53 | pp := []Price{} 54 | 55 | err := Unmarshal(data, &pp) 56 | if err != nil { 57 | panic(err) 58 | } 59 | 60 | out, err := Marshal(pp) 61 | if err != nil { 62 | panic(err) 63 | } 64 | 65 | if bytes.Equal(data, out) != true { 66 | panic("wrong results") 67 | } 68 | 69 | b.Logf("Unmarshal %d rows", len(pp)) 70 | b.Logf("Marshaled %d bytes", len(out)) 71 | } 72 | -------------------------------------------------------------------------------- /src/github.com/gorilla/websocket/example_test.go: -------------------------------------------------------------------------------- 1 | // Copyright 2015 The Gorilla WebSocket Authors. All rights reserved. 2 | // Use of this source code is governed by a BSD-style 3 | // license that can be found in the LICENSE file. 4 | 5 | package websocket_test 6 | 7 | import ( 8 | "log" 9 | "net/http" 10 | "testing" 11 | 12 | "github.com/gorilla/websocket" 13 | ) 14 | 15 | var ( 16 | c *websocket.Conn 17 | req *http.Request 18 | ) 19 | 20 | // The websocket.IsUnexpectedCloseError function is useful for identifying 21 | // application and protocol errors. 22 | // 23 | // This server application works with a client application running in the 24 | // browser. The client application does not explicitly close the websocket. The 25 | // only expected close message from the client has the code 26 | // websocket.CloseGoingAway. All other other close messages are likely the 27 | // result of an application or protocol error and are logged to aid debugging. 28 | func ExampleIsUnexpectedCloseError() { 29 | 30 | for { 31 | messageType, p, err := c.ReadMessage() 32 | if err != nil { 33 | if websocket.IsUnexpectedCloseError(err, websocket.CloseGoingAway) { 34 | log.Printf("error: %v, user-agent: %v", err, req.Header.Get("User-Agent")) 35 | } 36 | return 37 | } 38 | processMesage(messageType, p) 39 | } 40 | } 41 | 42 | func processMesage(mt int, p []byte) {} 43 | 44 | // TestX prevents godoc from showing this entire file in the example. Remove 45 | // this function when a second example is added. 46 | func TestX(t *testing.T) {} 47 | -------------------------------------------------------------------------------- /src/github.com/gorilla/websocket/client_clone_legacy.go: -------------------------------------------------------------------------------- 1 | // Copyright 2013 The Gorilla WebSocket Authors. All rights reserved. 2 | // Use of this source code is governed by a BSD-style 3 | // license that can be found in the LICENSE file. 4 | 5 | // +build !go1.8 6 | 7 | package websocket 8 | 9 | import "crypto/tls" 10 | 11 | // cloneTLSConfig clones all public fields except the fields 12 | // SessionTicketsDisabled and SessionTicketKey. This avoids copying the 13 | // sync.Mutex in the sync.Once and makes it safe to call cloneTLSConfig on a 14 | // config in active use. 15 | func cloneTLSConfig(cfg *tls.Config) *tls.Config { 16 | if cfg == nil { 17 | return &tls.Config{} 18 | } 19 | return &tls.Config{ 20 | Rand: cfg.Rand, 21 | Time: cfg.Time, 22 | Certificates: cfg.Certificates, 23 | NameToCertificate: cfg.NameToCertificate, 24 | GetCertificate: cfg.GetCertificate, 25 | RootCAs: cfg.RootCAs, 26 | NextProtos: cfg.NextProtos, 27 | ServerName: cfg.ServerName, 28 | ClientAuth: cfg.ClientAuth, 29 | ClientCAs: cfg.ClientCAs, 30 | InsecureSkipVerify: cfg.InsecureSkipVerify, 31 | CipherSuites: cfg.CipherSuites, 32 | PreferServerCipherSuites: cfg.PreferServerCipherSuites, 33 | ClientSessionCache: cfg.ClientSessionCache, 34 | MinVersion: cfg.MinVersion, 35 | MaxVersion: cfg.MaxVersion, 36 | CurvePreferences: cfg.CurvePreferences, 37 | } 38 | } 39 | -------------------------------------------------------------------------------- /src/github.com/dolotech/lib/utils/aes.go: -------------------------------------------------------------------------------- 1 | package utils 2 | 3 | import ( 4 | "crypto/aes" 5 | "crypto/cipher" 6 | "errors" 7 | ) 8 | 9 | //type AesEncrypt struct { 10 | // Key []byte 11 | //} 12 | 13 | func SetKey(key []byte) ([]byte,error){ 14 | keyLen := len(key) 15 | if keyLen < 16 { 16 | //panic("res key 长度不能小于16") 17 | return nil,errors.New("res key 长度不能小于16") 18 | } 19 | if keyLen >= 32 { 20 | //取前32个字节 21 | return key[:32],nil 22 | } 23 | if keyLen >= 24 { 24 | //取前24个字节 25 | return key[:24],nil 26 | } 27 | //取前16个字节 28 | return key[:16],nil 29 | } 30 | 31 | //加密字符串 32 | func AesEncrypt(key []byte,strMesg []byte) ([]byte, error) { 33 | key,err:= SetKey(key) 34 | encrypted := make([]byte, len(strMesg)) 35 | if err!= nil{ 36 | return encrypted,err 37 | } 38 | var iv = key[:aes.BlockSize] 39 | 40 | aesBlockEncrypter, err := aes.NewCipher(key) 41 | if err != nil { 42 | return nil, err 43 | } 44 | aesEncrypter := cipher.NewCFBEncrypter(aesBlockEncrypter, iv) 45 | aesEncrypter.XORKeyStream(encrypted, strMesg) 46 | return encrypted, nil 47 | } 48 | 49 | //解密字符串 50 | func AesDecrypt(key []byte,src []byte) (strDesc []byte, err error) { 51 | key,err= SetKey(key) 52 | if err!= nil{ 53 | return 54 | } 55 | 56 | var iv = key[:aes.BlockSize] 57 | decrypted := make([]byte, len(src)) 58 | var aesBlockDecrypter cipher.Block 59 | aesBlockDecrypter, err = aes.NewCipher(key) 60 | if err != nil { 61 | return 62 | } 63 | aesDecrypter := cipher.NewCFBDecrypter(aesBlockDecrypter, iv) 64 | aesDecrypter.XORKeyStream(decrypted, src) 65 | return decrypted,err 66 | } 67 | -------------------------------------------------------------------------------- /src/github.com/stretchr/testify/assert/doc.go: -------------------------------------------------------------------------------- 1 | // Package assert provides a set of comprehensive testing tools for use with the normal Go testing system. 2 | // 3 | // Example Usage 4 | // 5 | // The following is a complete example using assert in a standard test function: 6 | // import ( 7 | // "testing" 8 | // "github.com/stretchr/testify/assert" 9 | // ) 10 | // 11 | // func TestSomething(t *testing.T) { 12 | // 13 | // var a string = "Hello" 14 | // var b string = "Hello" 15 | // 16 | // assert.Equal(t, a, b, "The two words should be the same.") 17 | // 18 | // } 19 | // 20 | // if you assert many times, use the format below: 21 | // 22 | // import ( 23 | // "testing" 24 | // "github.com/stretchr/testify/assert" 25 | // ) 26 | // 27 | // func TestSomething(t *testing.T) { 28 | // assert := assert.New(t) 29 | // 30 | // var a string = "Hello" 31 | // var b string = "Hello" 32 | // 33 | // assert.Equal(a, b, "The two words should be the same.") 34 | // } 35 | // 36 | // Assertions 37 | // 38 | // Assertions allow you to easily write test code, and are global funcs in the `assert` package. 39 | // All assertion functions take, as the first argument, the `*testing.T` object provided by the 40 | // testing framework. This allows the assertion funcs to write the failings and other details to 41 | // the correct place. 42 | // 43 | // Every assertion function also takes an optional string message as the final argument, 44 | // allowing custom error messages to be appended to the message the assertion method outputs. 45 | package assert 46 | -------------------------------------------------------------------------------- /src/github.com/stretchr/testify/vendor/github.com/pmezard/go-difflib/LICENSE: -------------------------------------------------------------------------------- 1 | Copyright (c) 2013, Patrick Mezard 2 | All rights reserved. 3 | 4 | Redistribution and use in source and binary forms, with or without 5 | modification, are permitted provided that the following conditions are 6 | met: 7 | 8 | Redistributions of source code must retain the above copyright 9 | notice, this list of conditions and the following disclaimer. 10 | Redistributions in binary form must reproduce the above copyright 11 | notice, this list of conditions and the following disclaimer in the 12 | documentation and/or other materials provided with the distribution. 13 | The names of its contributors may not be used to endorse or promote 14 | products derived from this software without specific prior written 15 | permission. 16 | 17 | THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS 18 | IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED 19 | TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A 20 | PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT 21 | HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, 22 | SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED 23 | TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR 24 | PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF 25 | LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING 26 | NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS 27 | SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 28 | -------------------------------------------------------------------------------- /src/github.com/lib/pq/oid/gen.go: -------------------------------------------------------------------------------- 1 | // +build ignore 2 | 3 | // Generate the table of OID values 4 | // Run with 'go run gen.go'. 5 | package main 6 | 7 | import ( 8 | "database/sql" 9 | "fmt" 10 | "log" 11 | "os" 12 | "os/exec" 13 | 14 | _ "github.com/lib/pq" 15 | ) 16 | 17 | func main() { 18 | datname := os.Getenv("PGDATABASE") 19 | sslmode := os.Getenv("PGSSLMODE") 20 | 21 | if datname == "" { 22 | os.Setenv("PGDATABASE", "pqgotest") 23 | } 24 | 25 | if sslmode == "" { 26 | os.Setenv("PGSSLMODE", "disable") 27 | } 28 | 29 | db, err := sql.Open("postgres", "") 30 | if err != nil { 31 | log.Fatal(err) 32 | } 33 | cmd := exec.Command("gofmt") 34 | cmd.Stderr = os.Stderr 35 | w, err := cmd.StdinPipe() 36 | if err != nil { 37 | log.Fatal(err) 38 | } 39 | f, err := os.Create("types.go") 40 | if err != nil { 41 | log.Fatal(err) 42 | } 43 | cmd.Stdout = f 44 | err = cmd.Start() 45 | if err != nil { 46 | log.Fatal(err) 47 | } 48 | fmt.Fprintln(w, "// generated by 'go run gen.go'; do not edit") 49 | fmt.Fprintln(w, "\npackage oid") 50 | fmt.Fprintln(w, "const (") 51 | rows, err := db.Query(` 52 | SELECT typname, oid 53 | FROM pg_type WHERE oid < 10000 54 | ORDER BY oid; 55 | `) 56 | if err != nil { 57 | log.Fatal(err) 58 | } 59 | var name string 60 | var oid int 61 | for rows.Next() { 62 | err = rows.Scan(&name, &oid) 63 | if err != nil { 64 | log.Fatal(err) 65 | } 66 | fmt.Fprintf(w, "T_%s Oid = %d\n", name, oid) 67 | } 68 | if err = rows.Err(); err != nil { 69 | log.Fatal(err) 70 | } 71 | fmt.Fprintln(w, ")") 72 | w.Close() 73 | cmd.Wait() 74 | } 75 | -------------------------------------------------------------------------------- /src/github.com/go-xorm/xorm/LICENSE: -------------------------------------------------------------------------------- 1 | Copyright (c) 2013 - 2015 The Xorm Authors 2 | All rights reserved. 3 | 4 | Redistribution and use in source and binary forms, with or without 5 | modification, are permitted provided that the following conditions are met: 6 | 7 | * Redistributions of source code must retain the above copyright notice, this 8 | list of conditions and the following disclaimer. 9 | 10 | * Redistributions in binary form must reproduce the above copyright notice, 11 | this list of conditions and the following disclaimer in the documentation 12 | and/or other materials provided with the distribution. 13 | 14 | * Neither the name of the {organization} nor the names of its 15 | contributors may be used to endorse or promote products derived from 16 | this software without specific prior written permission. 17 | 18 | THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" 19 | AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE 20 | IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE 21 | DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE 22 | FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL 23 | DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR 24 | SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER 25 | CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, 26 | OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE 27 | OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 28 | -------------------------------------------------------------------------------- /src/server/algorithm/constan.go: -------------------------------------------------------------------------------- 1 | package algorithm 2 | 3 | // 扑克牌52张,分别包含普通牌52张 2-10、J、Q、K、A (以上每种牌4个花色 黑桃、梅花、红心、方块) 4 | var CARDS = []byte{ 5 | //方块 6 | 0x02, 0x03, 0x04, 0x05, 0x06, 0x07, 0x08, 0x09, 0x0A, 0x0B, 0x0C, 0x0D, 0x0E, 7 | //梅花 8 | 0x12, 0x13, 0x14, 0x15, 0x16, 0x17, 0x18, 0x19, 0x1A, 0x1B, 0x1C, 0x1D, 0x1E, 9 | //红桃 10 | 0x22, 0x23, 0x24, 0x25, 0x26, 0x27, 0x28, 0x29, 0x2A, 0x2B, 0x2C, 0x2D, 0x2E, 11 | //黑桃 12 | 0x32, 0x33, 0x34, 0x35, 0x36, 0x37, 0x38, 0x39, 0x3A, 0x3B, 0x3C, 0x3D, 0x3E, 13 | } 14 | 15 | const ( 16 | CARDRANK = 13 17 | SUITSIZE = 4 18 | TOTAL = 13 * 4 19 | 20 | TYPE_LEN = 5 // 牌型长度 21 | CARDS_LEN = 7 // 河牌+底牌长度 22 | ) 23 | 24 | //牌型大小: 25 | //1、皇家同花顺>同花顺>四条>葫芦>同花>顺子>三条>两队>一对>单牌 26 | //2、牌点从大到小为:A、K、Q、J、10、9、8、7、6、5、4、3、2,各花色不分大小。 27 | //3、同种牌型,对子时比对子的大小,其它牌型比最大的牌张,如最大牌张相同则比第二大的牌张,以此类推,都相同时为相同。 28 | //4、A 可以组顺子 A、1、2、3、4、5 也可以组顺子 10、J、Q、K、A 同花顺同理 29 | //所有牌型如下: 30 | const ( 31 | ROYAL_FLUSH uint8= 10 // 皇家同花顺:同一花色的最大顺子。(最大牌:A-K-Q-J-10) 32 | STRAIGHT_FLUSH uint8= 9 // 同花顺:同一花色的顺子。(最大牌:K-Q-J-10-9 最小牌:A-2-3-4-5) 33 | FOUR uint8= 8 // 四条:四同张加单张。(最大牌:A-A-A-A-K 最小牌:2-2-2-2-3) 34 | FULL_HOUSE uint8= 7 // 葫芦(豪斯):三同张加对子。(最大牌:A-A-A-K-K 最小牌:2-2-2-3-3) 35 | FLUSH uint8= 6 // 同花:同一花色。(最大牌:A-K-Q-J-9 最小牌:2-3-4-5-7) 36 | STRAIGHT uint8= 5 // 顺子:花色不一样的顺子。(最大牌:A-K-Q-J-10 最小牌:A-2-3-4-5) 37 | THREE uint8= 4 // 三条:三同张加两单张。(最大牌:A-A-A-K-Q 最小牌:2-2-2-3-4) 38 | TWO_PAIR uint8= 3 // 两对:(最大牌:A-A-K-K-Q 最小牌:2-2-3-3-4) 39 | ONE_PAIR uint8= 2 // 一对:(最大牌:A-A-K-Q-J 最小牌:2-2-3-4-5) 40 | HIGH_CARD uint8= 1 // 高牌:(最大牌:A-K-Q-J-9 最小牌:2-3-4-5-7) 41 | ) 42 | -------------------------------------------------------------------------------- /src/github.com/go-xorm/core/LICENSE: -------------------------------------------------------------------------------- 1 | Copyright (c) 2013 - 2015 Lunny Xiao 2 | All rights reserved. 3 | 4 | Redistribution and use in source and binary forms, with or without 5 | modification, are permitted provided that the following conditions are met: 6 | 7 | * Redistributions of source code must retain the above copyright notice, this 8 | list of conditions and the following disclaimer. 9 | 10 | * Redistributions in binary form must reproduce the above copyright notice, 11 | this list of conditions and the following disclaimer in the documentation 12 | and/or other materials provided with the distribution. 13 | 14 | * Neither the name of the {organization} nor the names of its 15 | contributors may be used to endorse or promote products derived from 16 | this software without specific prior written permission. 17 | 18 | THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" 19 | AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE 20 | IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE 21 | DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE 22 | FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL 23 | DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR 24 | SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER 25 | CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, 26 | OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE 27 | OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 28 | -------------------------------------------------------------------------------- /src/server/game/internal/pot.go: -------------------------------------------------------------------------------- 1 | package internal 2 | 3 | import ( 4 | "sort" 5 | ) 6 | 7 | type handBet struct { 8 | Pos uint8 9 | Bet uint32 10 | } 11 | 12 | type handBets []handBet 13 | 14 | func (p handBets) Len() int { 15 | return len(p) 16 | } 17 | 18 | func (p handBets) Less(i, j int) bool { 19 | return p[i].Bet < p[j].Bet 20 | } 21 | 22 | func (p handBets) Swap(i, j int) { 23 | p[i], p[j] = p[j], p[i] 24 | } 25 | 26 | type handPot struct { 27 | Pot uint32 28 | OPos []uint32 29 | } 30 | 31 | //因为每个人手中的筹码量会不时的产生变化,当出现多个筹码量不等的玩家“全下(ALL-IN)”争夺底池的时候就会出现多个奖池, 32 | //这时候底池将分出主池和边池,主池里的筹码可 由任何一位争夺者胜利后将其拿走,其后每个边池将分别由参与者按牌型大小分别拿走。 33 | //举个例子,假如发到河牌后共有三个人争夺底池,三人分别用ABC代替, 34 | //假设A玩家手中有60,B手中有80,C手中有100。三人ALL-IN后则先把每人的筹码划分成: 35 | //A玩家60;B玩家60+20;C玩家60+20+20,然后分出底池: 36 | //主池 由60乘以三个人(A+B+C)形成一个堆,总额为180; 37 | //边池一 由20乘以剩下的两个人(B+C)多出的部分为一个堆,总额为40; 38 | //边池二 由筹码最多者C的多出的部分20单独组成一个堆,总额为20。 39 | //现在三个底池形成了,然后分别按照牌型的大小来决定谁拿走哪个底池…… 40 | //首先,主池可以由三人中的任何一人得到胜利都可以拿走; 41 | // 但是边池一的争夺就只能在B与C之间产生,两人谁赢谁拿走,与A无关(就算A玩家的牌最大也只能拿走他参与的主池)。 42 | //而最后剩下的边池二不论三人谁输谁赢都只能由C拿走,因为边池二里的筹码只有C自己参与了,与其他人无关。 43 | func calcPot(bets []uint32) (pots []handPot) { 44 | var obs handBets 45 | for i, bet := range bets { 46 | if bet > 0 { 47 | obs = append(obs, handBet{Pos: uint8(i) + 1, Bet: bet}) 48 | } 49 | } 50 | sort.Sort(obs) 51 | 52 | for i, ob := range obs { 53 | if ob.Bet > 0 { 54 | s := obs[i:] 55 | hpot := handPot{Pot: ob.Bet * uint32(len(s))} 56 | for j, _ := range s { 57 | s[j].Bet -= ob.Bet 58 | hpot.OPos = append(hpot.OPos, uint32(s[j].Pos)) 59 | } 60 | pots = append(pots, hpot) 61 | } 62 | } 63 | return 64 | } 65 | -------------------------------------------------------------------------------- /src/github.com/go-xorm/xorm/mymysql_driver.go: -------------------------------------------------------------------------------- 1 | // Copyright 2015 The Xorm Authors. All rights reserved. 2 | // Use of this source code is governed by a BSD-style 3 | // license that can be found in the LICENSE file. 4 | 5 | package xorm 6 | 7 | import ( 8 | "errors" 9 | "strings" 10 | "time" 11 | 12 | "github.com/go-xorm/core" 13 | ) 14 | 15 | type mymysqlDriver struct { 16 | } 17 | 18 | func (p *mymysqlDriver) Parse(driverName, dataSourceName string) (*core.Uri, error) { 19 | db := &core.Uri{DbType: core.MYSQL} 20 | 21 | pd := strings.SplitN(dataSourceName, "*", 2) 22 | if len(pd) == 2 { 23 | // Parse protocol part of URI 24 | p := strings.SplitN(pd[0], ":", 2) 25 | if len(p) != 2 { 26 | return nil, errors.New("Wrong protocol part of URI") 27 | } 28 | db.Proto = p[0] 29 | options := strings.Split(p[1], ",") 30 | db.Raddr = options[0] 31 | for _, o := range options[1:] { 32 | kv := strings.SplitN(o, "=", 2) 33 | var k, v string 34 | if len(kv) == 2 { 35 | k, v = kv[0], kv[1] 36 | } else { 37 | k, v = o, "true" 38 | } 39 | switch k { 40 | case "laddr": 41 | db.Laddr = v 42 | case "timeout": 43 | to, err := time.ParseDuration(v) 44 | if err != nil { 45 | return nil, err 46 | } 47 | db.Timeout = to 48 | default: 49 | return nil, errors.New("Unknown option: " + k) 50 | } 51 | } 52 | // Remove protocol part 53 | pd = pd[1:] 54 | } 55 | // Parse database part of URI 56 | dup := strings.SplitN(pd[0], "/", 3) 57 | if len(dup) != 3 { 58 | return nil, errors.New("Wrong database part of URI") 59 | } 60 | db.DbName = dup[0] 61 | db.User = dup[1] 62 | db.Passwd = dup[2] 63 | 64 | return db, nil 65 | } 66 | -------------------------------------------------------------------------------- /src/github.com/golang/protobuf/LICENSE: -------------------------------------------------------------------------------- 1 | Go support for Protocol Buffers - Google's data interchange format 2 | 3 | Copyright 2010 The Go Authors. All rights reserved. 4 | https://github.com/golang/protobuf 5 | 6 | Redistribution and use in source and binary forms, with or without 7 | modification, are permitted provided that the following conditions are 8 | met: 9 | 10 | * Redistributions of source code must retain the above copyright 11 | notice, this list of conditions and the following disclaimer. 12 | * Redistributions in binary form must reproduce the above 13 | copyright notice, this list of conditions and the following disclaimer 14 | in the documentation and/or other materials provided with the 15 | distribution. 16 | * Neither the name of Google Inc. nor the names of its 17 | contributors may be used to endorse or promote products derived from 18 | this software without specific prior written permission. 19 | 20 | THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS 21 | "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT 22 | LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR 23 | A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT 24 | OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, 25 | SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT 26 | LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, 27 | DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY 28 | THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT 29 | (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE 30 | OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 31 | 32 | -------------------------------------------------------------------------------- /src/github.com/stretchr/testify/vendor/github.com/stretchr/objx/value.go: -------------------------------------------------------------------------------- 1 | package objx 2 | 3 | import ( 4 | "fmt" 5 | "strconv" 6 | ) 7 | 8 | // Value provides methods for extracting interface{} data in various 9 | // types. 10 | type Value struct { 11 | // data contains the raw data being managed by this Value 12 | data interface{} 13 | } 14 | 15 | // Data returns the raw data contained by this Value 16 | func (v *Value) Data() interface{} { 17 | return v.data 18 | } 19 | 20 | // String returns the value always as a string 21 | func (v *Value) String() string { 22 | switch { 23 | case v.IsStr(): 24 | return v.Str() 25 | case v.IsBool(): 26 | return strconv.FormatBool(v.Bool()) 27 | case v.IsFloat32(): 28 | return strconv.FormatFloat(float64(v.Float32()), 'f', -1, 32) 29 | case v.IsFloat64(): 30 | return strconv.FormatFloat(v.Float64(), 'f', -1, 64) 31 | case v.IsInt(): 32 | return strconv.FormatInt(int64(v.Int()), 10) 33 | case v.IsInt(): 34 | return strconv.FormatInt(int64(v.Int()), 10) 35 | case v.IsInt8(): 36 | return strconv.FormatInt(int64(v.Int8()), 10) 37 | case v.IsInt16(): 38 | return strconv.FormatInt(int64(v.Int16()), 10) 39 | case v.IsInt32(): 40 | return strconv.FormatInt(int64(v.Int32()), 10) 41 | case v.IsInt64(): 42 | return strconv.FormatInt(v.Int64(), 10) 43 | case v.IsUint(): 44 | return strconv.FormatUint(uint64(v.Uint()), 10) 45 | case v.IsUint8(): 46 | return strconv.FormatUint(uint64(v.Uint8()), 10) 47 | case v.IsUint16(): 48 | return strconv.FormatUint(uint64(v.Uint16()), 10) 49 | case v.IsUint32(): 50 | return strconv.FormatUint(uint64(v.Uint32()), 10) 51 | case v.IsUint64(): 52 | return strconv.FormatUint(v.Uint64(), 10) 53 | } 54 | 55 | return fmt.Sprintf("%#v", v.Data()) 56 | } 57 | -------------------------------------------------------------------------------- /src/github.com/labstack/gommon/color/color_test.go: -------------------------------------------------------------------------------- 1 | package color 2 | 3 | import ( 4 | "testing" 5 | 6 | "github.com/stretchr/testify/assert" 7 | ) 8 | 9 | func TestText(t *testing.T) { 10 | Println("*** colored text ***") 11 | Println(Black("black")) 12 | Println(Red("red")) 13 | Println(Green("green")) 14 | Println(Yellow("yellow")) 15 | Println(Blue("blue")) 16 | Println(Magenta("magenta")) 17 | Println(Cyan("cyan")) 18 | Println(White("white")) 19 | Println(Grey("grey")) 20 | } 21 | 22 | func TestBackground(t *testing.T) { 23 | Println("*** colored background ***") 24 | Println(BlackBg("black background", Wht)) 25 | Println(RedBg("red background")) 26 | Println(GreenBg("green background")) 27 | Println(YellowBg("yellow background")) 28 | Println(BlueBg("blue background")) 29 | Println(MagentaBg("magenta background")) 30 | Println(CyanBg("cyan background")) 31 | Println(WhiteBg("white background")) 32 | } 33 | 34 | func TestEmphasis(t *testing.T) { 35 | Println("*** emphasis ***") 36 | Println(Reset("reset")) 37 | Println(Bold("bold")) 38 | Println(Dim("dim")) 39 | Println(Italic("italic")) 40 | Println(Underline("underline")) 41 | Println(Inverse("inverse")) 42 | Println(Hidden("hidden")) 43 | Println(Strikeout("strikeout")) 44 | } 45 | 46 | func TestMixMatch(t *testing.T) { 47 | Println("*** mix and match ***") 48 | Println(Green("bold green with white background", B, WhtBg)) 49 | Println(Red("underline red", U)) 50 | Println(Yellow("dim yellow", D)) 51 | Println(Cyan("inverse cyan", In)) 52 | Println(Blue("bold underline dim blue", B, U, D)) 53 | } 54 | 55 | func TestEnableDisable(t *testing.T) { 56 | Disable() 57 | assert.Equal(t, "red", Red("red")) 58 | Enable() 59 | assert.NotEqual(t, "green", Green("green")) 60 | } 61 | -------------------------------------------------------------------------------- /src/github.com/gorilla/websocket/json.go: -------------------------------------------------------------------------------- 1 | // Copyright 2013 The Gorilla WebSocket Authors. All rights reserved. 2 | // Use of this source code is governed by a BSD-style 3 | // license that can be found in the LICENSE file. 4 | 5 | package websocket 6 | 7 | import ( 8 | "encoding/json" 9 | "io" 10 | ) 11 | 12 | // WriteJSON writes the JSON encoding of v as a message. 13 | // 14 | // Deprecated: Use c.WriteJSON instead. 15 | func WriteJSON(c *Conn, v interface{}) error { 16 | return c.WriteJSON(v) 17 | } 18 | 19 | // WriteJSON writes the JSON encoding of v as a message. 20 | // 21 | // See the documentation for encoding/json Marshal for details about the 22 | // conversion of Go values to JSON. 23 | func (c *Conn) WriteJSON(v interface{}) error { 24 | w, err := c.NextWriter(TextMessage) 25 | if err != nil { 26 | return err 27 | } 28 | err1 := json.NewEncoder(w).Encode(v) 29 | err2 := w.Close() 30 | if err1 != nil { 31 | return err1 32 | } 33 | return err2 34 | } 35 | 36 | // ReadJSON reads the next JSON-encoded message from the connection and stores 37 | // it in the value pointed to by v. 38 | // 39 | // Deprecated: Use c.ReadJSON instead. 40 | func ReadJSON(c *Conn, v interface{}) error { 41 | return c.ReadJSON(v) 42 | } 43 | 44 | // ReadJSON reads the next JSON-encoded message from the connection and stores 45 | // it in the value pointed to by v. 46 | // 47 | // See the documentation for the encoding/json Unmarshal function for details 48 | // about the conversion of JSON to a Go value. 49 | func (c *Conn) ReadJSON(v interface{}) error { 50 | _, r, err := c.NextReader() 51 | if err != nil { 52 | return err 53 | } 54 | err = json.NewDecoder(r).Decode(v) 55 | if err == io.EOF { 56 | // One value is expected in the message. 57 | err = io.ErrUnexpectedEOF 58 | } 59 | return err 60 | } 61 | -------------------------------------------------------------------------------- /src/github.com/stretchr/testify/mock/doc.go: -------------------------------------------------------------------------------- 1 | // Package mock provides a system by which it is possible to mock your objects 2 | // and verify calls are happening as expected. 3 | // 4 | // Example Usage 5 | // 6 | // The mock package provides an object, Mock, that tracks activity on another object. It is usually 7 | // embedded into a test object as shown below: 8 | // 9 | // type MyTestObject struct { 10 | // // add a Mock object instance 11 | // mock.Mock 12 | // 13 | // // other fields go here as normal 14 | // } 15 | // 16 | // When implementing the methods of an interface, you wire your functions up 17 | // to call the Mock.Called(args...) method, and return the appropriate values. 18 | // 19 | // For example, to mock a method that saves the name and age of a person and returns 20 | // the year of their birth or an error, you might write this: 21 | // 22 | // func (o *MyTestObject) SavePersonDetails(firstname, lastname string, age int) (int, error) { 23 | // args := o.Called(firstname, lastname, age) 24 | // return args.Int(0), args.Error(1) 25 | // } 26 | // 27 | // The Int, Error and Bool methods are examples of strongly typed getters that take the argument 28 | // index position. Given this argument list: 29 | // 30 | // (12, true, "Something") 31 | // 32 | // You could read them out strongly typed like this: 33 | // 34 | // args.Int(0) 35 | // args.Bool(1) 36 | // args.String(2) 37 | // 38 | // For objects of your own type, use the generic Arguments.Get(index) method and make a type assertion: 39 | // 40 | // return args.Get(0).(*MyObject), args.Get(1).(*AnotherObjectOfMine) 41 | // 42 | // This may cause a panic if the object you are getting is nil (the type assertion will fail), in those 43 | // cases you should check for nil first. 44 | package mock 45 | -------------------------------------------------------------------------------- /src/github.com/dolotech/lib/csv/encode_test.go: -------------------------------------------------------------------------------- 1 | /********************************************************** 2 | * Author : Michael 3 | * Email : dolotech@163.com 4 | * Last modified : 2016-07-07 23:42 5 | * Filename : encode_test.go 6 | * Description : 7 | * *******************************************************/ 8 | package csv 9 | 10 | import ( 11 | "reflect" 12 | "testing" 13 | ) 14 | 15 | type X struct { 16 | First string 17 | } 18 | 19 | type P struct { 20 | First string 21 | Last string 22 | } 23 | 24 | func (p P) MarshalCSV() ([]byte, error) { 25 | return []byte(p.First + " " + p.Last), nil 26 | } 27 | 28 | func TestMarshal_without_a_slice(t *testing.T) { 29 | _, err := Marshal(simple{}) 30 | 31 | if err == nil { 32 | t.Error("Non slice produced no error") 33 | } 34 | } 35 | 36 | func TestEncodeFieldValue(t *testing.T) { 37 | var encTests = []struct { 38 | val interface{} 39 | expected string 40 | tag string 41 | }{ 42 | // Strings 43 | {"ABC", "ABC", ""}, 44 | {byte(123), "123", ""}, 45 | 46 | // Numerics 47 | {int(1), "1", ""}, 48 | {float32(3.2), "3.2", ""}, 49 | {uint32(123), "123", ""}, 50 | {complex64(1 + 2i), "(+1+2i)", ""}, 51 | 52 | // Boolean 53 | {true, "Yes", `true:"Yes" false:"No"`}, 54 | {false, "No", `true:"Yes" false:"No"`}, 55 | 56 | // TODO Array 57 | // Interface with Marshaler 58 | {P{"Jay", "Zee"}, "Jay Zee", ""}, 59 | 60 | // Struct without Marshaler will produce nothing 61 | {X{"Jay"}, "", ""}, 62 | } 63 | 64 | enc := &encoder{} 65 | 66 | for _, test := range encTests { 67 | fv := reflect.ValueOf(test.val) 68 | st := reflect.StructTag(test.tag) 69 | res := enc.encodeCol(fv, st) 70 | 71 | if res != test.expected { 72 | t.Errorf("%s does not match %s", res, test.expected) 73 | } 74 | } 75 | 76 | } 77 | -------------------------------------------------------------------------------- /src/github.com/davecgh/go-spew/spew/bypasssafe.go: -------------------------------------------------------------------------------- 1 | // Copyright (c) 2015 Dave Collins 2 | // 3 | // Permission to use, copy, modify, and distribute this software for any 4 | // purpose with or without fee is hereby granted, provided that the above 5 | // copyright notice and this permission notice appear in all copies. 6 | // 7 | // THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES 8 | // WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF 9 | // MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR 10 | // ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES 11 | // WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN 12 | // ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF 13 | // OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. 14 | 15 | // NOTE: Due to the following build constraints, this file will only be compiled 16 | // when either the code is running on Google App Engine or "-tags disableunsafe" 17 | // is added to the go build command line. 18 | // +build appengine disableunsafe 19 | 20 | package spew 21 | 22 | import "reflect" 23 | 24 | const ( 25 | // UnsafeDisabled is a build-time constant which specifies whether or 26 | // not access to the unsafe package is available. 27 | UnsafeDisabled = true 28 | ) 29 | 30 | // unsafeReflectValue typically converts the passed reflect.Value into a one 31 | // that bypasses the typical safety restrictions preventing access to 32 | // unaddressable and unexported data. However, doing this relies on access to 33 | // the unsafe package. This is a stub version which simply returns the passed 34 | // reflect.Value when the unsafe package is not available. 35 | func unsafeReflectValue(v reflect.Value) reflect.Value { 36 | return v 37 | } 38 | -------------------------------------------------------------------------------- /src/github.com/go-xorm/core/filter.go: -------------------------------------------------------------------------------- 1 | package core 2 | 3 | import ( 4 | "fmt" 5 | "strings" 6 | ) 7 | 8 | // Filter is an interface to filter SQL 9 | type Filter interface { 10 | Do(sql string, dialect Dialect, table *Table) string 11 | } 12 | 13 | // QuoteFilter filter SQL replace ` to database's own quote character 14 | type QuoteFilter struct { 15 | } 16 | 17 | func (s *QuoteFilter) Do(sql string, dialect Dialect, table *Table) string { 18 | return strings.Replace(sql, "`", dialect.QuoteStr(), -1) 19 | } 20 | 21 | // IdFilter filter SQL replace (id) to primary key column name 22 | type IdFilter struct { 23 | } 24 | 25 | type Quoter struct { 26 | dialect Dialect 27 | } 28 | 29 | func NewQuoter(dialect Dialect) *Quoter { 30 | return &Quoter{dialect} 31 | } 32 | 33 | func (q *Quoter) Quote(content string) string { 34 | return q.dialect.QuoteStr() + content + q.dialect.QuoteStr() 35 | } 36 | 37 | func (i *IdFilter) Do(sql string, dialect Dialect, table *Table) string { 38 | quoter := NewQuoter(dialect) 39 | if table != nil && len(table.PrimaryKeys) == 1 { 40 | sql = strings.Replace(sql, "`(id)`", quoter.Quote(table.PrimaryKeys[0]), -1) 41 | sql = strings.Replace(sql, quoter.Quote("(id)"), quoter.Quote(table.PrimaryKeys[0]), -1) 42 | return strings.Replace(sql, "(id)", quoter.Quote(table.PrimaryKeys[0]), -1) 43 | } 44 | return sql 45 | } 46 | 47 | // SeqFilter filter SQL replace ?, ? ... to $1, $2 ... 48 | type SeqFilter struct { 49 | Prefix string 50 | Start int 51 | } 52 | 53 | func (s *SeqFilter) Do(sql string, dialect Dialect, table *Table) string { 54 | segs := strings.Split(sql, "?") 55 | size := len(segs) 56 | res := "" 57 | for i, c := range segs { 58 | if i < size-1 { 59 | res += c + fmt.Sprintf("%s%v", s.Prefix, i+s.Start) 60 | } 61 | } 62 | res += segs[size-1] 63 | return res 64 | } 65 | -------------------------------------------------------------------------------- /src/github.com/golang/protobuf/protoc-gen-go/Makefile: -------------------------------------------------------------------------------- 1 | # Go support for Protocol Buffers - Google's data interchange format 2 | # 3 | # Copyright 2010 The Go Authors. All rights reserved. 4 | # https://github.com/golang/protobuf 5 | # 6 | # Redistribution and use in source and binary forms, with or without 7 | # modification, are permitted provided that the following conditions are 8 | # met: 9 | # 10 | # * Redistributions of source code must retain the above copyright 11 | # notice, this list of conditions and the following disclaimer. 12 | # * Redistributions in binary form must reproduce the above 13 | # copyright notice, this list of conditions and the following disclaimer 14 | # in the documentation and/or other materials provided with the 15 | # distribution. 16 | # * Neither the name of Google Inc. nor the names of its 17 | # contributors may be used to endorse or promote products derived from 18 | # this software without specific prior written permission. 19 | # 20 | # THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS 21 | # "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT 22 | # LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR 23 | # A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT 24 | # OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, 25 | # SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT 26 | # LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, 27 | # DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY 28 | # THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT 29 | # (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE 30 | # OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 31 | 32 | test: 33 | cd testdata && make test 34 | -------------------------------------------------------------------------------- /src/github.com/golang/protobuf/protoc-gen-go/link_grpc.go: -------------------------------------------------------------------------------- 1 | // Go support for Protocol Buffers - Google's data interchange format 2 | // 3 | // Copyright 2015 The Go Authors. All rights reserved. 4 | // https://github.com/golang/protobuf 5 | // 6 | // Redistribution and use in source and binary forms, with or without 7 | // modification, are permitted provided that the following conditions are 8 | // met: 9 | // 10 | // * Redistributions of source code must retain the above copyright 11 | // notice, this list of conditions and the following disclaimer. 12 | // * Redistributions in binary form must reproduce the above 13 | // copyright notice, this list of conditions and the following disclaimer 14 | // in the documentation and/or other materials provided with the 15 | // distribution. 16 | // * Neither the name of Google Inc. nor the names of its 17 | // contributors may be used to endorse or promote products derived from 18 | // this software without specific prior written permission. 19 | // 20 | // THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS 21 | // "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT 22 | // LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR 23 | // A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT 24 | // OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, 25 | // SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT 26 | // LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, 27 | // DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY 28 | // THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT 29 | // (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE 30 | // OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 31 | 32 | package main 33 | 34 | import _ "github.com/golang/protobuf/protoc-gen-go/grpc" 35 | -------------------------------------------------------------------------------- /src/github.com/golang/protobuf/ptypes/doc.go: -------------------------------------------------------------------------------- 1 | // Go support for Protocol Buffers - Google's data interchange format 2 | // 3 | // Copyright 2016 The Go Authors. All rights reserved. 4 | // https://github.com/golang/protobuf 5 | // 6 | // Redistribution and use in source and binary forms, with or without 7 | // modification, are permitted provided that the following conditions are 8 | // met: 9 | // 10 | // * Redistributions of source code must retain the above copyright 11 | // notice, this list of conditions and the following disclaimer. 12 | // * Redistributions in binary form must reproduce the above 13 | // copyright notice, this list of conditions and the following disclaimer 14 | // in the documentation and/or other materials provided with the 15 | // distribution. 16 | // * Neither the name of Google Inc. nor the names of its 17 | // contributors may be used to endorse or promote products derived from 18 | // this software without specific prior written permission. 19 | // 20 | // THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS 21 | // "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT 22 | // LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR 23 | // A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT 24 | // OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, 25 | // SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT 26 | // LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, 27 | // DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY 28 | // THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT 29 | // (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE 30 | // OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 31 | 32 | /* 33 | Package ptypes contains code for interacting with well-known types. 34 | */ 35 | package ptypes 36 | -------------------------------------------------------------------------------- /src/github.com/dolotech/leaf/timer/timer.go: -------------------------------------------------------------------------------- 1 | package timer 2 | 3 | import ( 4 | "github.com/dolotech/leaf/conf" 5 | "github.com/golang/glog" 6 | "runtime" 7 | "time" 8 | ) 9 | 10 | // one dispatcher per goroutine (goroutine not safe) 11 | type Dispatcher struct { 12 | ChanTimer chan *Timer 13 | } 14 | 15 | func NewDispatcher(l int) *Dispatcher { 16 | disp := new(Dispatcher) 17 | disp.ChanTimer = make(chan *Timer, l) 18 | return disp 19 | } 20 | 21 | // Timer 22 | type Timer struct { 23 | t *time.Timer 24 | cb func() 25 | } 26 | 27 | func (t *Timer) Stop() { 28 | t.t.Stop() 29 | t.cb = nil 30 | } 31 | 32 | func (t *Timer) Cb() { 33 | defer func() { 34 | t.cb = nil 35 | if r := recover(); r != nil { 36 | if conf.LenStackBuf > 0 { 37 | buf := make([]byte, conf.LenStackBuf) 38 | l := runtime.Stack(buf, false) 39 | glog.Error("%v: %s", r, buf[:l]) 40 | } else { 41 | glog.Error("%v", r) 42 | } 43 | } 44 | }() 45 | 46 | if t.cb != nil { 47 | t.cb() 48 | } 49 | } 50 | 51 | func (disp *Dispatcher) AfterFunc(d time.Duration, cb func()) *Timer { 52 | t := new(Timer) 53 | t.cb = cb 54 | t.t = time.AfterFunc(d, func() { 55 | disp.ChanTimer <- t 56 | }) 57 | return t 58 | } 59 | 60 | // Cron 61 | type Cron struct { 62 | t *Timer 63 | } 64 | 65 | func (c *Cron) Stop() { 66 | if c.t != nil { 67 | c.t.Stop() 68 | } 69 | } 70 | 71 | func (disp *Dispatcher) CronFunc(cronExpr *CronExpr, _cb func()) *Cron { 72 | c := new(Cron) 73 | 74 | now := time.Now() 75 | nextTime := cronExpr.Next(now) 76 | if nextTime.IsZero() { 77 | return c 78 | } 79 | 80 | // callback 81 | var cb func() 82 | cb = func() { 83 | defer _cb() 84 | 85 | now := time.Now() 86 | nextTime := cronExpr.Next(now) 87 | if nextTime.IsZero() { 88 | return 89 | } 90 | c.t = disp.AfterFunc(nextTime.Sub(now), cb) 91 | } 92 | 93 | c.t = disp.AfterFunc(nextTime.Sub(now), cb) 94 | return c 95 | } 96 | -------------------------------------------------------------------------------- /src/server/login/internal/handler.go: -------------------------------------------------------------------------------- 1 | package internal 2 | 3 | import ( 4 | "reflect" 5 | "server/protocol" 6 | "github.com/dolotech/leaf/gate" 7 | "server/game" 8 | "github.com/golang/glog" 9 | "server/model" 10 | "github.com/dolotech/leaf/room" 11 | ) 12 | 13 | func init() { 14 | handler(&protocol.UserLoginInfo{}, handlLoginUser) 15 | handler(&protocol.Version{}, handlVersion) 16 | handler(&protocol.RoomList{}, onRoomList) // 17 | } 18 | 19 | func handler(m interface{}, h interface{}) { 20 | skeleton.RegisterChanRPC(reflect.TypeOf(m), h) 21 | } 22 | 23 | func handlVersion(m *protocol.Version, a gate.Agent) { 24 | glog.Infoln(m) 25 | a.WriteMsg(m) 26 | } 27 | 28 | func handlLoginUser(m *protocol.UserLoginInfo, a gate.Agent) { 29 | user := &model.User{UnionId: m.UnionId} 30 | exist, err := user.GetByUnionId() 31 | if err != nil { 32 | a.WriteMsg(protocol.MSG_DB_Error) 33 | return 34 | } 35 | 36 | if !exist { 37 | user = &model.User{Nickname: m.Nickname, 38 | UnionId: m.UnionId} 39 | err := user.Insert() 40 | if err != nil { 41 | a.WriteMsg(protocol.MSG_User_Not_Exist) 42 | return 43 | } 44 | } 45 | 46 | resp := &protocol.UserLoginInfoResp{ 47 | Nickname: user.Nickname, 48 | Account: user.Account, 49 | UnionId: user.UnionId, 50 | } 51 | 52 | a.WriteMsg(resp) 53 | game.ChanRPC.Go(model.Agent_Login, user, a) 54 | } 55 | 56 | func onRoomList(m *protocol.RoomList, a gate.Agent) { 57 | 58 | msg := &protocol.RoomListResp{} 59 | 60 | array := room.GetRooms() 61 | rooms := make([]*protocol.Room, len(array)) 62 | 63 | for k, v := range array { 64 | d := v.Data() 65 | data := d.(*model.Room) 66 | rooms[k] = &protocol.Room{ 67 | 68 | Number: data.Number, 69 | MaxCap: v.Cap(), 70 | Cap: v.Len(), 71 | DraginChips: data.DraginChips, 72 | CreatedAt: data.CreatedTime(), 73 | Rid: data.Rid, 74 | } 75 | } 76 | msg.Room = rooms 77 | a.WriteMsg(msg) 78 | } 79 | -------------------------------------------------------------------------------- /src/github.com/stretchr/testify/vendor/github.com/davecgh/go-spew/spew/bypasssafe.go: -------------------------------------------------------------------------------- 1 | // Copyright (c) 2015-2016 Dave Collins 2 | // 3 | // Permission to use, copy, modify, and distribute this software for any 4 | // purpose with or without fee is hereby granted, provided that the above 5 | // copyright notice and this permission notice appear in all copies. 6 | // 7 | // THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES 8 | // WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF 9 | // MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR 10 | // ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES 11 | // WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN 12 | // ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF 13 | // OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. 14 | 15 | // NOTE: Due to the following build constraints, this file will only be compiled 16 | // when the code is running on Google App Engine, compiled by GopherJS, or 17 | // "-tags safe" is added to the go build command line. The "disableunsafe" 18 | // tag is deprecated and thus should not be used. 19 | // +build js appengine safe disableunsafe 20 | 21 | package spew 22 | 23 | import "reflect" 24 | 25 | const ( 26 | // UnsafeDisabled is a build-time constant which specifies whether or 27 | // not access to the unsafe package is available. 28 | UnsafeDisabled = true 29 | ) 30 | 31 | // unsafeReflectValue typically converts the passed reflect.Value into a one 32 | // that bypasses the typical safety restrictions preventing access to 33 | // unaddressable and unexported data. However, doing this relies on access to 34 | // the unsafe package. This is a stub version which simply returns the passed 35 | // reflect.Value when the unsafe package is not available. 36 | func unsafeReflectValue(v reflect.Value) reflect.Value { 37 | return v 38 | } 39 | -------------------------------------------------------------------------------- /src/github.com/golang/protobuf/protoc-gen-go/testdata/imp3.proto: -------------------------------------------------------------------------------- 1 | // Go support for Protocol Buffers - Google's data interchange format 2 | // 3 | // Copyright 2012 The Go Authors. All rights reserved. 4 | // https://github.com/golang/protobuf 5 | // 6 | // Redistribution and use in source and binary forms, with or without 7 | // modification, are permitted provided that the following conditions are 8 | // met: 9 | // 10 | // * Redistributions of source code must retain the above copyright 11 | // notice, this list of conditions and the following disclaimer. 12 | // * Redistributions in binary form must reproduce the above 13 | // copyright notice, this list of conditions and the following disclaimer 14 | // in the documentation and/or other materials provided with the 15 | // distribution. 16 | // * Neither the name of Google Inc. nor the names of its 17 | // contributors may be used to endorse or promote products derived from 18 | // this software without specific prior written permission. 19 | // 20 | // THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS 21 | // "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT 22 | // LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR 23 | // A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT 24 | // OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, 25 | // SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT 26 | // LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, 27 | // DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY 28 | // THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT 29 | // (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE 30 | // OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 31 | 32 | syntax = "proto2"; 33 | 34 | package imp; 35 | 36 | message ForeignImportedMessage { 37 | optional string tuber = 1; 38 | } 39 | -------------------------------------------------------------------------------- /src/github.com/golang/protobuf/protoc-gen-go/testdata/extension_extra.proto: -------------------------------------------------------------------------------- 1 | // Go support for Protocol Buffers - Google's data interchange format 2 | // 3 | // Copyright 2011 The Go Authors. All rights reserved. 4 | // https://github.com/golang/protobuf 5 | // 6 | // Redistribution and use in source and binary forms, with or without 7 | // modification, are permitted provided that the following conditions are 8 | // met: 9 | // 10 | // * Redistributions of source code must retain the above copyright 11 | // notice, this list of conditions and the following disclaimer. 12 | // * Redistributions in binary form must reproduce the above 13 | // copyright notice, this list of conditions and the following disclaimer 14 | // in the documentation and/or other materials provided with the 15 | // distribution. 16 | // * Neither the name of Google Inc. nor the names of its 17 | // contributors may be used to endorse or promote products derived from 18 | // this software without specific prior written permission. 19 | // 20 | // THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS 21 | // "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT 22 | // LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR 23 | // A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT 24 | // OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, 25 | // SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT 26 | // LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, 27 | // DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY 28 | // THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT 29 | // (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE 30 | // OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 31 | 32 | syntax = "proto2"; 33 | 34 | package extension_extra; 35 | 36 | message ExtraMessage { 37 | optional int32 width = 1; 38 | } 39 | -------------------------------------------------------------------------------- /src/github.com/gorilla/websocket/mask_test.go: -------------------------------------------------------------------------------- 1 | // Copyright 2016 The Gorilla WebSocket Authors. All rights reserved. Use of 2 | // this source code is governed by a BSD-style license that can be found in the 3 | // LICENSE file. 4 | 5 | // Require 1.7 for sub-bencmarks 6 | // +build go1.7,!appengine 7 | 8 | package websocket 9 | 10 | import ( 11 | "fmt" 12 | "testing" 13 | ) 14 | 15 | func maskBytesByByte(key [4]byte, pos int, b []byte) int { 16 | for i := range b { 17 | b[i] ^= key[pos&3] 18 | pos++ 19 | } 20 | return pos & 3 21 | } 22 | 23 | func notzero(b []byte) int { 24 | for i := range b { 25 | if b[i] != 0 { 26 | return i 27 | } 28 | } 29 | return -1 30 | } 31 | 32 | func TestMaskBytes(t *testing.T) { 33 | key := [4]byte{1, 2, 3, 4} 34 | for size := 1; size <= 1024; size++ { 35 | for align := 0; align < wordSize; align++ { 36 | for pos := 0; pos < 4; pos++ { 37 | b := make([]byte, size+align)[align:] 38 | maskBytes(key, pos, b) 39 | maskBytesByByte(key, pos, b) 40 | if i := notzero(b); i >= 0 { 41 | t.Errorf("size:%d, align:%d, pos:%d, offset:%d", size, align, pos, i) 42 | } 43 | } 44 | } 45 | } 46 | } 47 | 48 | func BenchmarkMaskBytes(b *testing.B) { 49 | for _, size := range []int{2, 4, 8, 16, 32, 512, 1024} { 50 | b.Run(fmt.Sprintf("size-%d", size), func(b *testing.B) { 51 | for _, align := range []int{wordSize / 2} { 52 | b.Run(fmt.Sprintf("align-%d", align), func(b *testing.B) { 53 | for _, fn := range []struct { 54 | name string 55 | fn func(key [4]byte, pos int, b []byte) int 56 | }{ 57 | {"byte", maskBytesByByte}, 58 | {"word", maskBytes}, 59 | } { 60 | b.Run(fn.name, func(b *testing.B) { 61 | key := newMaskKey() 62 | data := make([]byte, size+align)[align:] 63 | for i := 0; i < b.N; i++ { 64 | fn.fn(key, 0, data) 65 | } 66 | b.SetBytes(int64(len(data))) 67 | }) 68 | } 69 | }) 70 | } 71 | }) 72 | } 73 | } 74 | -------------------------------------------------------------------------------- /src/github.com/lib/pq/url.go: -------------------------------------------------------------------------------- 1 | package pq 2 | 3 | import ( 4 | "fmt" 5 | nurl "net/url" 6 | "sort" 7 | "strings" 8 | ) 9 | 10 | // ParseURL no longer needs to be used by clients of this library since supplying a URL as a 11 | // connection string to sql.Open() is now supported: 12 | // 13 | // sql.Open("postgres", "postgres://bob:secret@1.2.3.4:5432/mydb?sslmode=verify-full") 14 | // 15 | // It remains exported here for backwards-compatibility. 16 | // 17 | // ParseURL converts a url to a connection string for driver.Open. 18 | // Example: 19 | // 20 | // "postgres://bob:secret@1.2.3.4:5432/mydb?sslmode=verify-full" 21 | // 22 | // converts to: 23 | // 24 | // "user=bob password=secret host=1.2.3.4 port=5432 dbname=mydb sslmode=verify-full" 25 | // 26 | // A minimal example: 27 | // 28 | // "postgres://" 29 | // 30 | // This will be blank, causing driver.Open to use all of the defaults 31 | func ParseURL(url string) (string, error) { 32 | u, err := nurl.Parse(url) 33 | if err != nil { 34 | return "", err 35 | } 36 | 37 | if u.Scheme != "postgres" && u.Scheme != "postgresql" { 38 | return "", fmt.Errorf("invalid connection protocol: %s", u.Scheme) 39 | } 40 | 41 | var kvs []string 42 | escaper := strings.NewReplacer(` `, `\ `, `'`, `\'`, `\`, `\\`) 43 | accrue := func(k, v string) { 44 | if v != "" { 45 | kvs = append(kvs, k+"="+escaper.Replace(v)) 46 | } 47 | } 48 | 49 | if u.User != nil { 50 | v := u.User.Username() 51 | accrue("user", v) 52 | 53 | v, _ = u.User.Password() 54 | accrue("password", v) 55 | } 56 | 57 | i := strings.Index(u.Host, ":") 58 | if i < 0 { 59 | accrue("host", u.Host) 60 | } else { 61 | accrue("host", u.Host[:i]) 62 | accrue("port", u.Host[i+1:]) 63 | } 64 | 65 | if u.Path != "" { 66 | accrue("dbname", u.Path[1:]) 67 | } 68 | 69 | q := u.Query() 70 | for k := range q { 71 | accrue(k, q.Get(k)) 72 | } 73 | 74 | sort.Strings(kvs) // Makes testing easier (not a performance concern) 75 | return strings.Join(kvs, " "), nil 76 | } 77 | -------------------------------------------------------------------------------- /src/github.com/dolotech/lib/utils/random.go: -------------------------------------------------------------------------------- 1 | package utils 2 | 3 | import ( 4 | "math/rand" 5 | "time" 6 | "sync" 7 | //crand "crypto/rand" 8 | ) 9 | 10 | var o *rand.Rand = rand.New(rand.NewSource(TimestampNano())) 11 | var random_mux_ sync.Mutex 12 | 13 | func RandInt64() (r int64) { 14 | random_mux_.Lock() 15 | defer random_mux_.Unlock() 16 | return (o.Int63()) 17 | } 18 | 19 | func RandInt32() (r int32) { 20 | random_mux_.Lock() 21 | defer random_mux_.Unlock() 22 | return (o.Int31()) 23 | } 24 | 25 | func RandUint32() (r uint32) { 26 | random_mux_.Lock() 27 | defer random_mux_.Unlock() 28 | return (o.Uint32()) 29 | } 30 | 31 | func RandInt64N(n int64) (r int64) { 32 | random_mux_.Lock() 33 | defer random_mux_.Unlock() 34 | return (o.Int63n(n)) 35 | } 36 | 37 | func RandInt32N(n int32) (r int32) { 38 | random_mux_.Lock() 39 | defer random_mux_.Unlock() 40 | return (o.Int31n(n)) 41 | } 42 | 43 | var randomChan chan uint32 44 | 45 | func randUint32() { 46 | randomChan = make(chan uint32, 1024) 47 | go func() { 48 | var numstr uint32 49 | for { 50 | numstr = RandUint32() 51 | select { 52 | case randomChan <- numstr: 53 | } 54 | <-time.After(time.Millisecond * 100) 55 | } 56 | }() 57 | } 58 | 59 | func GetRandUint32() uint32 { 60 | return <-randomChan 61 | } 62 | 63 | 64 | func init() { 65 | rand.Seed(time.Now().UTC().UnixNano()) 66 | } 67 | 68 | var letters = []rune("abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ") 69 | 70 | func RandomString(length int) string { 71 | 72 | //rand.Seed(time.Now().UTC().UnixNano()) 73 | b := make([]rune, length) 74 | for i := range b { 75 | b[i] = letters[rand.Intn(len(letters))] 76 | } 77 | return string(b) 78 | } 79 | 80 | 81 | var letters_ = []rune("ABCDEFGHIJKLMNPQRSTUVWXYZ123456789") 82 | 83 | func RandomString_(length int) string { 84 | 85 | //rand.Seed(time.Now().UTC().UnixNano()) 86 | b := make([]rune, length) 87 | for i := range b { 88 | b[i] = letters_[rand.Intn(len(letters_))] 89 | } 90 | return string(b) 91 | } -------------------------------------------------------------------------------- /src/github.com/golang/protobuf/protoc-gen-go/generator/Makefile: -------------------------------------------------------------------------------- 1 | # Go support for Protocol Buffers - Google's data interchange format 2 | # 3 | # Copyright 2010 The Go Authors. All rights reserved. 4 | # https://github.com/golang/protobuf 5 | # 6 | # Redistribution and use in source and binary forms, with or without 7 | # modification, are permitted provided that the following conditions are 8 | # met: 9 | # 10 | # * Redistributions of source code must retain the above copyright 11 | # notice, this list of conditions and the following disclaimer. 12 | # * Redistributions in binary form must reproduce the above 13 | # copyright notice, this list of conditions and the following disclaimer 14 | # in the documentation and/or other materials provided with the 15 | # distribution. 16 | # * Neither the name of Google Inc. nor the names of its 17 | # contributors may be used to endorse or promote products derived from 18 | # this software without specific prior written permission. 19 | # 20 | # THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS 21 | # "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT 22 | # LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR 23 | # A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT 24 | # OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, 25 | # SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT 26 | # LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, 27 | # DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY 28 | # THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT 29 | # (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE 30 | # OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 31 | 32 | include $(GOROOT)/src/Make.inc 33 | 34 | TARG=github.com/golang/protobuf/compiler/generator 35 | GOFILES=\ 36 | generator.go\ 37 | 38 | DEPS=../descriptor ../plugin ../../proto 39 | 40 | include $(GOROOT)/src/Make.pkg 41 | -------------------------------------------------------------------------------- /src/github.com/golang/protobuf/protoc-gen-go/testdata/multi/multi3.proto: -------------------------------------------------------------------------------- 1 | // Go support for Protocol Buffers - Google's data interchange format 2 | // 3 | // Copyright 2010 The Go Authors. All rights reserved. 4 | // https://github.com/golang/protobuf 5 | // 6 | // Redistribution and use in source and binary forms, with or without 7 | // modification, are permitted provided that the following conditions are 8 | // met: 9 | // 10 | // * Redistributions of source code must retain the above copyright 11 | // notice, this list of conditions and the following disclaimer. 12 | // * Redistributions in binary form must reproduce the above 13 | // copyright notice, this list of conditions and the following disclaimer 14 | // in the documentation and/or other materials provided with the 15 | // distribution. 16 | // * Neither the name of Google Inc. nor the names of its 17 | // contributors may be used to endorse or promote products derived from 18 | // this software without specific prior written permission. 19 | // 20 | // THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS 21 | // "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT 22 | // LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR 23 | // A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT 24 | // OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, 25 | // SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT 26 | // LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, 27 | // DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY 28 | // THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT 29 | // (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE 30 | // OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 31 | 32 | syntax = "proto2"; 33 | 34 | package multitest; 35 | 36 | message Multi3 { 37 | enum HatType { 38 | FEDORA = 1; 39 | FEZ = 2; 40 | }; 41 | optional HatType hat_type = 1; 42 | } 43 | 44 | -------------------------------------------------------------------------------- /src/github.com/lib/pq/buf.go: -------------------------------------------------------------------------------- 1 | package pq 2 | 3 | import ( 4 | "bytes" 5 | "encoding/binary" 6 | 7 | "github.com/lib/pq/oid" 8 | ) 9 | 10 | type readBuf []byte 11 | 12 | func (b *readBuf) int32() (n int) { 13 | n = int(int32(binary.BigEndian.Uint32(*b))) 14 | *b = (*b)[4:] 15 | return 16 | } 17 | 18 | func (b *readBuf) oid() (n oid.Oid) { 19 | n = oid.Oid(binary.BigEndian.Uint32(*b)) 20 | *b = (*b)[4:] 21 | return 22 | } 23 | 24 | // N.B: this is actually an unsigned 16-bit integer, unlike int32 25 | func (b *readBuf) int16() (n int) { 26 | n = int(binary.BigEndian.Uint16(*b)) 27 | *b = (*b)[2:] 28 | return 29 | } 30 | 31 | func (b *readBuf) string() string { 32 | i := bytes.IndexByte(*b, 0) 33 | if i < 0 { 34 | errorf("invalid message format; expected string terminator") 35 | } 36 | s := (*b)[:i] 37 | *b = (*b)[i+1:] 38 | return string(s) 39 | } 40 | 41 | func (b *readBuf) next(n int) (v []byte) { 42 | v = (*b)[:n] 43 | *b = (*b)[n:] 44 | return 45 | } 46 | 47 | func (b *readBuf) byte() byte { 48 | return b.next(1)[0] 49 | } 50 | 51 | type writeBuf struct { 52 | buf []byte 53 | pos int 54 | } 55 | 56 | func (b *writeBuf) int32(n int) { 57 | x := make([]byte, 4) 58 | binary.BigEndian.PutUint32(x, uint32(n)) 59 | b.buf = append(b.buf, x...) 60 | } 61 | 62 | func (b *writeBuf) int16(n int) { 63 | x := make([]byte, 2) 64 | binary.BigEndian.PutUint16(x, uint16(n)) 65 | b.buf = append(b.buf, x...) 66 | } 67 | 68 | func (b *writeBuf) string(s string) { 69 | b.buf = append(b.buf, (s + "\000")...) 70 | } 71 | 72 | func (b *writeBuf) byte(c byte) { 73 | b.buf = append(b.buf, c) 74 | } 75 | 76 | func (b *writeBuf) bytes(v []byte) { 77 | b.buf = append(b.buf, v...) 78 | } 79 | 80 | func (b *writeBuf) wrap() []byte { 81 | p := b.buf[b.pos:] 82 | binary.BigEndian.PutUint32(p, uint32(len(p))) 83 | return b.buf 84 | } 85 | 86 | func (b *writeBuf) next(c byte) { 87 | p := b.buf[b.pos:] 88 | binary.BigEndian.PutUint32(p, uint32(len(p))) 89 | b.pos = len(b.buf) + 1 90 | b.buf = append(b.buf, c, 0, 0, 0, 0) 91 | } 92 | -------------------------------------------------------------------------------- /src/github.com/go-xorm/xorm/syslogger.go: -------------------------------------------------------------------------------- 1 | // Copyright 2015 The Xorm Authors. All rights reserved. 2 | // Use of this source code is governed by a BSD-style 3 | // license that can be found in the LICENSE file. 4 | 5 | // +build !windows,!nacl,!plan9 6 | 7 | package xorm 8 | 9 | import ( 10 | "fmt" 11 | "log/syslog" 12 | 13 | "github.com/go-xorm/core" 14 | ) 15 | 16 | var _ core.ILogger = &SyslogLogger{} 17 | 18 | // SyslogLogger will be depricated 19 | type SyslogLogger struct { 20 | w *syslog.Writer 21 | showSQL bool 22 | } 23 | 24 | func NewSyslogLogger(w *syslog.Writer) *SyslogLogger { 25 | return &SyslogLogger{w: w} 26 | } 27 | 28 | func (s *SyslogLogger) Debug(v ...interface{}) { 29 | s.w.Debug(fmt.Sprint(v...)) 30 | } 31 | 32 | func (s *SyslogLogger) Debugf(format string, v ...interface{}) { 33 | s.w.Debug(fmt.Sprintf(format, v...)) 34 | } 35 | 36 | func (s *SyslogLogger) Error(v ...interface{}) { 37 | s.w.Err(fmt.Sprint(v...)) 38 | } 39 | 40 | func (s *SyslogLogger) Errorf(format string, v ...interface{}) { 41 | s.w.Err(fmt.Sprintf(format, v...)) 42 | } 43 | 44 | func (s *SyslogLogger) Info(v ...interface{}) { 45 | s.w.Info(fmt.Sprint(v...)) 46 | } 47 | 48 | func (s *SyslogLogger) Infof(format string, v ...interface{}) { 49 | s.w.Info(fmt.Sprintf(format, v...)) 50 | } 51 | 52 | func (s *SyslogLogger) Warn(v ...interface{}) { 53 | s.w.Warning(fmt.Sprint(v...)) 54 | } 55 | 56 | func (s *SyslogLogger) Warnf(format string, v ...interface{}) { 57 | s.w.Warning(fmt.Sprintf(format, v...)) 58 | } 59 | 60 | func (s *SyslogLogger) Level() core.LogLevel { 61 | return core.LOG_UNKNOWN 62 | } 63 | 64 | // SetLevel always return error, as current log/syslog package doesn't allow to set priority level after syslog.Writer created 65 | func (s *SyslogLogger) SetLevel(l core.LogLevel) {} 66 | 67 | func (s *SyslogLogger) ShowSQL(show ...bool) { 68 | if len(show) == 0 { 69 | s.showSQL = true 70 | return 71 | } 72 | s.showSQL = show[0] 73 | } 74 | 75 | func (s *SyslogLogger) IsShowSQL() bool { 76 | return s.showSQL 77 | } 78 | -------------------------------------------------------------------------------- /src/github.com/golang/protobuf/protoc-gen-go/testdata/imp2.proto: -------------------------------------------------------------------------------- 1 | // Go support for Protocol Buffers - Google's data interchange format 2 | // 3 | // Copyright 2011 The Go Authors. All rights reserved. 4 | // https://github.com/golang/protobuf 5 | // 6 | // Redistribution and use in source and binary forms, with or without 7 | // modification, are permitted provided that the following conditions are 8 | // met: 9 | // 10 | // * Redistributions of source code must retain the above copyright 11 | // notice, this list of conditions and the following disclaimer. 12 | // * Redistributions in binary form must reproduce the above 13 | // copyright notice, this list of conditions and the following disclaimer 14 | // in the documentation and/or other materials provided with the 15 | // distribution. 16 | // * Neither the name of Google Inc. nor the names of its 17 | // contributors may be used to endorse or promote products derived from 18 | // this software without specific prior written permission. 19 | // 20 | // THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS 21 | // "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT 22 | // LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR 23 | // A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT 24 | // OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, 25 | // SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT 26 | // LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, 27 | // DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY 28 | // THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT 29 | // (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE 30 | // OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 31 | 32 | syntax = "proto2"; 33 | 34 | package imp; 35 | 36 | message PubliclyImportedMessage { 37 | optional int64 field = 1; 38 | } 39 | 40 | enum PubliclyImportedEnum { 41 | GLASSES = 1; 42 | HAIR = 2; 43 | } 44 | -------------------------------------------------------------------------------- /src/github.com/labstack/gommon/bytes/bytes_test.go: -------------------------------------------------------------------------------- 1 | package bytes 2 | 3 | import ( 4 | "testing" 5 | 6 | "github.com/stretchr/testify/assert" 7 | ) 8 | 9 | func TestBytesFormat(t *testing.T) { 10 | // B 11 | b := Format(515) 12 | assert.Equal(t, "515B", b) 13 | 14 | // KB 15 | b = Format(31323) 16 | assert.Equal(t, "30.59KB", b) 17 | 18 | // MB 19 | b = Format(13231323) 20 | assert.Equal(t, "12.62MB", b) 21 | 22 | // GB 23 | b = Format(7323232398) 24 | assert.Equal(t, "6.82GB", b) 25 | 26 | // TB 27 | b = Format(7323232398434) 28 | assert.Equal(t, "6.66TB", b) 29 | 30 | // PB 31 | b = Format(9923232398434432) 32 | assert.Equal(t, "8.81PB", b) 33 | } 34 | 35 | func TestBytesParse(t *testing.T) { 36 | // B 37 | b, err := Parse("515B") 38 | if assert.NoError(t, err) { 39 | assert.Equal(t, int64(515), b) 40 | } 41 | 42 | // KB 43 | b, err = Parse("12KB") 44 | if assert.NoError(t, err) { 45 | assert.Equal(t, int64(12288), b) 46 | } 47 | b, err = Parse("12K") 48 | if assert.NoError(t, err) { 49 | assert.Equal(t, int64(12288), b) 50 | } 51 | 52 | // MB 53 | b, err = Parse("2MB") 54 | if assert.NoError(t, err) { 55 | assert.Equal(t, int64(2097152), b) 56 | } 57 | b, err = Parse("2M") 58 | if assert.NoError(t, err) { 59 | assert.Equal(t, int64(2097152), b) 60 | } 61 | 62 | // GB 63 | b, err = Parse("6GB") 64 | if assert.NoError(t, err) { 65 | assert.Equal(t, int64(6442450944), b) 66 | } 67 | b, err = Parse("6G") 68 | if assert.NoError(t, err) { 69 | assert.Equal(t, int64(6442450944), b) 70 | } 71 | 72 | // TB 73 | b, err = Parse("5TB") 74 | if assert.NoError(t, err) { 75 | assert.Equal(t, int64(5497558138880), b) 76 | } 77 | b, err = Parse("5T") 78 | if assert.NoError(t, err) { 79 | assert.Equal(t, int64(5497558138880), b) 80 | } 81 | 82 | // PB 83 | b, err = Parse("9PB") 84 | if assert.NoError(t, err) { 85 | assert.Equal(t, int64(10133099161583616), b) 86 | } 87 | b, err = Parse("9P") 88 | if assert.NoError(t, err) { 89 | assert.Equal(t, int64(10133099161583616), b) 90 | } 91 | } 92 | -------------------------------------------------------------------------------- /src/github.com/gorilla/websocket/examples/echo/client.go: -------------------------------------------------------------------------------- 1 | // Copyright 2015 The Gorilla WebSocket Authors. All rights reserved. 2 | // Use of this source code is governed by a BSD-style 3 | // license that can be found in the LICENSE file. 4 | 5 | // +build ignore 6 | 7 | package main 8 | 9 | import ( 10 | "flag" 11 | "log" 12 | "net/url" 13 | "os" 14 | "os/signal" 15 | "time" 16 | 17 | "github.com/gorilla/websocket" 18 | ) 19 | 20 | var addr = flag.String("addr", "localhost:8080", "http service address") 21 | 22 | func main() { 23 | flag.Parse() 24 | log.SetFlags(0) 25 | 26 | interrupt := make(chan os.Signal, 1) 27 | signal.Notify(interrupt, os.Interrupt) 28 | 29 | u := url.URL{Scheme: "ws", Host: *addr, Path: "/echo"} 30 | log.Printf("connecting to %s", u.String()) 31 | 32 | c, _, err := websocket.DefaultDialer.Dial(u.String(), nil) 33 | if err != nil { 34 | log.Fatal("dial:", err) 35 | } 36 | defer c.Close() 37 | 38 | done := make(chan struct{}) 39 | 40 | go func() { 41 | defer close(done) 42 | for { 43 | _, message, err := c.ReadMessage() 44 | if err != nil { 45 | log.Println("read:", err) 46 | return 47 | } 48 | log.Printf("recv: %s", message) 49 | } 50 | }() 51 | 52 | ticker := time.NewTicker(time.Second) 53 | defer ticker.Stop() 54 | 55 | for { 56 | select { 57 | case <-done: 58 | return 59 | case t := <-ticker.C: 60 | err := c.WriteMessage(websocket.TextMessage, []byte(t.String())) 61 | if err != nil { 62 | log.Println("write:", err) 63 | return 64 | } 65 | case <-interrupt: 66 | log.Println("interrupt") 67 | 68 | // Cleanly close the connection by sending a close message and then 69 | // waiting (with timeout) for the server to close the connection. 70 | err := c.WriteMessage(websocket.CloseMessage, websocket.FormatCloseMessage(websocket.CloseNormalClosure, "")) 71 | if err != nil { 72 | log.Println("write close:", err) 73 | return 74 | } 75 | select { 76 | case <-done: 77 | case <-time.After(time.Second): 78 | } 79 | return 80 | } 81 | } 82 | } 83 | -------------------------------------------------------------------------------- /src/github.com/golang/protobuf/protoc-gen-go/testdata/multi/multi2.proto: -------------------------------------------------------------------------------- 1 | // Go support for Protocol Buffers - Google's data interchange format 2 | // 3 | // Copyright 2010 The Go Authors. All rights reserved. 4 | // https://github.com/golang/protobuf 5 | // 6 | // Redistribution and use in source and binary forms, with or without 7 | // modification, are permitted provided that the following conditions are 8 | // met: 9 | // 10 | // * Redistributions of source code must retain the above copyright 11 | // notice, this list of conditions and the following disclaimer. 12 | // * Redistributions in binary form must reproduce the above 13 | // copyright notice, this list of conditions and the following disclaimer 14 | // in the documentation and/or other materials provided with the 15 | // distribution. 16 | // * Neither the name of Google Inc. nor the names of its 17 | // contributors may be used to endorse or promote products derived from 18 | // this software without specific prior written permission. 19 | // 20 | // THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS 21 | // "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT 22 | // LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR 23 | // A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT 24 | // OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, 25 | // SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT 26 | // LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, 27 | // DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY 28 | // THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT 29 | // (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE 30 | // OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 31 | 32 | syntax = "proto2"; 33 | 34 | package multitest; 35 | 36 | message Multi2 { 37 | required int32 required_value = 1; 38 | 39 | enum Color { 40 | BLUE = 1; 41 | GREEN = 2; 42 | RED = 3; 43 | }; 44 | optional Color color = 2; 45 | } 46 | 47 | -------------------------------------------------------------------------------- /src/github.com/golang/protobuf/protoc-gen-go/testdata/multi/multi1.proto: -------------------------------------------------------------------------------- 1 | // Go support for Protocol Buffers - Google's data interchange format 2 | // 3 | // Copyright 2010 The Go Authors. All rights reserved. 4 | // https://github.com/golang/protobuf 5 | // 6 | // Redistribution and use in source and binary forms, with or without 7 | // modification, are permitted provided that the following conditions are 8 | // met: 9 | // 10 | // * Redistributions of source code must retain the above copyright 11 | // notice, this list of conditions and the following disclaimer. 12 | // * Redistributions in binary form must reproduce the above 13 | // copyright notice, this list of conditions and the following disclaimer 14 | // in the documentation and/or other materials provided with the 15 | // distribution. 16 | // * Neither the name of Google Inc. nor the names of its 17 | // contributors may be used to endorse or promote products derived from 18 | // this software without specific prior written permission. 19 | // 20 | // THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS 21 | // "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT 22 | // LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR 23 | // A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT 24 | // OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, 25 | // SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT 26 | // LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, 27 | // DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY 28 | // THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT 29 | // (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE 30 | // OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 31 | 32 | syntax = "proto2"; 33 | 34 | import "multi/multi2.proto"; 35 | import "multi/multi3.proto"; 36 | 37 | package multitest; 38 | 39 | message Multi1 { 40 | required Multi2 multi2 = 1; 41 | optional Multi2.Color color = 2; 42 | optional Multi3.HatType hat_type = 3; 43 | } 44 | 45 | -------------------------------------------------------------------------------- /src/github.com/golang/protobuf/proto/Makefile: -------------------------------------------------------------------------------- 1 | # Go support for Protocol Buffers - Google's data interchange format 2 | # 3 | # Copyright 2010 The Go Authors. All rights reserved. 4 | # https://github.com/golang/protobuf 5 | # 6 | # Redistribution and use in source and binary forms, with or without 7 | # modification, are permitted provided that the following conditions are 8 | # met: 9 | # 10 | # * Redistributions of source code must retain the above copyright 11 | # notice, this list of conditions and the following disclaimer. 12 | # * Redistributions in binary form must reproduce the above 13 | # copyright notice, this list of conditions and the following disclaimer 14 | # in the documentation and/or other materials provided with the 15 | # distribution. 16 | # * Neither the name of Google Inc. nor the names of its 17 | # contributors may be used to endorse or promote products derived from 18 | # this software without specific prior written permission. 19 | # 20 | # THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS 21 | # "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT 22 | # LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR 23 | # A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT 24 | # OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, 25 | # SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT 26 | # LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, 27 | # DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY 28 | # THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT 29 | # (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE 30 | # OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 31 | 32 | install: 33 | go install 34 | 35 | test: install generate-test-pbs 36 | go test 37 | 38 | 39 | generate-test-pbs: 40 | make install 41 | make -C testdata 42 | protoc --go_out=Mtestdata/test.proto=github.com/golang/protobuf/proto/testdata,Mgoogle/protobuf/any.proto=github.com/golang/protobuf/ptypes/any:. proto3_proto/proto3.proto 43 | make 44 | -------------------------------------------------------------------------------- /src/github.com/golang/protobuf/Make.protobuf: -------------------------------------------------------------------------------- 1 | # Go support for Protocol Buffers - Google's data interchange format 2 | # 3 | # Copyright 2010 The Go Authors. All rights reserved. 4 | # https://github.com/golang/protobuf 5 | # 6 | # Redistribution and use in source and binary forms, with or without 7 | # modification, are permitted provided that the following conditions are 8 | # met: 9 | # 10 | # * Redistributions of source code must retain the above copyright 11 | # notice, this list of conditions and the following disclaimer. 12 | # * Redistributions in binary form must reproduce the above 13 | # copyright notice, this list of conditions and the following disclaimer 14 | # in the documentation and/or other materials provided with the 15 | # distribution. 16 | # * Neither the name of Google Inc. nor the names of its 17 | # contributors may be used to endorse or promote products derived from 18 | # this software without specific prior written permission. 19 | # 20 | # THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS 21 | # "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT 22 | # LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR 23 | # A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT 24 | # OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, 25 | # SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT 26 | # LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, 27 | # DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY 28 | # THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT 29 | # (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE 30 | # OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 31 | 32 | # Includable Makefile to add a rule for generating .pb.go files from .proto files 33 | # (Google protocol buffer descriptions). 34 | # Typical use if myproto.proto is a file in package mypackage in this directory: 35 | # 36 | # include $(GOROOT)/src/pkg/github.com/golang/protobuf/Make.protobuf 37 | 38 | %.pb.go: %.proto 39 | protoc --go_out=. $< 40 | 41 | -------------------------------------------------------------------------------- /src/github.com/dolotech/lib/utils/structandmap.go: -------------------------------------------------------------------------------- 1 | package utils 2 | 3 | import ( 4 | "errors" 5 | "reflect" 6 | ) 7 | 8 | func ToM(value interface{}) map[string]interface{} { 9 | if value == nil{ 10 | return nil 11 | } 12 | v := reflect.ValueOf(value) 13 | if v.Kind() == reflect.Ptr { 14 | v = v.Elem() 15 | value = v.Interface() 16 | v = reflect.ValueOf(value) 17 | } 18 | t := reflect.TypeOf(value) 19 | var data = make(map[string]interface{}) 20 | for i := 0; i < t.NumField(); i++ { 21 | data[t.Field(i).Name] = v.Field(i).Interface() 22 | } 23 | return data 24 | } 25 | 26 | // 27 | func ToMs(values []interface{}) []interface{} { 28 | list:= make([]interface{},len(values)) 29 | l:= len(values) 30 | for i:=0;i