简单了解一下GoWorld,做个记录。
- 下载GoWorld引擎源码
GitHub地址
https://github.com/xiaonanln/goworld
保存到本地之后可以随意改个目录名
截屏2020-06-12 下午6.59.19.png- 安装依赖库
因为goworld提供了go.mod,可以使用
go mod tidy
命令来添加依赖
go get -u github.com/xiaonanln/goworld
- 在工程目录下编译安装goworld,或者是编译安装工程目录下的cmd文件夹内容。(goworld程序是cmd目录下的文件编译出来的。)
工程目录
go install
cmd目录
go install ./cmd/...
这里只要能在Gopath下正确生成goworld文件即可。
-
把编译出来的goworld文件移至工程目录的bin目录下(没有就创建一个,哪那么多为什么)
截屏2020-06-12 下午7.07.45.png
-
将bin目录配到环境变量PATH下(否则goworld命令不识别)
截屏2020-06-12 下午7.10.20.png -
使用goworld命令编译、启动。。。。各工程。
如:
SueshingdeMacBook-Pro:PacManNet_Server_World Sueshing$
SueshingdeMacBook-Pro:PacManNet_Server_World Sueshing$ goworld build examples/chatroom_demo
> arguments: build examples/chatroom_demo
> go list -m -json: {Path:github.com/xiaonanln/goworld Main:true Dir:/Users/Sueshing/Workspace/PacManNet_Server_World GoMod:/Users/Sueshing/Workspace/PacManNet_Server_World/go.mod GoVersion:1.13}
> goworld directory found: /Users/Sueshing/Workspace/PacManNet_Server_World
info Using config file: /Users/Sueshing/Workspace/PacManNet_Server_World/goworld.ini {"ts": "2020-06-12T18:50:39.725+0800"}
info >>> config <<< debug = true {"ts": "2020-06-12T18:50:39.726+0800"}
info >>> config <<< desired dispatcher count = 1 {"ts": "2020-06-12T18:50:39.726+0800"}
info >>> config <<< desired game count = 1 {"ts": "2020-06-12T18:50:39.726+0800"}
info >>> config <<< desired gate count = 1 {"ts": "2020-06-12T18:50:39.726+0800"}
info >>> config <<< storage type = mongodb {"ts": "2020-06-12T18:50:39.726+0800"}
info >>> config <<< KVDB type = mongodb {"ts": "2020-06-12T18:50:39.726+0800"}
> building server examples/chatroom_demo ...
> server directory is /Users/Sueshing/Workspace/PacManNet_Server_World/examples/chatroom_demo ...
> go build examples/chatroom_demo ...
> go build dispatcher ...
> go build gate ...
SueshingdeMacBook-Pro:PacManNet_Server_World Sueshing$
SueshingdeMacBook-Pro:PacManNet_Server_World Sueshing$
SueshingdeMacBook-Pro:PacManNet_Server_World Sueshing$ goworld start examples/chatroom_demo
> arguments: start examples/chatroom_demo
> go list -m -json: {Path:github.com/xiaonanln/goworld Main:true Dir:/Users/Sueshing/Workspace/PacManNet_Server_World GoMod:/Users/Sueshing/Workspace/PacManNet_Server_World/go.mod GoVersion:1.13}
> goworld directory found: /Users/Sueshing/Workspace/PacManNet_Server_World
info Using config file: /Users/Sueshing/Workspace/PacManNet_Server_World/goworld.ini {"ts": "2020-06-12T18:51:33.508+0800"}
info >>> config <<< debug = true {"ts": "2020-06-12T18:51:33.508+0800"}
info >>> config <<< desired dispatcher count = 1 {"ts": "2020-06-12T18:51:33.508+0800"}
info >>> config <<< desired game count = 1 {"ts": "2020-06-12T18:51:33.508+0800"}
info >>> config <<< desired gate count = 1 {"ts": "2020-06-12T18:51:33.508+0800"}
info >>> config <<< storage type = mongodb {"ts": "2020-06-12T18:51:33.508+0800"}
info >>> config <<< KVDB type = mongodb {"ts": "2020-06-12T18:51:33.508+0800"}
> start dispatchers ...
> dispatcher ids: [1]
> start games ...
> desired games = 1
> start game 1 ...
※注意:如果编译成功,在工程目录或GoPAth下 输入goworld 会有如下显示
SueshingdeMacBook-Pro:PacManNet_Server_World Sueshing$
SueshingdeMacBook-Pro:PacManNet_Server_World Sueshing$ goworld
> arguments:
> go list -m -json: {Path:github.com/xiaonanln/goworld Main:true Dir:/Users/Sueshing/Workspace/PacManNet_Server_World GoMod:/Users/Sueshing/Workspace/PacManNet_Server_World/go.mod GoVersion:1.13}
> goworld directory found: /Users/Sueshing/Workspace/PacManNet_Server_World
info Using config file: /Users/Sueshing/Workspace/PacManNet_Server_World/goworld.ini {"ts": "2020-06-12T19:14:01.041+0800"}
info >>> config <<< debug = true {"ts": "2020-06-12T19:14:01.041+0800"}
info >>> config <<< desired dispatcher count = 1 {"ts": "2020-06-12T19:14:01.041+0800"}
info >>> config <<< desired game count = 1 {"ts": "2020-06-12T19:14:01.041+0800"}
info >>> config <<< desired gate count = 1 {"ts": "2020-06-12T19:14:01.041+0800"}
info >>> config <<< storage type = mongodb {"ts": "2020-06-12T19:14:01.041+0800"}
info >>> config <<< KVDB type = mongodb {"ts": "2020-06-12T19:14:01.041+0800"}
> no command to execute
Usage of goworld:
-d run in daemon mode
goworld <build|start|stop|kill|reload|status> [server-id]
SueshingdeMacBook-Pro:PacManNet_Server_World Sueshing$
网友评论