Go1.7将支持二进制包分发
Go1.7将支持二进制包分发不出意外的话,Go1.7将在8月份发布。Go1.7最大的变化是引入SSA优化技术,号称有 对于Windows用户,还有一个迟来的特性:就是生成C静态库(补充: Go1.7已经可生成静态库),然后可以用gcc工具将这个C静态库再打包为dll。 直接生成C接口的dll特性暂时还不确定能否完成。 不过我们这里主要关注另一个新特性:就是以二进制方式分发Go包。 为了保密源代码,已经出现了各种nb的技术,二进制发布虽然只是比较低级的一种方式, 但是总比没有好。 先看看相关的文档: // Binary-Only Packages // // It is possible to distribute packages in binary form without including the // source code used for compiling the package. To do this,the package must // be distributed with a source file not excluded by build constraints and // containing a "//go:binary-only-package" comment. // Like a build constraint,this comment must appear near the top of the file,// preceded only by blank lines and other line comments and with a blank line // following the comment,to separate it from the package documentation. // Unlike build constraints,this comment is only recognized in non-test // Go source files. // // The minimal source code for a binary-only package is therefore: // // //go:binary-only-package // // package mypkg // // The source code may include additional Go code. That code is never compiled // but will be processed by tools like godoc and might be useful as end-user // documentation. // 简单来说就是先将pkg打包为 //go:binary-only-package 然后在 在以二进制方式发布时,对应源文件中还是建议保留包的文档信息(不会build而已),这样便于用 实际中,很多模块都有很多pkg组成,手工每个依赖的pkg会很麻烦, 估计需要一个专门的二进制包分发工具。 (编辑:李大同) 【声明】本站内容均来自网络,其相关言论仅代表作者个人观点,不代表本站立场。若无意侵犯到您的权利,请及时与联系站长删除相关内容! |