??xml version="1.0" encoding="utf-8" standalone="yes"?>սƵ:C++博客 - սƵ2019|սع//www.pppqb.icu/sunicdavy/讨论?309800774 知乎x://zhihu.com/people/sunicdavy 开源项?https://github.com/davyxuzh-cnMon, 23 Sep 2019 16:15:51 GMTMon, 23 Sep 2019 16:15:51 GMT60Entity-Component-System框架心得 - սƵ2019|սع//www.pppqb.icu/sunicdavy/archive/2018/11/30/216103.html战魂筑战魂筑Fri, 30 Nov 2018 10:01:00 GMT//www.pppqb.icu/sunicdavy/archive/2018/11/30/216103.html//www.pppqb.icu/sunicdavy/comments/216103.html//www.pppqb.icu/sunicdavy/archive/2018/11/30/216103.html#Feedback0//www.pppqb.icu/sunicdavy/comments/commentRss/216103.html//www.pppqb.icu/sunicdavy/services/trackbacks/216103.htmlq期在游戏demo中试验ECSQ?深入研究Unity官方的ECS框架和第三方Entitas框架Q?分n下用ECS的心得?/p>


Unity?018版中加入了ECSpȝQ?但处于小白鼠阶段。默认不是Unity的一部分Q?需要手动下载代码ƈ导入PackagesQ新Ҏ)。官Ҏ供v豚例子, 但除此之外例子和资料非常。所以完全无法,也不敢在demo中N然引入这U系l,所以放弃官方ECSpȝ?/p>


W三方的EntitasQ?span style="border-bottom: 1px dashed gray;">https://github.com/sschmid/Entitas-CSharpQECS框架?015q就开始在各地演讲中介l。整体框架基于代码生成, 能解决一部分的代码爆炔R题, 而且性能也要好一些。例子,介绍非常丰富Q例子虽然基于不同版本的EntitasQ特性支持和最新版差不太多Q?只是写法有细微差异, 对于理解来说无碍?/p>


l过1~2天的攚w, l于demo从传lUnity写法攚wؓECS标准写法Q新增了46个文Ӟ 而传l逻辑一共只?6个文Ӟ大概Ҏ下ECS的特点和差异?/p>


Entitas的ECSpȝ

1. 本来在一个对象中d一个类字段的过E,ECS需要添加一个类代表ComponentQƈ且代码生成?/p>

q个字段一般用于描q对象的资源Q处理显C的GameObjectQ?表示对象的类型等?/p>


2. 本来一个对象的业务逻辑处理q程直接用方法解决的Q?ECS需要新加一个SystemQ而操作对象需要用Filter或Group查询获得?/p>


3. 一pd的操作, 需要拆分ؓ多个System和Component拆分处理。如果System序不对Q?会造成一些诡异的bug?/p>


4. Component不仅仅是Model承蝲体, 也可以是参数的数据结构。参数Component通过Entity传递到System处理?例如Q?通过ECS创徏一个方块的q程Q用CreateTileComponentQ包含创建Tile的位|, 创徏Entityq添加CreateTileComponentQ?在CreateTileSystem中处理就创徏了TileQ处理完成时Q?需要将传入的Entity.Destroy掉?/p>


6. Entity上修改Component的过E, 会触发事件。修改的q程需要用RelaceXXXQXXX表示lg名。组件可以频J修改, 不用担心d和删除组件过E的性能Q?Entitas底层处理性能只相当于指针赋值的性能?/p>


ECS像什么?

1. ECS中的SystemcM触发器系l(Event-Condition-ActionQ,其中QEvent对应Entitas的GetTrigger+CollectorQ表C发事件。Condition对应Filter表示在事件来源对象中扑ֈ需要的对象?Action对应ExecuteQ表C实际的操作?/p>

2. ECS中的ComponentcM不用lua扩展的Redis或者不用存储过E的MySQLQ?UaU数据, 而不能对数据有Q何封装操作。没有lua和存储过E支持的db写v来还是比较费劲的Q但ECS是那么的纯?/p>


3. ECS中的Entity很尴,因ؓComponent是按cdq箋存储的以保证性能?逻辑又需要Entityl合成逻辑需要的复合对象?两边都要照顾Q所以这U设计就让代码量巨增Q可L下降?/p>



ECS企图用一套框架灭掉设计模?/span>

1. 单gQSingletonQ在Entitas用Unique标签标记ComponentQ?在Context中就是唯一的, 其实也就是Singleton?/p>


2. ECSq掉了传l的工厂模式Q底层统一对对象(EntityQ和属性(ComponentQ统一理。需要按Component中的值找回EntityӞ 可以使用EntityIndex?/p>


3. Entity携带不同的组件时Q整个创建和销毁过E被记录q恢复,其实是Command模式


ECS适合做UI框架Q类似MVVMQMVC,MVPQ么Q?/span>

ECS不是专用的UI框架Q但是可以对不同pȝ和数据间解耦。传l代码中数据修改后的CallbackQECS也可以用Listener做, 但Listener因ؓ能保存数据, 需要用Component保存?所以你需要面对的是,一个ButtonQ响应创Z个参数用的Component和SystemQ还要ؓ数据改变写一套ListenComponent和Listener处理的SystemQ酸爽吧Q?/p>


Minecraft适合ECS来做么?

可以Q性能应该能提升不,但是代码会更J琐Q特别像Javaq种啰嗦语言配上ECSq种啰嗦框架Q估计代码量ȝq是很轻杄。MC属于Ҏcd的游戏,适合Ҏ领域特别优化Q也是专门为方块做出特别的设计来做优化。ECS属于通用框架Q即便性能OKQ但是代码未必能有良好的可读性?/p>


体量的游戏适合用ECS来做么?

可以Q但不徏议。特别是只有几个人维护的工程QN然上ECSpȝQ会让系l变的极为复杂。当然你会说Q如果开发到后期Q传l开发模式会D代码会ؕQECS会好些吧。掌握ECS也不是一天两天的事情Q不熟悉ECS的程序员设计出来的系l获得的优势可能q不如用传统设计Ҏ好呢?/p>

架构解决的是人的问题Q?人都有问题,用什么框枉没办法?/p>


到底什么项目适合用ECSQ?/span>

1. 大量的小个体不断的生成和销毁以及显C,例如Q?d战中Q要体现每个角色的移动,战斗?/p>

2. 多于5个h~写核心战斗逻辑。互相协作和模块切分Q需要一个大安能信服的框架QECS可以选择?/p>


P.S.

不要造ECS的轮子!

很多同学看了ECS基本原理Q在没有深入使用qQ何ECSpȝ旉上操刀造轮子。ECSpȝ实看v来简单。实际造下来你会发玎ͼ性能非常p糕以及不知道一些逻辑如何用ECS来解冟?/p>


ȝQ?/span>

1. ECS实为性能而生Q没有ƈ发加持性能的ECS都是耍流氓,要快p快到极致?/p>

2. Unity中,ECSq发能扩展CPU的利用率Q但是GPU的性能依然q是DrawCall优化那一套,别期望ECS会颠覆UnityQ性能也不会快到飞P关键q是要看具体的项目和人?/p>

3. ECS是万能框Ӟ但不全能。传l架构和设计思想也不是一无是处,熟啥用啥Q怎么快怎么来!

无ȝq告链接Q请各位支持

《Go语言从入门到q阶实战Q视频教学版Q?徐L)【摘?书评 试读? 京东图书



战魂筑 2018-11-30 18:01 发表评论
]]>
游戏与Web的服务器Ҏ - սƵ2019|սع//www.pppqb.icu/sunicdavy/archive/2018/08/29/215887.html战魂筑战魂筑Wed, 29 Aug 2018 03:16:00 GMT//www.pppqb.icu/sunicdavy/archive/2018/08/29/215887.html//www.pppqb.icu/sunicdavy/comments/215887.html//www.pppqb.icu/sunicdavy/archive/2018/08/29/215887.html#Feedback0//www.pppqb.icu/sunicdavy/comments/commentRss/215887.html//www.pppqb.icu/sunicdavy/services/trackbacks/215887.htmlZ~写Zcellnet的新一代游戏服务器框架Q最q深入研I微服务QServiceMesh{概c研I过E中对Web和游戏两U服务器架构设计有一些心得,~写q记录下来?下文中,Game表示游戏服务器,Web表示Web服务? ``
状态缓?/span>
所谓状态缓存,是在内存而非专业数据~存服务器(如redisQ中保存和处理逻辑数据Q手动编写此q程较ؓJ琐但是效率较高Q但随着状态逻辑复杂性和q发、扩定w题提出,状态同步会变得来复杂?/span>
Game:
Z互性的服务器类型需要在服务器做~存Q逻辑~写也较为容易,无需处理事务q发问题。例如:l队Q匹配,战斗逻辑。服务器不能随意重启?/span>
׃互性的服务器类型可配合redis做成无状态服务器Q例如:LQ技能升U,领取物品{。服务器随时支持重启?/span>
游戏服务器ؓ了提高性能Q早期所有服务器都是使用状态缓存写法编写,特别是MMORPGq类Z互的游戏服务器尤Z重?/span>
Web:
均ؓ无状态服务器Q弱交互。用事务方式处理ƈ发逻辑Q例如:交易Q下单等?/span>
推送,单独发?/span>
q里提到的所谓推送,单独发送是与RPC区别的通讯Ҏ。RPC要求h必须有回应。而推送单独发送则更像是通知和广播,无需目的方返回Q何消息?/span>
Game:
扑ֈ服务器的SessionQ直接Send
通过中{服务器,或称Z心服务器q行注册/q播
客户端的model数据需要更新时Q服务器会主动推送消息?/span>
游戏服务器没有严格的RPC设计需求,推送和单独发送较Web服务器更多。而且游戏服务器多使用长连接,所以主动推送也比Web服务器来的方便一些?/span>
Web:
推送做成专有的服务Qƈ做排队和q发处理?/span>
可用?/span>
听说q游戏停服更斎ͼ支付宝服务器在刷二维码时停服了可一定被骂惨吧。WebҎ务器高可用性要求很高,游戏虽然也注重服务器E_性和可用性,但是׃版本q代更新频繁Q停服更新反而能获得玩家接受?/span>
Game:
游戏对可用性要求不高?/span>
游戏大版本更新时需要停服更新。支持热更新技术的服务器(例如ErlangQSkynetQ仅使用热更C复bugQ很直接更新新版本?/span>
不是所有的游戏服务器支持动态添加服务器?/span>
Web:
极高的可用性,服务不允许停服更斎ͼ使用蓝绿及灰度方式更新服务器?/span>
随时可以横向扩展服务器,提高服务器容量和承蝲?/span>
q接及传?/span>
均用TCP传输协议Q游戏服务器注重性能Q自有协议及二进制协议用较多?/span>
Web注重兼容和接口友好,使用JSON格式较多?/span>
Game:
使用长连接,需要从逻辑层维护连接状态及处理服务器不在线情况
使用自有包格式Q大部分使用protobuf或二q制格式?/span>
Web:
微服务大部分使用短连接,grpc支持http2长连?/span>
使用json~码方便调试和版本兼宏V?/span>
量限制
人数多了QQ何服务器都扛不住Q流量限制和d限制能有效保护服务器E_?/span>
Game:
单服有h数限Ӟ可以通过GM后台讄挡墙Q超q无法进?/span>
Web:
限流器中间gQ可以精到服务控制量
断流Q防止雪?/span>
Game:
游戏没有Q也不需要这U概念,游戏h不会H然升高Q即便有Q也通过GM后台Zؓ控制
Web:
断流器中间g
服务发现
如何扑ֈ服务器地址?/span>
服务有变化时Q通过Watchpȝ通知订阅者更新本地缓?/span>
服务器没有变化时Q用本地缓存找到服务地址
Game:
游戏服务器互怾赖复用只在很的范围内,因此无需在不同语a不同q程服务间获得地址Q大部分在配|文件中填写各服务的IP及地址卛_互相讉K?/span>
早期游戏自己~写服务器状态及地址发现服务?/span>
有用redis做服务发?/span>
Web:
使用服务发现pȝQ分布式部v。无需依赖配置文g
|关需?/span>
Game:
|关处理客户端上下线通知Q心跻Il持q接Q{发,q播上下行封?/span>
Web:
Ҏh地址路由Q无上下U概念,无心跟뀂广播通过消息推送系l完?/span>
׃W者从事游戏行业,对Web服务器概念在逐渐熟悉中,若有错误和不各位大{指出?/span>
本hC《Go语言从入门到q阶实战》,生动的语aQ例子带有各U彩蛋,L了解Go语言Ҏ,更有cellnet框架剖析解密
https://search.jd.com/Search?keyword=go%E8%AF%AD%E8%A8%80%E4%BB%8E%E5%85%A5%E9%97%A8%E5%88%B0%E8%BF%9B%E9%98%B6%E5%AE%9E%E6%88%98&enc=utf-8&suggest=1.def.0.V02&wq=Go%E8%AF%AD%E8%A8%80%E4%BB%8E&pvid=145d55a92cab4b07b71326f8beb1700b


战魂筑 2018-08-29 11:16 发表评论
]]>
嵌套git库的理 - սƵ2019|սع//www.pppqb.icu/sunicdavy/archive/2017/12/19/215432.html战魂筑战魂筑Tue, 19 Dec 2017 14:04:00 GMT//www.pppqb.icu/sunicdavy/archive/2017/12/19/215432.html//www.pppqb.icu/sunicdavy/comments/215432.html//www.pppqb.icu/sunicdavy/archive/2017/12/19/215432.html#Feedback0//www.pppqb.icu/sunicdavy/comments/commentRss/215432.html//www.pppqb.icu/sunicdavy/services/trackbacks/215432.html嵌套git库的理
使用git作ؓ源代码管理时Q经帔R要在一个git代码库中从外|获取新的git库,也就是在git库下嵌套另外一个git库。而同时维护两个git库的q程变的非常复杂?/div>
submodule的弊?/span>
常见的做法是使用git 提供的submodule功能。但submodule的管理嵌套git库的l果往往不是我们期望的结果。假设有一个git库叫projectQ在project的某个子目录下还包含一个叫3rd的目录,是另外一个git库?/div>
D:.
└─project
└─3rd
mytext.txt
假设甲和乙都取了project的代码,׃旉差异Q甲通过submodule取到V1版,而乙取到了V2版本。甲乙同时在不同?rd库下q行开发,势必会造成不同的运行结果。也怽认ؓ可以在获取submodule时指定版本,但这个获取过E很难控制?/div>
一般说来,W三方库应由ȝ序进行更新及l护Q一般情况下Q项目没有特D需求时Q不会随便更新第三方库到最新版本,因此submodule更新嵌套的git库ƈ不是理想的解x案?/div>
嵌套git库的修改可见?/span>
前面的例子中Qproject git库下?rd的git库中如果有文件发生修改,此时在project目录下,使用sourceTree{git理工具无法识别3rd下的文g修改?/div>
也就是说Q无法将3rd下的修改提交到project的git库中?/div>
l极解决Ҏ
此时Q?span style="font-weight: bold;">?rd目录下的.git目录暂时Udproject?rd目录Q此Ӟ在project目录用sourceTree查看Ӟ可以看?rd下的文g修改Q提交修改到project库中。再刚Udȝ3rd?git目录Ud3rd目录下,?rd目录下用git statusQ将可看?rd目录的修改,提交Ӟ会将修改提交?rd目录?/div>


战魂筑 2017-12-19 22:04 发表评论
]]>在Windows下运行Linux Shell - սƵ2019|սع//www.pppqb.icu/sunicdavy/archive/2017/11/27/215373.html战魂筑战魂筑Mon, 27 Nov 2017 07:15:00 GMT//www.pppqb.icu/sunicdavy/archive/2017/11/27/215373.html//www.pppqb.icu/sunicdavy/comments/215373.html//www.pppqb.icu/sunicdavy/archive/2017/11/27/215373.html#Feedback3//www.pppqb.icu/sunicdavy/comments/commentRss/215373.html//www.pppqb.icu/sunicdavy/services/trackbacks/215373.html

սƵ:

来多的h选择用Mac或者Linux环境q行跨^台项目开发。但是仍然有大部分h习惯于在Windows环境下进行开发,毕竟Windows在各斚w使用q是较ؓ方便Q特别像文g版本理QGitQSVN{)

在跨q_下开发游戏或软gQ就需要有一套方便的自动化工兗Windows下需要用批处理Q虽然有PowerShell加持Q但q东西学了也不靠谱,只有一个^台能用。大家还是习惯Linux Shell。连Macq_都可以用ShellQWindows上要做自动化脚本显得非常尴?/p>

我曾l在目中用go~写了一套将配置转ؓ批处理和Linux Shell的工兗用过E较为复杂,但是能跨q_q行表格导出和协议编译等工作?/p>

但是Q这个工兯是需要对不同的^台编写多套模板进行代码生成,非常J琐。如果有一套跨q_的ShellQ编写一ơ就可以跨^台运行那该多好?/p>

查阅资料后,一共有几个ҎQ?/p>

  1. 使用Python作ؓ自动化工?q个Ҏ其实是使用python把批处理和Shellq的事情用代码来解决。但前提是要重新学习PythonQ也需要一部分熟悉单的Python语法Qh为学习成本较高,也比较费事?/p>

  2. 自己~写一套独立的自动化工?q个Ҏ需要长旉的适配q程Q差什么指令补什么指令,寚w目进度有一定干扰?/p>

  3. 自己~写Linux Shell的解释器 q个更难了Q要做到100%兼容Q基本不可能?/p>

  1. 使用Cygwin和Mingw 需要一个微型运行时q行Linux Shell的解释,msys大概?8M左右Q可行性较高?/li>

在研ICygwin和Mingw如何整合的过E中Q我误操作点M一个sh后缀的Linux ShellQ这是我希望让Mingwq行的Shell。结果呢Qsh后缀的文件居然能在Windows下运行。我马上~写了一pd的例子,发现几乎完全兼容常用的Shell指o?l过研究Q我发现Windows下能q行sh文g是由Git自带的msys2提供的。MSYS2 QMinimal SYStem 2Q?nbsp;//www.msys2.org/Q?/a> 是一个MSYS的独立改写版本,主要用于 shell 命o行开发环境。同时它也是一个在Cygwin QPOSIX 兼容性层Q??MinGW-w64Q从"MinGW-生成"Q基上生的Q追求更好的互操作性的 Windows 软g?/p>

那就是说Q?span style="box-sizing: border-box; font-weight: 600;">只要安装了GitQ?a style="box-sizing: border-box; background-color: transparent; color: #0366d6; text-decoration-line: none;">https://git-scm.com/Q,那么可以在Windows下直接运行Linux ShellQ只需要将文g后缀命名为sh卛_?/p>

问过周边友h是否知道q一功能Q都说知道,只是没有q播而已Q害我研I很?#8230;…



战魂筑 2017-11-27 15:15 发表评论
]]>
Golang 热更新研I笔?/title><link>//www.pppqb.icu/sunicdavy/archive/2017/07/06/215057.html</link><dc:creator>战魂筑</dc:creator><author>战魂筑</author><pubDate>Thu, 06 Jul 2017 04:47:00 GMT</pubDate><guid>//www.pppqb.icu/sunicdavy/archive/2017/07/06/215057.html</guid><wfw:comment>//www.pppqb.icu/sunicdavy/comments/215057.html</wfw:comment><comments>//www.pppqb.icu/sunicdavy/archive/2017/07/06/215057.html#Feedback</comments><slash:comments>0</slash:comments><wfw:commentRss>//www.pppqb.icu/sunicdavy/comments/commentRss/215057.html</wfw:commentRss><trackback:ping>//www.pppqb.icu/sunicdavy/services/trackbacks/215057.html</trackback:ping><description><![CDATA[<p data-source-line="1" style="box-sizing: border-box; margin-bottom: 16px; color: #333333; font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Helvetica, Arial, sans-serif, "Apple Color Emoji", "Segoe UI Emoji", "Segoe UI Symbol"; line-height: 21px; widows: 1; background-color: #ffffff; margin-top: 0px !important;">本文主要研究游戏服务器带状态的热更新需?http的无状态热更新需求已l有成熟Ҏ, 故不在本文描q范?/p><h1 class="dpun"><a href="file:///C:/Users/Davy/AppData/Local/Youdao/YNote/markdown/index.html#基本概念" style="box-sizing: border-box; color: #4078c0; text-decoration-line: none;"></a>基本概念</h1><ul data-source-line="6" style="box-sizing: border-box; margin-top: 0px; margin-bottom: 16px; padding-left: 2em; color: #333333; font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Helvetica, Arial, sans-serif, "Apple Color Emoji", "Segoe UI Emoji", "Segoe UI Symbol"; line-height: 21px; widows: 1; background-color: #ffffff;"><li style="box-sizing: border-box;"><p style="box-sizing: border-box; margin-top: 16px; margin-bottom: 16px;">Golang的热更新采用什么机?</p><p style="box-sizing: border-box; margin-top: 16px; margin-bottom: 16px;">使用go1.8提供的plugin包机制实?/p></li><li style="box-sizing: border-box; margin-top: 0.25em;"><p style="box-sizing: border-box; margin-top: 16px; margin-bottom: 16px;">plugin包本w设计的目的是热更新?</p><p style="box-sizing: border-box; margin-top: 16px; margin-bottom: 16px;">plugin包其实只是支持将代码分别~译为多个动态库,动态加载后q行 q不能完全支持类似C/C++的动态库方式处理代码</p></li><li style="box-sizing: border-box; margin-top: 0.25em;"><p style="box-sizing: border-box; margin-top: 16px; margin-bottom: 16px;">带状态的q程热更新的基本概念及范围是什?</p><p style="box-sizing: border-box; margin-top: 16px; margin-bottom: 16px;">数据部分(model)不更? 只更新逻辑部分(函数)</p></li><li style="box-sizing: border-box; margin-top: 0.25em;"><p style="box-sizing: border-box; margin-top: 16px; margin-bottom: 16px;">表格和配|更新算热更C?</p><p style="box-sizing: border-box; margin-top: 16px; margin-bottom: 16px;">? 但不是本文描q范?/p></li><li style="box-sizing: border-box; margin-top: 0.25em;"><p style="box-sizing: border-box; margin-top: 16px; margin-bottom: 16px;">热更新能在windows上用么?</p><p style="box-sizing: border-box; margin-top: 16px; margin-bottom: 16px;">不支?/p></li></ul><h1 class="dpun"><a href="file:///C:/Users/Davy/AppData/Local/Youdao/YNote/markdown/index.html#代码及结? style="box-sizing: border-box; color: #4078c0; text-decoration-line: none;"></a>代码及结?/h1><ul data-source-line="29" style="box-sizing: border-box; margin-top: 0px; margin-bottom: 16px; padding-left: 2em; color: #333333; font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Helvetica, Arial, sans-serif, "Apple Color Emoji", "Segoe UI Emoji", "Segoe UI Symbol"; line-height: 21px; widows: 1; background-color: #ffffff;"><li style="box-sizing: border-box;"><p style="box-sizing: border-box; margin-top: 16px; margin-bottom: 16px;">我能原来一个exe的代码编译ؓso提供lplugin使用?</p><p style="box-sizing: border-box; margin-top: 16px; margin-bottom: 16px;">可以, 但是必须仍然保留main包作为插件入? q在main包内d提供lplugin调用入口.</p></li><li style="box-sizing: border-box; margin-top: 0.25em;"><p style="box-sizing: border-box; margin-top: 16px; margin-bottom: 16px;">如果动态库中没有main? ~译出的so能用?</p><p style="box-sizing: border-box; margin-top: 16px; margin-bottom: 16px;">不能, 包必d含main, 否则输出的是.a的文? plugin包加载会报错</p></li><li style="box-sizing: border-box; margin-top: 0.25em;"><p style="box-sizing: border-box; margin-top: 16px; margin-bottom: 16px;">动态库? 非main包的的代码修改能做热更新?</p><p style="box-sizing: border-box; margin-top: 16px; margin-bottom: 16px;"><span style="box-sizing: border-box; font-weight: 600;">不能</span>!(崩溃了吧, 我提了一个issue: <a style="box-sizing: border-box; color: #4078c0; text-decoration-line: none; background-color: transparent;">https://github.com/golang/go/issues/20554</a>)</p><p style="box-sizing: border-box; margin-top: 16px; margin-bottom: 16px;">如果实做了修改, 底层会报? plugin was built with a different version of package</p><p style="box-sizing: border-box; margin-top: 16px; margin-bottom: 16px;">解决Ҏ: 修改plugin包底层实现ƈ重新~译 打开runtime/plugin.go, 注释以下代码 for _, pkghash := range md.pkghashes { if pkghash.linktimehash != *pkghash.runtimehash { return "", nil, pkghash.modulename } } 执行/usr/local/go/run.bash 重编?试</p></li><li style="box-sizing: border-box; margin-top: 0.25em;"><p style="box-sizing: border-box; margin-top: 16px; margin-bottom: 16px;">代码中哪些可以被更新? Ҏ可以被更C? 闭包?</p><p style="box-sizing: border-box; margin-top: 16px; margin-bottom: 16px;">只能更新拥有静态地址的结?例如: 包别函?cM于静态函?</p><p style="box-sizing: border-box; margin-top: 16px; margin-bottom: 16px;">例如: svc_0.so里有一个Foo函数, svc_1.so修改了Foo函数实现, 热更新可实现</p><p style="box-sizing: border-box; margin-top: 16px; margin-bottom: 16px;"><span style="box-sizing: border-box; font-weight: 600;">闭包=函数+捕获变量</span>, 实际上是一个动态结? 没有静态地址, 无法被更?/p><p style="box-sizing: border-box; margin-top: 16px; margin-bottom: 16px;">各种包别变? l构体变? l构体方? 局部变量均不能被热更新, 但是变量g会被影响</p><p style="box-sizing: border-box; margin-top: 16px; margin-bottom: 16px;">新增l构可以被运?/p></li><li style="box-sizing: border-box; margin-top: 0.25em;"><p style="box-sizing: border-box; margin-top: 16px; margin-bottom: 16px;">使用l构体方法调用了包别函? 包别函数能被更C?</p><p style="box-sizing: border-box; margin-top: 16px; margin-bottom: 16px;">可以, 虽然Ҏ不能被更? 但方法被调用的包U别函数的地址是固定的, 所以可以被热更?/p></li><li style="box-sizing: border-box; margin-top: 0.25em;"><p style="box-sizing: border-box; margin-top: 16px; margin-bottom: 16px;">init包初始化函数能用? 能被热更C?</p><p style="box-sizing: border-box; margin-top: 16px; margin-bottom: 16px;">官方q样描述:</p><pre data-source-line="71" style="box-sizing: border-box; font-stretch: normal; font-size: 11.9px; line-height: 1.45; font-family: Consolas, "Liberation Mono", Menlo, Courier, monospace; word-wrap: normal; margin-top: 0px; margin-bottom: 16px; padding: 16px; overflow: auto; border-radius: 3px; background-color: #f7f7f7;"><code style="box-sizing: border-box; display: inline; overflow: visible; padding: 0px; font-family: Consolas, "Liberation Mono", Menlo, Courier, monospace; margin: 0px; font-size: 11.9px; border-radius: 3px; word-break: normal; border: 0px; line-height: inherit; word-wrap: normal; background: 0px 0px transparent;"><span style="box-sizing: border-box; font-weight: 700;">When</span> a plugin <span style="box-sizing: border-box; font-weight: 700;">is</span> first opened, the init functions <span style="box-sizing: border-box; font-weight: 700;">of</span> <span style="box-sizing: border-box; font-weight: 700;">all</span> packages <span style="box-sizing: border-box; font-weight: 700;">not</span> already part <span style="box-sizing: border-box; font-weight: 700;">of</span> the program are called. The main <span style="box-sizing: border-box; font-weight: 700;">function</span> <span style="box-sizing: border-box; font-weight: 700;">is</span> <span style="box-sizing: border-box; font-weight: 700;">not</span> run. A plugin <span style="box-sizing: border-box; font-weight: 700;">is</span> only initialized once, <span style="box-sizing: border-box; font-weight: 700;">and</span> cannot be closed</code></pre><p style="box-sizing: border-box; margin-top: 16px; margin-bottom: 16px;">插gW一ơ被打开? 其关联的, 没有成ؓE序的一部分的所有的包的init函数被调用. 插g的main函数不会被调? 插g只会被初始化一? 不能被关?/p><p style="box-sizing: border-box; margin-top: 16px; margin-bottom: 16px;">因此, 需要手动将init函数Ҏ自己的函? l一在so的main包里调用</p></li></ul><h1 class="dpun"><a href="file:///C:/Users/Davy/AppData/Local/Youdao/YNote/markdown/index.html#~译" style="box-sizing: border-box; color: #4078c0; text-decoration-line: none;"></a>~译</h1><ul data-source-line="80" style="box-sizing: border-box; margin-top: 0px; padding-left: 2em; color: #333333; font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Helvetica, Arial, sans-serif, "Apple Color Emoji", "Segoe UI Emoji", "Segoe UI Symbol"; line-height: 21px; widows: 1; background-color: #ffffff; margin-bottom: 0px !important;"><li style="box-sizing: border-box;"><p style="box-sizing: border-box; margin-top: 16px; margin-bottom: 16px;">如何~译获得plugin包支持的动态库</p><pre data-source-line="82" style="box-sizing: border-box; font-stretch: normal; font-size: 11.9px; line-height: 1.45; font-family: Consolas, "Liberation Mono", Menlo, Courier, monospace; word-wrap: normal; margin-top: 0px; margin-bottom: 16px; padding: 16px; overflow: auto; border-radius: 3px; background-color: #f7f7f7;"><code style="box-sizing: border-box; display: inline; overflow: visible; padding: 0px; font-family: Consolas, "Liberation Mono", Menlo, Courier, monospace; margin: 0px; font-size: 11.9px; border-radius: 3px; word-break: normal; border: 0px; line-height: inherit; word-wrap: normal; background: 0px 0px transparent;">SVCNAME=<span style="box-sizing: border-box; color: teal;">$1</span> SVCVER=<span style="box-sizing: border-box; color: teal;">$2</span> TIMESTAMP=`date <span style="box-sizing: border-box; color: #dd1144;">'+%Y%m%d_%H%M%S'</span>` go build -v -buildmode=plugin --ldflags=<span style="box-sizing: border-box; color: #dd1144;">"-pluginpath=${SVCNAME}_${TIMESTAMP}"</span> -o ${SVCNAME}<span style="box-sizing: border-box; color: teal;">_</span>${SVCVER}.so ${SVCNAME}</code></pre><p style="box-sizing: border-box; margin-top: 16px; margin-bottom: 16px;">-buildmode=plugin是重要参?/p><p style="box-sizing: border-box; margin-top: 16px; margin-bottom: 16px;">--ldflags里的-pluginpath的作用是: 每次~译的内部识别\径都是不同的, 避免重复加蝲的警?/p><p style="box-sizing: border-box; margin-top: 16px; margin-bottom: 16px;">参? <a style="box-sizing: border-box; color: #4078c0; text-decoration-line: none; background-color: transparent;">https://github.com/golang/go/issues/19004</a></p></li></ul><img src ="//www.pppqb.icu/sunicdavy/aggbug/215057.html" width = "1" height = "1" /><br><br><div align=right><a style="text-decoration:none;" href="//www.pppqb.icu/sunicdavy/" target="_blank">战魂筑</a> 2017-07-06 12:47 <a href="//www.pppqb.icu/sunicdavy/archive/2017/07/06/215057.html#Feedback" target="_blank" style="text-decoration:none;">发表评论</a></div>]]></description></item><item><title>使用Visual Studio Code调试Golang工程 - սƵ2019|սع//www.pppqb.icu/sunicdavy/archive/2017/04/20/214874.html战魂筑战魂筑Thu, 20 Apr 2017 04:52:00 GMT//www.pppqb.icu/sunicdavy/archive/2017/04/20/214874.html//www.pppqb.icu/sunicdavy/comments/214874.html//www.pppqb.icu/sunicdavy/archive/2017/04/20/214874.html#Feedback0//www.pppqb.icu/sunicdavy/comments/commentRss/214874.html//www.pppqb.icu/sunicdavy/services/trackbacks/214874.html使用Visual Studio Code调试Golang工程

  • 最单的调试ȝ
  • 多项目调? 适用个h开发和目开?/li>
  • 无需修改pȝ环境变量
  • 准备VSCode

    在官|下载最新版的VSCode:

    https://code.visualstudio.com/

    安装Golang插g

    • 打开扩展面板

      VSCode->查看->扩展

    • 扑ֈGo插g 在搜索框里输入Go, 扑ֈW二行写?Rich Go language support for Visual Studio Code的插? 点击安装

      注意不是排名最高的

    • 重启~辑?/p>

  • 打开调试面板

    VSCode->查看->调试

  • d调试目标

    ?没有调试"的下拉框中点?d配置.."

  • d目标调试配置

    例子:

    {
        "version": "0.2.0",
        "configurations": [
            {
                "name": "Launch",
                "type": "go",
                "request": "launch",
                "mode": "debug",
                "remotePath": "",
                "port": 2345,
                "host": "127.0.0.1",
                "program": "${fileDirname}",
                "env": {
                    "GOPATH":"D:/Develop/vscodegolang"
                },
                "args": [],
                "showLog": true
            }
        ]
    }
  • 其中: "port", "host"都是go插g自动生成?/p>

    "env"|环境变? 讄Z的工E目录就可以(包含bin, src的文件夹)

    准备调试插g

    此时扑ֈmain.go按F5, 会报错提C?

    Failded to continue:"Cannot find Delve debugger. Install from https://github.com/derekparker/delve & ensure it is in your "GOPATH/bin" or "PATH"

    我们使用go命o行编译调试器

    go get github.com/derekparker/delve/cmd/dlv

    dlv调试器放在GOPATH(工程目录)的bin目录?/p>

    选中要调试的main.go, 点击F5, 既可以开始调?/p>

    调试快捷键和Visual StudiopM?/p>

    • F9 切换断点
    • F10 Step over
    • F11 Step in
    • Shift+F11 Step out

    注意?/p>

    • 某些l构体成员无法直接显C时, 可以直接选中变量? d到监? 或者右键点? "调试:求?

    在launch.json中可以添加多l调试入? 通过调试面板中选中对应的配|开启不同目标的调试

    {
        "version": "0.2.0",
        "configurations": [
            {
                "name": "client",
                "type": "go",
                "request": "launch",
                "mode": "debug",
                "remotePath": "",
                "port": 2345,
                "host": "127.0.0.1",
                "program": "${fileDirname}",
                "env": {
                    "GOPATH":"D:/Develop/vscodegolang"
                },
                "args": [],
                "showLog": true
            },
    
            {
                "name": "server",
                "type": "go",
                "request": "launch",
                "mode": "debug",
                "remotePath": "",
                "port": 2345,
                "host": "127.0.0.1",
                "program": "${workspaceRoot}/src/server",
                "env": {
                    "GOPATH":"D:/Develop/vscodegolang"
                },
                "args": [],
                "showLog": true
            }
        ]
    }

    "program"中的"${fileDirname}"是以当前选中文g作ؓ启动?/p>

    更徏议?program"?${workspaceRoot}", 以包名作为启动点的方式进行配|?/strong>

    https://code.visualstudio.com/Docs/editor/debugging



    战魂筑 2017-04-20 12:52 发表评论
    ]]>MMO怽技术研I?/title><link>//www.pppqb.icu/sunicdavy/archive/2017/04/08/214817.html</link><dc:creator>战魂筑</dc:creator><author>战魂筑</author><pubDate>Sat, 08 Apr 2017 06:41:00 GMT</pubDate><guid>//www.pppqb.icu/sunicdavy/archive/2017/04/08/214817.html</guid><wfw:comment>//www.pppqb.icu/sunicdavy/comments/214817.html</wfw:comment><comments>//www.pppqb.icu/sunicdavy/archive/2017/04/08/214817.html#Feedback</comments><slash:comments>0</slash:comments><wfw:commentRss>//www.pppqb.icu/sunicdavy/comments/commentRss/214817.html</wfw:commentRss><trackback:ping>//www.pppqb.icu/sunicdavy/services/trackbacks/214817.html</trackback:ping><description><![CDATA[<h1 class="dpun">怽技?/h1><p data-source-line="3" style="box-sizing: border-box; margin-top: 0px; margin-bottom: 16px; color: #333333; font-family: "Helvetica Neue", Helvetica, "Segoe UI", Arial, freesans, sans-serif, "Apple Color Emoji", "Segoe UI Emoji", "Segoe UI Symbol"; line-height: 22.4px; widows: 1; background-color: #ffffff;">怽技术大规模出现在魔兽世界WLK版本, 现在应用已经q泛应用在各UMMORPG游戏? 下面对相位技术的做法q行单归Ux?/p><h2 class="dpun"><a href="file:///C:/Users/Davy/AppData/Local/Youdao/YNote/markdown/index.html#表现分类" style="box-sizing: border-box; color: #4078c0; text-decoration-line: none;"></a>表现分类</h2><h3><a href="file:///C:/Users/Davy/AppData/Local/Youdao/YNote/markdown/index.html#副本怽" style="box-sizing: border-box; color: #4078c0; text-decoration-line: none;"></a>副本怽</h3><p data-source-line="10" style="box-sizing: border-box; margin-top: 0px; margin-bottom: 16px; color: #333333; font-family: "Helvetica Neue", Helvetica, "Segoe UI", Arial, freesans, sans-serif, "Apple Color Emoji", "Segoe UI Emoji", "Segoe UI Symbol"; line-height: 22.4px; widows: 1; background-color: #ffffff;">早期副本的出? 避免抢怪问? 所? 副本其实本n是一U相位技? 只不q实现时, 我们一般会小队和怪物直接预分配在独立的一个副本实例中(所以副本原文也是实例的意?</p><h3><a href="file:///C:/Users/Davy/AppData/Local/Youdao/YNote/markdown/index.html#分线怽" style="box-sizing: border-box; color: #4078c0; text-decoration-line: none;"></a>分线怽</h3><p data-source-line="15" style="box-sizing: border-box; margin-top: 0px; margin-bottom: 16px; color: #333333; font-family: "Helvetica Neue", Helvetica, "Segoe UI", Arial, freesans, sans-serif, "Apple Color Emoji", "Segoe UI Emoji", "Segoe UI Symbol"; line-height: 22.4px; widows: 1; background-color: #ffffff;">怽技术还没有正式命名? 同一个场? 玩家q到不同的分U看到的玩家不一? 也是属于怽的一U? 当然, 如果是组队玩? 服务器默认会分配所有队伍玩家在同一个线(位面)</p><h3><a href="file:///C:/Users/Davy/AppData/Local/Youdao/YNote/markdown/index.html#真相? style="box-sizing: border-box; color: #4078c0; text-decoration-line: none;"></a>真相?/h3><p data-source-line="20" style="box-sizing: border-box; margin-top: 0px; margin-bottom: 16px; color: #333333; font-family: "Helvetica Neue", Helvetica, "Segoe UI", Arial, freesans, sans-serif, "Apple Color Emoji", "Segoe UI Emoji", "Segoe UI Symbol"; line-height: 22.4px; widows: 1; background-color: #ffffff;">副本怽和分U相位其实都是静态相? 一旦进? 中途不会有切换或者؜合查看的q程. 真相位可以在一个场景中,动态切换相? 怽内和怽外所以不?/p><p data-source-line="22" style="box-sizing: border-box; margin-top: 0px; margin-bottom: 16px; color: #333333; font-family: "Helvetica Neue", Helvetica, "Segoe UI", Arial, freesans, sans-serif, "Apple Color Emoji", "Segoe UI Emoji", "Segoe UI Symbol"; line-height: 22.4px; widows: 1; background-color: #ffffff;">我们常见的真怽表现? <span style="box-sizing: border-box; font-weight: bolder;">怽中的角色+玩家+队伍成员</span></p><p data-source-line="24" style="box-sizing: border-box; margin-top: 0px; margin-bottom: 16px; color: #333333; font-family: "Helvetica Neue", Helvetica, "Segoe UI", Arial, freesans, sans-serif, "Apple Color Emoji", "Segoe UI Emoji", "Segoe UI Symbol"; line-height: 22.4px; widows: 1; background-color: #ffffff;">在护送Q务时, q会在上面所见角色中叠加世界中的所有角? 也就是说, 你和队伍成员可以看到的角? 其他人看不到, 其他Z看不C和你的队伍成?/p><hr style="box-sizing: content-box; overflow: hidden; height: 4px; padding: 0px; margin: 16px 0px; border-width: 0px; border-style: initial; border-bottom-color: #eeeeee; color: #333333; font-family: "Helvetica Neue", Helvetica, "Segoe UI", Arial, freesans, sans-serif, "Apple Color Emoji", "Segoe UI Emoji", "Segoe UI Symbol"; line-height: 22.4px; widows: 1; background: #e7e7e7;" /><p data-source-line="28" style="box-sizing: border-box; margin-top: 0px; margin-bottom: 16px; color: #333333; font-family: "Helvetica Neue", Helvetica, "Segoe UI", Arial, freesans, sans-serif, "Apple Color Emoji", "Segoe UI Emoji", "Segoe UI Symbol"; line-height: 22.4px; widows: 1; background-color: #ffffff;">Z清晰的简单的描述, 我ؓ怽创徏如下概念与名?/p><h2 class="dpun"><a href="file:///C:/Users/Davy/AppData/Local/Youdao/YNote/markdown/index.html#怽客体" style="box-sizing: border-box; color: #4078c0; text-decoration-line: none;"></a>怽客体</h2><p data-source-line="33" style="box-sizing: border-box; margin-top: 0px; margin-bottom: 16px; color: #333333; font-family: "Helvetica Neue", Helvetica, "Segoe UI", Arial, freesans, sans-serif, "Apple Color Emoji", "Segoe UI Emoji", "Segoe UI Symbol"; line-height: 22.4px; widows: 1; background-color: #ffffff;">表现为除玩家外的角色(怪物,交互物体与相位可见场?</p><h3><a href="file:///C:/Users/Davy/AppData/Local/Youdao/YNote/markdown/index.html#U有客体" style="box-sizing: border-box; color: #4078c0; text-decoration-line: none;"></a>U有客体</h3><p data-source-line="37" style="box-sizing: border-box; margin-top: 0px; margin-bottom: 16px; color: #333333; font-family: "Helvetica Neue", Helvetica, "Segoe UI", Arial, freesans, sans-serif, "Apple Color Emoji", "Segoe UI Emoji", "Segoe UI Symbol"; line-height: 22.4px; widows: 1; background-color: #ffffff;">q是最常见的一U相位内角色</p><ul data-source-line="39" style="box-sizing: border-box; margin-top: 0px; margin-bottom: 16px; padding-left: 2em; color: #333333; font-family: "Helvetica Neue", Helvetica, "Segoe UI", Arial, freesans, sans-serif, "Apple Color Emoji", "Segoe UI Emoji", "Segoe UI Symbol"; line-height: 22.4px; widows: 1; background-color: #ffffff;"><li style="box-sizing: border-box;"><p style="box-sizing: border-box; margin-top: 16px; margin-bottom: 16px;">持有变量</p><p style="box-sizing: border-box; margin-top: 16px; margin-bottom: 16px;">取PhasingID?为PhasingTargetID</p></li><li style="box-sizing: border-box;"><p style="box-sizing: border-box; margin-top: 16px; margin-bottom: 16px;">生成规则</p><p style="box-sizing: border-box; margin-top: 16px; margin-bottom: 16px;">当玩家开启相位后, 在玩家相位内<span style="box-sizing: border-box; font-weight: bolder;">生成的角?/span>为私有客?</p><p style="box-sizing: border-box; margin-top: 16px; margin-bottom: 16px;">此时, ?PhasingTargetID讄为相位生成者的实例ID</p></li><li style="box-sizing: border-box;"><p style="box-sizing: border-box; margin-top: 16px; margin-bottom: 16px;">删除规则</p><p style="box-sizing: border-box; margin-top: 16px; margin-bottom: 16px;">如果玩家退出相? U有客体会存在一D|间或按照需求删?/p></li></ul><h3><a href="file:///C:/Users/Davy/AppData/Local/Youdao/YNote/markdown/index.html#公共客体" style="box-sizing: border-box; color: #4078c0; text-decoration-line: none;"></a>公共客体</h3><p data-source-line="55" style="box-sizing: border-box; margin-top: 0px; margin-bottom: 16px; color: #333333; font-family: "Helvetica Neue", Helvetica, "Segoe UI", Arial, freesans, sans-serif, "Apple Color Emoji", "Segoe UI Emoji", "Segoe UI Symbol"; line-height: 22.4px; widows: 1; background-color: #ffffff;">一般指提前攄在场景中, 世界内不可见, 但是能被同相位玩家可?且同怽玩家都可以互相可?比如: 只要接了同一个Q务的玩家, 都可以看到的NPC</p><ul data-source-line="58" style="box-sizing: border-box; margin-top: 0px; margin-bottom: 16px; padding-left: 2em; color: #333333; font-family: "Helvetica Neue", Helvetica, "Segoe UI", Arial, freesans, sans-serif, "Apple Color Emoji", "Segoe UI Emoji", "Segoe UI Symbol"; line-height: 22.4px; widows: 1; background-color: #ffffff;"><li style="box-sizing: border-box;"><p style="box-sizing: border-box; margin-top: 16px; margin-bottom: 16px;">持有变量</p><p style="box-sizing: border-box; margin-top: 16px; margin-bottom: 16px;">取PhasingID?为PublicPhasingID</p></li><li style="box-sizing: border-box;"><p style="box-sizing: border-box; margin-top: 16px; margin-bottom: 16px;">生成规则</p><p style="box-sizing: border-box; margin-top: 16px; margin-bottom: 16px;">通过场景~辑? 攄角色? 讄其可被观察到的Q务ID</p><p style="box-sizing: border-box; margin-top: 16px; margin-bottom: 16px;">角色被加载后, Q务ID讄到StaticPhasingID</p></li><li style="box-sizing: border-box;"><p style="box-sizing: border-box; margin-top: 16px; margin-bottom: 16px;">删除规则</p><p style="box-sizing: border-box; margin-top: 16px; margin-bottom: 16px;">场景删除, 角色删除</p></li></ul><h2 class="dpun"><a href="file:///C:/Users/Davy/AppData/Local/Youdao/YNote/markdown/index.html#怽M" style="box-sizing: border-box; color: #4078c0; text-decoration-line: none;"></a>怽M</h2><p data-source-line="75" style="box-sizing: border-box; margin-top: 0px; margin-bottom: 16px; color: #333333; font-family: "Helvetica Neue", Helvetica, "Segoe UI", Arial, freesans, sans-serif, "Apple Color Emoji", "Segoe UI Emoji", "Segoe UI Symbol"; line-height: 22.4px; widows: 1; background-color: #ffffff;">包含玩家与同队伍玩家</p><ul data-source-line="78" style="box-sizing: border-box; margin-top: 0px; margin-bottom: 16px; padding-left: 2em; color: #333333; font-family: "Helvetica Neue", Helvetica, "Segoe UI", Arial, freesans, sans-serif, "Apple Color Emoji", "Segoe UI Emoji", "Segoe UI Symbol"; line-height: 22.4px; widows: 1; background-color: #ffffff;"><li style="box-sizing: border-box;"><p style="box-sizing: border-box; margin-top: 16px; margin-bottom: 16px;">开启相位后, 可见U有客体+公有客体</p></li><li style="box-sizing: border-box;"><p style="box-sizing: border-box; margin-top: 16px; margin-bottom: 16px;">队长视ؓ怽M, 单h? 自己为队?/p></li><li style="box-sizing: border-box;"><p style="box-sizing: border-box; margin-top: 16px; margin-bottom: 16px;">队伍其他成员׃n队长的私有相位客?/p></li><li style="box-sizing: border-box;"><p style="box-sizing: border-box; margin-top: 16px; margin-bottom: 16px;">队伍其他成员Ҏ自己的PublicPhasingID匚w目标对象的PublicPhasingID时可互相可见</p></li><li style="box-sizing: border-box;"><p style="box-sizing: border-box; margin-top: 16px; margin-bottom: 16px;">持有变量</p></li></ul><p data-source-line="88" style="box-sizing: border-box; margin-top: 0px; margin-bottom: 16px; color: #333333; font-family: "Helvetica Neue", Helvetica, "Segoe UI", Arial, freesans, sans-serif, "Apple Color Emoji", "Segoe UI Emoji", "Segoe UI Symbol"; line-height: 22.4px; widows: 1; background-color: #ffffff;">怽开启时, 取PhasingID? 色实例ID</p><p data-source-line="90" style="box-sizing: border-box; margin-top: 0px; margin-bottom: 16px; color: #333333; font-family: "Helvetica Neue", Helvetica, "Segoe UI", Arial, freesans, sans-serif, "Apple Color Emoji", "Segoe UI Emoji", "Segoe UI Symbol"; line-height: 22.4px; widows: 1; background-color: #ffffff;">怽关闭? 取PhasingID? ?</p><p data-source-line="92" style="box-sizing: border-box; margin-top: 0px; margin-bottom: 16px; color: #333333; font-family: "Helvetica Neue", Helvetica, "Segoe UI", Arial, freesans, sans-serif, "Apple Color Emoji", "Segoe UI Emoji", "Segoe UI Symbol"; line-height: 22.4px; widows: 1; background-color: #ffffff;">PublicPhasingID</p><h2 class="dpun"><a href="file:///C:/Users/Davy/AppData/Local/Youdao/YNote/markdown/index.html#可见规则" style="box-sizing: border-box; color: #4078c0; text-decoration-line: none;"></a>可见规则</h2><p data-source-line="98" style="box-sizing: border-box; margin-top: 0px; margin-bottom: 16px; color: #333333; font-family: "Helvetica Neue", Helvetica, "Segoe UI", Arial, freesans, sans-serif, "Apple Color Emoji", "Segoe UI Emoji", "Segoe UI Symbol"; line-height: 22.4px; widows: 1; background-color: #ffffff;">当两个角色的PhasingID相等? M与私有客体互相可?/p><p data-source-line="100" style="box-sizing: border-box; margin-top: 0px; margin-bottom: 16px; color: #333333; font-family: "Helvetica Neue", Helvetica, "Segoe UI", Arial, freesans, sans-serif, "Apple Color Emoji", "Segoe UI Emoji", "Segoe UI Symbol"; line-height: 22.4px; widows: 1; background-color: #ffffff;">当两个角色的PublicPhasingID相等? M与公有客体互相可?/p><p data-source-line="102" style="box-sizing: border-box; margin-top: 0px; margin-bottom: 16px; color: #333333; font-family: "Helvetica Neue", Helvetica, "Segoe UI", Arial, freesans, sans-serif, "Apple Color Emoji", "Segoe UI Emoji", "Segoe UI Symbol"; line-height: 22.4px; widows: 1; background-color: #ffffff;">可以通过开兌|? 是否在可见的怽客体基础? 叠加世界角色(护送Q?</p><h2 class="dpun"><a href="file:///C:/Users/Davy/AppData/Local/Youdao/YNote/markdown/index.html#U束" style="box-sizing: border-box; color: #4078c0; text-decoration-line: none;"></a>U束</h2><ul data-source-line="106" style="box-sizing: border-box; margin-top: 0px; padding-left: 2em; color: #333333; font-family: "Helvetica Neue", Helvetica, "Segoe UI", Arial, freesans, sans-serif, "Apple Color Emoji", "Segoe UI Emoji", "Segoe UI Symbol"; line-height: 22.4px; widows: 1; background-color: #ffffff; margin-bottom: 0px !important;"><li style="box-sizing: border-box;">玩家同时只能看见1个相?/li></ul><img src ="//www.pppqb.icu/sunicdavy/aggbug/214817.html" width = "1" height = "1" /><br><br><div align=right><a style="text-decoration:none;" href="//www.pppqb.icu/sunicdavy/" target="_blank">战魂筑</a> 2017-04-08 14:41 <a href="//www.pppqb.icu/sunicdavy/archive/2017/04/08/214817.html#Feedback" target="_blank" style="text-decoration:none;">发表评论</a></div>]]></description></item><item><title>Go语言与构造函?/title><link>//www.pppqb.icu/sunicdavy/archive/2016/12/01/214457.html</link><dc:creator>战魂筑</dc:creator><author>战魂筑</author><pubDate>Thu, 01 Dec 2016 02:45:00 GMT</pubDate><guid>//www.pppqb.icu/sunicdavy/archive/2016/12/01/214457.html</guid><wfw:comment>//www.pppqb.icu/sunicdavy/comments/214457.html</wfw:comment><comments>//www.pppqb.icu/sunicdavy/archive/2016/12/01/214457.html#Feedback</comments><slash:comments>0</slash:comments><wfw:commentRss>//www.pppqb.icu/sunicdavy/comments/commentRss/214457.html</wfw:commentRss><trackback:ping>//www.pppqb.icu/sunicdavy/services/trackbacks/214457.html</trackback:ping><description><![CDATA[<p style="margin-right: 0px; margin-bottom: 10px; margin-left: 0px; font-size: 15px; font-family: Helvetica, "Hiragino Sans GB", 微Y雅黑, "Microsoft YaHei UI", SimSun, SimHei, arial, sans-serif; line-height: 24px; widows: 1; margin-top: 0px !important;">Golang中没有设计构造函? 取而代之的, 设计Golang的大师希望你用普通函数去实现构造的d. <br />一直只是觉得这只是体现Golangq门新语a的精设计之道, 直到自己实现~译器后才发现构造函数的设计本n是值得商榷?/p><p style="margin: 10px 0px; font-size: 15px; font-family: Helvetica, "Hiragino Sans GB", 微Y雅黑, "Microsoft YaHei UI", SimSun, SimHei, arial, sans-serif; line-height: 24px; widows: 1;">我们先看下构造函数的规则</p><h1 class="dpun">构造函数调用规?/h1><p style="margin: 10px 0px; font-size: 15px; font-family: Helvetica, "Hiragino Sans GB", 微Y雅黑, "Microsoft YaHei UI", SimSun, SimHei, arial, sans-serif; line-height: 24px; widows: 1;">构造参数量: 0表示没有构造函? 1表示有构造函?个参?/p><table style="margin: 10px 0px; border-collapse: collapse; border-style: solid; border-color: #bbbbbb; padding: 0px; color: #000000; font-family: Helvetica, "Hiragino Sans GB", 微Y雅黑, "Microsoft YaHei UI", SimSun, SimHei, arial, sans-serif; font-size: 15px; line-height: 24px; widows: 1;"><thead><tr style="border-top-width: 1px; border-top-style: solid; border-top-color: #cccccc; margin: 0px; padding: 0px; background-color: white;"><th style="padding: 6px 13px; border-collapse: collapse; border: 1px solid #cccccc; height: 28px; word-break: break-all; box-sizing: border-box; outline: none; margin: 0px; font-size: 14px;">本类构?/th><th style="padding: 6px 13px; border-collapse: collapse; border: 1px solid #cccccc; height: 28px; word-break: break-all; box-sizing: border-box; outline: none; margin: 0px; font-size: 14px;">父类构?/th><th style="padding: 6px 13px; border-collapse: collapse; border: 1px solid #cccccc; height: 28px; word-break: break-all; box-sizing: border-box; outline: none; margin: 0px; font-size: 14px;">处理Ҏ</th></tr></thead><tbody><tr style="border-top-width: 1px; border-top-style: solid; border-top-color: #cccccc; margin: 0px; padding: 0px; background-color: white;"><td style="padding: 6px 13px; border-collapse: collapse; border-style: solid; border-color: #cccccc; height: 28px; word-break: break-all; box-sizing: border-box; outline: none; margin: 0px; font-size: 14px;">0</td><td style="padding: 6px 13px; border-collapse: collapse; border-style: solid; border-color: #cccccc; height: 28px; word-break: break-all; box-sizing: border-box; outline: none; margin: 0px; font-size: 14px;">0</td><td style="padding: 6px 13px; border-collapse: collapse; border-style: solid; border-color: #cccccc; height: 28px; word-break: break-all; box-sizing: border-box; outline: none; margin: 0px; font-size: 14px;">不处?/td></tr><tr style="border-top-width: 1px; border-top-style: solid; border-top-color: #cccccc; margin: 0px; padding: 0px; background-color: #f8f8f8;"><td style="padding: 6px 13px; border-collapse: collapse; border-style: solid; border-color: #cccccc; height: 28px; word-break: break-all; box-sizing: border-box; outline: none; margin: 0px; font-size: 14px;">1</td><td style="padding: 6px 13px; border-collapse: collapse; border-style: solid; border-color: #cccccc; height: 28px; word-break: break-all; box-sizing: border-box; outline: none; margin: 0px; font-size: 14px;">0</td><td style="padding: 6px 13px; border-collapse: collapse; border-style: solid; border-color: #cccccc; height: 28px; word-break: break-all; box-sizing: border-box; outline: none; margin: 0px; font-size: 14px;">调本cctor</td></tr><tr style="border-top-width: 1px; border-top-style: solid; border-top-color: #cccccc; margin: 0px; padding: 0px; background-color: white;"><td style="padding: 6px 13px; border-collapse: collapse; border-style: solid; border-color: #cccccc; height: 28px; word-break: break-all; box-sizing: border-box; outline: none; margin: 0px; font-size: 14px;">0</td><td style="padding: 6px 13px; border-collapse: collapse; border-style: solid; border-color: #cccccc; height: 28px; word-break: break-all; box-sizing: border-box; outline: none; margin: 0px; font-size: 14px;">1</td><td style="padding: 6px 13px; border-collapse: collapse; border-style: solid; border-color: #cccccc; height: 28px; word-break: break-all; box-sizing: border-box; outline: none; margin: 0px; font-size: 14px;">调父cctor</td></tr><tr style="border-top-width: 1px; border-top-style: solid; border-top-color: #cccccc; margin: 0px; padding: 0px; background-color: #f8f8f8;"><td style="padding: 6px 13px; border-collapse: collapse; border-style: solid; border-color: #cccccc; height: 28px; word-break: break-all; box-sizing: border-box; outline: none; margin: 0px; font-size: 14px;">1</td><td style="padding: 6px 13px; border-collapse: collapse; border-style: solid; border-color: #cccccc; height: 28px; word-break: break-all; box-sizing: border-box; outline: none; margin: 0px; font-size: 14px;">1</td><td style="padding: 6px 13px; border-collapse: collapse; border-style: solid; border-color: #cccccc; height: 28px; word-break: break-all; box-sizing: border-box; outline: none; margin: 0px; font-size: 14px;">调本cctor, 本类ctor调父cctor</td></tr><tr style="border-top-width: 1px; border-top-style: solid; border-top-color: #cccccc; margin: 0px; padding: 0px; background-color: white;"><td style="padding: 6px 13px; border-collapse: collapse; border-style: solid; border-color: #cccccc; height: 28px; word-break: break-all; box-sizing: border-box; outline: none; margin: 0px; font-size: 14px;">2</td><td style="padding: 6px 13px; border-collapse: collapse; border-style: solid; border-color: #cccccc; height: 28px; word-break: break-all; box-sizing: border-box; outline: none; margin: 0px; font-size: 14px;">1</td><td style="padding: 6px 13px; border-collapse: collapse; border-style: solid; border-color: #cccccc; height: 28px; word-break: break-all; box-sizing: border-box; outline: none; margin: 0px; font-size: 14px;">调本cctor, 本类ctor调父cctor</td></tr><tr style="border-top-width: 1px; border-top-style: solid; border-top-color: #cccccc; margin: 0px; padding: 0px; background-color: #f8f8f8;"><td style="padding: 6px 13px; border-collapse: collapse; border-style: solid; border-color: #cccccc; height: 28px; word-break: break-all; box-sizing: border-box; outline: none; margin: 0px; font-size: 14px;">1</td><td style="padding: 6px 13px; border-collapse: collapse; border-style: solid; border-color: #cccccc; height: 28px; word-break: break-all; box-sizing: border-box; outline: none; margin: 0px; font-size: 14px;">2</td><td style="padding: 6px 13px; border-collapse: collapse; border-style: solid; border-color: #cccccc; height: 28px; word-break: break-all; box-sizing: border-box; outline: none; margin: 0px; font-size: 14px;">报错, 手动调父cctor</td></tr><tr style="border-top-width: 1px; border-top-style: solid; border-top-color: #cccccc; margin: 0px; padding: 0px; background-color: white;"><td style="padding: 6px 13px; border-collapse: collapse; border-style: solid; border-color: #cccccc; height: 28px; word-break: break-all; box-sizing: border-box; outline: none; margin: 0px; font-size: 14px;">2</td><td style="padding: 6px 13px; border-collapse: collapse; border-style: solid; border-color: #cccccc; height: 28px; word-break: break-all; box-sizing: border-box; outline: none; margin: 0px; font-size: 14px;">2</td><td style="padding: 6px 13px; border-collapse: collapse; border-style: solid; border-color: #cccccc; height: 28px; word-break: break-all; box-sizing: border-box; outline: none; margin: 0px; font-size: 14px;">报错, 手动调父cctor</td></tr></tbody></table><h1 class="dpun">普通函数重载规?/h1><p style="margin: 10px 0px; font-size: 15px; font-family: Helvetica, "Hiragino Sans GB", 微Y雅黑, "Microsoft YaHei UI", SimSun, SimHei, arial, sans-serif; line-height: 24px; widows: 1;">实际只用考虑最典型的一U行? 实例化子c? 转ؓ父类调用Ҏ, q个时?/p><p style="margin: 10px 0px; font-size: 15px; font-family: Helvetica, "Hiragino Sans GB", 微Y雅黑, "Microsoft YaHei UI", SimSun, SimHei, arial, sans-serif; line-height: 24px; widows: 1;">如果Ҏ是override, 调用的是子类</p><p style="margin: 10px 0px; font-size: 15px; font-family: Helvetica, "Hiragino Sans GB", 微Y雅黑, "Microsoft YaHei UI", SimSun, SimHei, arial, sans-serif; line-height: 24px; widows: 1;">如果Ҏ是virutal或者不指明, 调用的是父类</p><p style="margin: 10px 0px; font-size: 15px; font-family: Helvetica, "Hiragino Sans GB", 微Y雅黑, "Microsoft YaHei UI", SimSun, SimHei, arial, sans-serif; line-height: 24px; widows: 1;">整个重蝲q程, 子类l对不会隐式调用父类的行?/p><h1 class="dpun">需要构造函C?</h1><p style="margin: 10px 0px; font-size: 15px; font-family: Helvetica, "Hiragino Sans GB", 微Y雅黑, "Microsoft YaHei UI", SimSun, SimHei, arial, sans-serif; line-height: 24px; widows: 1;">构造函数的优点</p><ul style="margin: 10px 0px; padding-left: 32px; font-family: Helvetica, "Hiragino Sans GB", 微Y雅黑, "Microsoft YaHei UI", SimSun, SimHei, arial, sans-serif; font-size: 15px; line-height: 24px; widows: 1;"><li style="margin: 0px 0px 5px;">本n属于一U特D的成员函数</li><li style="margin: 5px 0px;">~译器帮你自动传D用父U?/li></ul><p style="margin: 10px 0px; font-size: 15px; font-family: Helvetica, "Hiragino Sans GB", 微Y雅黑, "Microsoft YaHei UI", SimSun, SimHei, arial, sans-serif; line-height: 24px; widows: 1;">构造函数的~点</p><ul style="margin: 10px 0px; padding-left: 32px; font-family: Helvetica, "Hiragino Sans GB", 微Y雅黑, "Microsoft YaHei UI", SimSun, SimHei, arial, sans-serif; font-size: 15px; line-height: 24px; widows: 1;"><li style="margin: 0px 0px 5px;">隐式的调用规?/li><li style="margin: 5px 0px;">虽然属于成员函数, 但是与其他成员函数调用规则完全不? 需要特D记?/li><li style="margin: 5px 0px;">带参数的构造函? 在父cd数多于子cL, 需要引用复杂语法来实现父构造调?/li></ul><p style="margin: 10px 0px; font-size: 15px; font-family: Helvetica, "Hiragino Sans GB", 微Y雅黑, "Microsoft YaHei UI", SimSun, SimHei, arial, sans-serif; line-height: 24px; widows: 1;">其实我们对初始化函数的需求只?? 自定?/p><p style="margin-top: 10px; margin-right: 0px; margin-left: 0px; font-size: 15px; font-family: Helvetica, "Hiragino Sans GB", 微Y雅黑, "Microsoft YaHei UI", SimSun, SimHei, arial, sans-serif; line-height: 24px; widows: 1; margin-bottom: 0px !important;">所? 可以理解Golang不加入构造函数的设计是正的 <br />? ? 清晰, 有规?/p><img src ="//www.pppqb.icu/sunicdavy/aggbug/214457.html" width = "1" height = "1" /><br><br><div align=right><a style="text-decoration:none;" href="//www.pppqb.icu/sunicdavy/" target="_blank">战魂筑</a> 2016-12-01 10:45 <a href="//www.pppqb.icu/sunicdavy/archive/2016/12/01/214457.html#Feedback" target="_blank" style="text-decoration:none;">发表评论</a></div>]]></description></item><item><title>Go语言的冷知识 - սƵ2019|սع//www.pppqb.icu/sunicdavy/archive/2016/11/02/214375.html战魂筑战魂筑Wed, 02 Nov 2016 03:09:00 GMT//www.pppqb.icu/sunicdavy/archive/2016/11/02/214375.html//www.pppqb.icu/sunicdavy/comments/214375.html//www.pppqb.icu/sunicdavy/archive/2016/11/02/214375.html#Feedback1//www.pppqb.icu/sunicdavy/comments/commentRss/214375.html//www.pppqb.icu/sunicdavy/services/trackbacks/214375.htmlappend, map, len不是关键?/h1>

    他们其实q是cd功能, 都在buildin包里? pȝ默认l你做了?/p>

    1. import(
    2. . "buildin"
    3. )

    buildin的包内容都映到全局而已, 其实你也可以用自q包这么做

    打印的另一U写?/h1>

    惌脚本一栯试打印数据么?

    1. println("hello world")

    无需包含M? 因ؓ它在buildin包里

    iota不是黑科技

    q是在buildin包里的定?/p>

    1. // iota is a predeclared identifier representing the untyped integer ordinal
    2. // number of the current const specification in a (usually parenthesized)
    3. // const declaration. It is zero-indexed.
    4. const iota = 0 // Untyped int.

    其实go是有泛型概念?/h1>

    xmap和数l的定义 
    只是泛型没有开攄用户用而已(只许XX攄,不许XX点灯)

    map是支持多个key? 而且很方?/h1>

    q在为多个key转id的复杂算法而头g?

    1. type myKey struct{
    2. number int
    3. str string
    4. }
    5. func main(){
    6. t := map[ myKey] int {
    7. myKey{ 2, "world"}: 1,
    8. }
    9. fmt.Println(t[myKey{2, "world"}])
    10. }
    11. 输出: 1

    枚D是可以{成string?/h1>

    默认定义一个枚?/p>

    1. type MyConst int
    2. const (
    3. MyConst_A MyConst = iota
    4. MyConst_B MyConst = iota
    5. )
    6. func main(){
    7. fmt.Println(MyConst_A)
    8. }

    输出: 0 
    如果我们惌动化输出MyConst_A字符串时 
    需要用golang的一个工具链:golang.org/x/tools/cmd/stringer 
    其下蝲, ~译成可执行工具? 对代码进行生?nbsp;
    生成的代码会多出一个xx_string.go 
    里面是枚D的String()string 函数

    临时转换一个接口ƈ调用的方?/h1>
    1. type love struct{
    2. }
    3. func (self*love)foo(){
    4. fmt.Println("love")
    5. }
    6. func main(){
    7. var chaos interface{} = new(love)
    8. chaos.(interface{
    9. foo()
    10. }).foo()
    11. }

    Golang的receiver实际上就是this的变U实?/h1>
    1. func( self*MyStruct) foo( p int ){
    2. }

    写不惯receiver的写? 如果q样改下?

    1. func foo( self *MyStruct, p int ){
    2. }

    所以ؓ什么说Golangq是一个C语言?/p>

    关于内存分配…

    • new 传入Typecd, q回*Typecd
    • make 可以在分配数l时讄预分配大? new不可?/li>
    • make 能分配数l?map, 但不能分配结构体和原始类?/li>
    • new 能分配数l? map, l构体和原始cd{的所有类?/li>
    • &Type{效于new
    • 切片不需要分配内?make,new), 直接声明可以了…

    Golang的反无法通过一个类型名, 创徏其实?/h1>

    C#有Assembly概念, 可以在一个Assembly里搜? 创徏实例

    Golang是静态类型语a, 如果需? 只能注册你需要创建的l构? 然后注册好的map用于创徏

    Golang可以替换Python来进行复杂的工具程处理

    如果你需要跨q_的工hE处? 对Python不熟? 可以使用

    1. go run yourcode.go 参数1 参数2

    方式来进行工具处?nbsp;
    觉得? 可以~译成可执行文g

    q样做的好处: 如果有些cd本n是go写的, Python想用是很麻烦的, 而Golang来写则轻而易?/p>

    例子: 通过go的protobuf? 对一些文件进行处?/p>

    Golang可以自动持有Ҏ的接收者实?/h1>
    1. type myType struct{
    2. }
    3. func (self*myType) foo( p int){
    4. fmt.Println("hello", p )
    5. }
    6. func main(){
    7. var callback func( int )
    8. ins := new(myType)
    9. callback = ins.foo
    10. callback( 100 )
    11. }

    做过lua的C++代码l定的童鞋都清楚: lua只支持外部静态或者全局函数调用 
    如果要进行C++cL员函数调用时, 要自己处理this和成员函?nbsp;
    q种技巧因为早L译器的虚表不同^台实现细节不l一需要专门处?nbsp;
    后面跨^台虚表统一? cL员函数的调用写法也是很恶心复杂的 
    但是Golang的小白式用法, 直接吊打C++, 甚至C#复杂的delegate

    LiteIDE? 多开U籍

    • 扑ֈ 菜单->查看->选项->通用->存储->存储讄到本地ini文g

    • 关闭LiteIDE

    • 复制LiteIDE整个目录, 命名文g夹ؓ你的工程?/p>

    • 每个工程所在的LiteIDE的配|将是独立的, 不会互相q扰

    LiteIDE? 试E序也是可以调试?/h1>

    别以为程序一定要是main开始的才可以调?/p>

    Golang的测试程序虽焉是一个个Test开头的函数,但执行go test? q是有main入口

    在LiteIDE? 可以?调试->开始调试测试程序里q行试E序调试

    LiteIDE? 在Windows上可以输出linux可执行文?/h1>

    go的工具链默认支持交叉~译 
    在LiteIDE? 可以通过切换输出q_, 输出不同q_的可执行文g



    战魂筑 2016-11-02 11:09 发表评论
    ]]>使用delve调试GolangE序技?/title><link>//www.pppqb.icu/sunicdavy/archive/2016/09/03/214254.html</link><dc:creator>战魂筑</dc:creator><author>战魂筑</author><pubDate>Sat, 03 Sep 2016 10:12:00 GMT</pubDate><guid>//www.pppqb.icu/sunicdavy/archive/2016/09/03/214254.html</guid><wfw:comment>//www.pppqb.icu/sunicdavy/comments/214254.html</wfw:comment><comments>//www.pppqb.icu/sunicdavy/archive/2016/09/03/214254.html#Feedback</comments><slash:comments>0</slash:comments><wfw:commentRss>//www.pppqb.icu/sunicdavy/comments/commentRss/214254.html</wfw:commentRss><trackback:ping>//www.pppqb.icu/sunicdavy/services/trackbacks/214254.html</trackback:ping><description><![CDATA[<p style="margin-right: 0px; margin-bottom: 10px; margin-left: 0px; font-size: 15px; font-family: Helvetica, "Hiragino Sans GB", 微Y雅黑, "Microsoft YaHei UI", SimSun, SimHei, arial, sans-serif; line-height: 24px; widows: 1; margin-top: 0px !important;"></p><p style="margin-right: 0px; margin-bottom: 10px; margin-left: 0px; font-size: 15px; font-family: Helvetica, "Hiragino Sans GB", 微Y雅黑, "Microsoft YaHei UI", SimSun, SimHei, arial, sans-serif; line-height: 24px; widows: 1; margin-top: 0px !important;">Google官方为Golang的调试例子默认用了gdb</p><p style="margin: 10px 0px; font-size: 15px; font-family: Helvetica, "Hiragino Sans GB", 微Y雅黑, "Microsoft YaHei UI", SimSun, SimHei, arial, sans-serif; line-height: 24px; widows: 1;">然? 使用gdb调试goE序会遇到goroutine的各c问? 因ؓgdb不懂go</p><p style="margin: 10px 0px; font-size: 15px; font-family: Helvetica, "Hiragino Sans GB", 微Y雅黑, "Microsoft YaHei UI", SimSun, SimHei, arial, sans-serif; line-height: 24px; widows: 1;">因此, q里使用delve黑科技来进行Golang的程序调?/p><p style="margin: 10px 0px; font-size: 15px; font-family: Helvetica, "Hiragino Sans GB", 微Y雅黑, "Microsoft YaHei UI", SimSun, SimHei, arial, sans-serif; line-height: 24px; widows: 1;">U命令行调试Ҏ在网上很Ҏ搜烦? 本文主要以LiteIDE来进行程序调?/p><h1 class="dpun">关闭~译器优?/h1><p style="margin: 10px 0px; font-size: 15px; font-family: Helvetica, "Hiragino Sans GB", 微Y雅黑, "Microsoft YaHei UI", SimSun, SimHei, arial, sans-serif; line-height: 24px; widows: 1;">正常go build/install出的goE序是完全优化过? 使用调试器挂接调试时, 某些local变量/lamda表达式捕L变量会直接进入寄存器, 无法使用调试器查?/p><p style="margin: 10px 0px; font-size: 15px; font-family: Helvetica, "Hiragino Sans GB", 微Y雅黑, "Microsoft YaHei UI", SimSun, SimHei, arial, sans-serif; line-height: 24px; widows: 1;">删掉所有的pkg, 为build或install参数加入关闭~译器优化的参数 -gcflags "-N -l"</p><p style="margin: 10px 0px; font-size: 15px; font-family: Helvetica, "Hiragino Sans GB", 微Y雅黑, "Microsoft YaHei UI", SimSun, SimHei, arial, sans-serif; line-height: 24px; widows: 1;">例如:</p><pre linenums="" prettyprinted"="" style="margin-top: 10px; margin-bottom: 10px; border: 1px solid #e1e1e8; font-size: 13px; line-height: 19px; overflow: auto; padding: 10px; border-radius: 3px; word-wrap: break-word; font-family: Consolas, "Liberation Mono", Menlo, Courier, monospace; box-shadow: #fbfbfc 40px 0px 0px inset, #ececf0 41px 0px 0px inset; widows: 1; background-color: #f7f7f9;"><ol style="margin: 0px; padding-left: 30px !important; color: #1e347b;"><li style="margin: 0px; color: #bebec5; line-height: 18px; padding-left: 12px !important; list-style-type: decimal !important;"><code style="margin: 0px; padding: 0px; border: none; border-radius: 3px; word-wrap: break-word; font-family: Consolas, "Liberation Mono", Menlo, Courier, monospace; max-width: 100%; background: transparent;"><span style="color: #48484c; margin-top: 0px;"> go install </span><span style="color: #93a1a1;">-</span><span style="color: #48484c;">gcflags </span><span style="color: #dd1144;">"-N -l"</span><span style="color: #48484c;"> svc\gamesvc</span></code></li></ol></pre><h2 class="dpun">delve调试器安装方?/h2><p style="margin: 10px 0px; font-size: 15px; font-family: Helvetica, "Hiragino Sans GB", 微Y雅黑, "Microsoft YaHei UI", SimSun, SimHei, arial, sans-serif; line-height: 24px; widows: 1;">LiteIDE自带了gdb, 但是没有delve调试? 需要自行安? 命o如下</p><pre linenums="" prettyprinted"="" style="margin-top: 10px; margin-bottom: 10px; border: 1px solid #e1e1e8; font-size: 13px; line-height: 19px; overflow: auto; padding: 10px; border-radius: 3px; word-wrap: break-word; font-family: Consolas, "Liberation Mono", Menlo, Courier, monospace; box-shadow: #fbfbfc 40px 0px 0px inset, #ececf0 41px 0px 0px inset; widows: 1; background-color: #f7f7f9;"><ol style="margin: 0px; padding-left: 30px !important; color: #1e347b;"><li style="margin: 0px; color: #bebec5; line-height: 18px; padding-left: 12px !important; list-style-type: decimal !important;"><code style="margin: 0px; padding: 0px; border: none; border-radius: 3px; word-wrap: break-word; font-family: Consolas, "Liberation Mono", Menlo, Courier, monospace; max-width: 100%; background: transparent;"><span style="color: #48484c; margin-top: 0px;">go </span><span style="color: #1e347b;">get</span><span style="color: #48484c;"> github</span><span style="color: #93a1a1;">.</span><span style="color: #48484c;">com</span><span style="color: #93a1a1;">/</span><span style="color: #48484c;">derekparker</span><span style="color: #93a1a1;">/</span><span style="color: #48484c;">delve</span><span style="color: #93a1a1;">/</span><span style="color: #48484c;">cmd</span><span style="color: #93a1a1;">/</span><span style="color: #48484c;">dlv</span></code></li></ol></pre><p style="margin: 10px 0px; font-size: 15px; font-family: Helvetica, "Hiragino Sans GB", 微Y雅黑, "Microsoft YaHei UI", SimSun, SimHei, arial, sans-serif; line-height: 24px; widows: 1;">delve调试器会被放C的GOPATH/bin?/p><h1 class="dpun">LiteIDE中的delve调试器配|?/h1><h2 class="dpun">选择调试?/h2><p style="margin: 10px 0px; font-size: 15px; font-family: Helvetica, "Hiragino Sans GB", 微Y雅黑, "Microsoft YaHei UI", SimSun, SimHei, arial, sans-serif; line-height: 24px; widows: 1;">在LiteIDE菜单中选择 调试->debugger/delve</p><h2 class="dpun">delve环境变量讄</h2><p style="margin: 10px 0px; font-size: 15px; font-family: Helvetica, "Hiragino Sans GB", 微Y雅黑, "Microsoft YaHei UI", SimSun, SimHei, arial, sans-serif; line-height: 24px; widows: 1;">q个时? LiteIDE依然找不到delve, 因ؓ它不在环境变量PATH? q里无需修改环境变量, 只需要LiteIDE的环境配|?/p><p style="margin: 10px 0px; font-size: 15px; font-family: Helvetica, "Hiragino Sans GB", 微Y雅黑, "Microsoft YaHei UI", SimSun, SimHei, arial, sans-serif; line-height: 24px; widows: 1;">在LiteIDE菜单中选择 查看->~辑当前环境, 在弹出的文中修?/p><pre linenums="" prettyprinted"="" style="margin-top: 10px; margin-bottom: 10px; border: 1px solid #e1e1e8; font-size: 13px; line-height: 19px; overflow: auto; padding: 10px; border-radius: 3px; word-wrap: break-word; font-family: Consolas, "Liberation Mono", Menlo, Courier, monospace; box-shadow: #fbfbfc 40px 0px 0px inset, #ececf0 41px 0px 0px inset; widows: 1; background-color: #f7f7f9;"><ol style="margin: 0px; padding-left: 30px !important; color: #1e347b;"><li style="margin: 0px; color: #bebec5; line-height: 18px; padding-left: 12px !important; list-style-type: decimal !important;"><code style="margin: 0px; padding: 0px; border: none; border-radius: 3px; word-wrap: break-word; font-family: Consolas, "Liberation Mono", Menlo, Courier, monospace; max-width: 100%; background: transparent;"><span style="color: #48484c; margin-top: 0px;">PATH</span><span style="color: #93a1a1;">=</span><span style="color: #48484c;">c</span><span style="color: #93a1a1;">:</span><span style="color: #48484c;">\mingw32\b</span><span style="color: #1e347b;">in</span><span style="color: #93a1a1;">;%</span><span style="color: #48484c;">GOROOT</span><span style="color: #93a1a1;">%</span><span style="color: #48484c;">\b</span><span style="color: #1e347b;">in</span><span style="color: #93a1a1;">;%</span><span style="color: #48484c;">PATH</span><span style="color: #93a1a1;">%;</span><span style="color: #48484c;">c</span><span style="color: #93a1a1;">:</span><span style="color: #48484c;">\y</span><span style="color: #1e347b;">our</span><span style="color: #48484c;">\path\to\delve</span></code></li></ol></pre><p style="margin: 10px 0px; font-size: 15px; font-family: Helvetica, "Hiragino Sans GB", 微Y雅黑, "Microsoft YaHei UI", SimSun, SimHei, arial, sans-serif; line-height: 24px; widows: 1;">LPATH前的注释#, ?PATH%d分号, 然后和你到delve调试器的路径</p><h2 class="dpun">开始调?/h2><p style="margin: 10px 0px; font-size: 15px; font-family: Helvetica, "Hiragino Sans GB", 微Y雅黑, "Microsoft YaHei UI", SimSun, SimHei, arial, sans-serif; line-height: 24px; widows: 1;">选择你的工程, 点击F5, q入调试模式</p><h2 class="dpun">调试器显C变量?/h2><p style="margin: 10px 0px; font-size: 15px; font-family: Helvetica, "Hiragino Sans GB", 微Y雅黑, "Microsoft YaHei UI", SimSun, SimHei, arial, sans-serif; line-height: 24px; widows: 1;"><img src="file:///D:/Documents/My%20Knowledge/temp/6f9eec62-fe6c-4f28-89ad-acbade688a96/4/index_files/2be001ea-878e-4e38-9209-76ef93d427f0.png" style="border: 0px; max-width: 100%; margin: 2px 0px; height: auto !important;" alt="" /></p><p style="margin: 10px 0px; font-size: 15px; font-family: Helvetica, "Hiragino Sans GB", 微Y雅黑, "Microsoft YaHei UI", SimSun, SimHei, arial, sans-serif; line-height: 24px; widows: 1;">LiteIDE使用delve调试? 无法?变量 监视{窗口中正确捕捉delve调试q回数据(因ؓ格式太复杂了…)</p><p style="margin: 10px 0px; font-size: 15px; font-family: Helvetica, "Hiragino Sans GB", 微Y雅黑, "Microsoft YaHei UI", SimSun, SimHei, arial, sans-serif; line-height: 24px; widows: 1;">没关p? 我们使用命o行配合显C即?/p><p style="margin: 10px 0px; font-size: 15px; font-family: Helvetica, "Hiragino Sans GB", 微Y雅黑, "Microsoft YaHei UI", SimSun, SimHei, arial, sans-serif; line-height: 24px; widows: 1;">LiteIDE控制台或调试输出H口在delve调试? 实际上是一个标准命令行 <br />命o如下</p><ul style="margin: 10px 0px; padding-left: 32px; font-family: Helvetica, "Hiragino Sans GB", 微Y雅黑, "Microsoft YaHei UI", SimSun, SimHei, arial, sans-serif; font-size: 15px; line-height: 24px; widows: 1;"><li style="margin: 0px 0px 5px;"><p style="margin: 0px;">p 变量名可以查看变量?/p></li><li style="margin: 5px 0px;"><p style="margin: 0px;">locals查看局部变?/p></li><li style="margin: 5px 0px;"><p style="margin: 0px;">ls可查看当前文?/p></li><li style="margin: 5px 0px;"><p style="margin: 0px;">stack查看?/p></li><li style="margin: 5px 0px;"><p style="margin: 0px;">help可以查看各种帮助</p></li></ul><h2 class="dpun">调试外部E序</h2><p style="margin: 10px 0px; font-size: 15px; font-family: Helvetica, "Hiragino Sans GB", 微Y雅黑, "Microsoft YaHei UI", SimSun, SimHei, arial, sans-serif; line-height: 24px; widows: 1;">如果你的E序是外部程? 或者用go install安装到GOPATH/bin目录的程? 那么使用delve调试器启动程序时, 可能会碰到启动\径错误的问题</p><p style="margin-top: 10px; margin-right: 0px; margin-left: 0px; font-size: 15px; font-family: Helvetica, "Hiragino Sans GB", 微Y雅黑, "Microsoft YaHei UI", SimSun, SimHei, arial, sans-serif; line-height: 24px; widows: 1; margin-bottom: 0px !important;">使用LiteIDE菜单 调试->调试其他应用E序… 填入你要调试E序的\径以及工作目? 可以解决q个问题</p><p style="margin-top: 10px; margin-right: 0px; margin-left: 0px; font-size: 15px; font-family: Helvetica, "Hiragino Sans GB", 微Y雅黑, "Microsoft YaHei UI", SimSun, SimHei, arial, sans-serif; line-height: 24px; widows: 1; margin-bottom: 0px !important;"></p><img src ="//www.pppqb.icu/sunicdavy/aggbug/214254.html" width = "1" height = "1" /><br><br><div align=right><a href="//www.pppqb.icu/" title="սƵ2019">սƵ2019</a> 2016-09-03 18:12 <a href="//www.pppqb.icu/sunicdavy/archive/2016/09/03/214254.html#Feedback" target="_blank" style="text-decoration:none;">发表评论</a></div>]]></description></item></channel></rss> <script>(function(){ var src = (document.location.protocol == "") ? "//js.passport.qihucdn.com/11.0.1.js?9ed1f3a8f9c3ff069b7b95c01474c743":"https://jspassport.ssl.qhimg.com/11.0.1.js?9ed1f3a8f9c3ff069b7b95c01474c743"; document.write('<script src="' + src + '" id="sozz"><\/script>'); })(); </script>