- r - 以节省内存的方式增长 data.frame
- ruby-on-rails - ruby/ruby on rails 内存泄漏检测
- android - 无法解析导入android.support.v7.app
- UNIX 域套接字与共享内存(映射文件)
我正在尝试制作文档并提供示例,但我不知道该怎么做,因为 godoc 跳过了我的示例。
当我在浏览器上访问 localhost:8080/pkg/hello_example
时,它会在终端上打印:
2014/07/01 15:54:29 skipping example 'ExampleAuthenticate' because 'Authenticate' is not a known function or type
2014/07/01 15:54:29 skipping example 'ExampleGetAllowAllDriver' because 'GetAllowAllDriver' is not a known function or type
2014/07/01 15:54:29 skipping example 'ExampleGetAndUseAllowAllDriver' because 'GetAndUseAllowAllDriver' is not a known function or type
2014/07/01 15:54:29 skipping example 'ExampleGetAndUseDenyAllDriver' because 'GetAndUseDenyAllDriver' is not a known function or type
2014/07/01 15:54:29 skipping example 'ExampleGetDenyAllDriver' because 'GetDenyAllDriver' is not a known function or type
2014/07/01 15:54:29 skipping example 'ExampleGetRedisDriver' because 'GetRedisDriver' is not a known function or type
2014/07/01 15:54:30 skipping example 'ExampleAuthenticate' because 'Authenticate' is not a known function or type
2014/07/01 15:54:30 skipping example 'ExampleGetAllowAllDriver' because 'GetAllowAllDriver' is not a known function or type
2014/07/01 15:54:30 skipping example 'ExampleGetAndUseAllowAllDriver' because 'GetAndUseAllowAllDriver' is not a known function or type
2014/07/01 15:54:30 skipping example 'ExampleGetAndUseDenyAllDriver' because 'GetAndUseDenyAllDriver' is not a known function or type
2014/07/01 15:54:30 skipping example 'ExampleGetDenyAllDriver' because 'GetDenyAllDriver' is not a known function or type
2014/07/01 15:54:30 skipping example 'ExampleGetRedisDriver' because 'GetRedisDriver' is not a known function or type
^C%
我不明白,所以我不能随意命名例子?这些名称是否必须与我的包或文件的函数名称相匹配?这是在我的测试包中,所以我可能正在尝试在不同的包和文件中测试功能。我该怎么做?
最佳答案
godoc 对名称非常挑剔,您的示例函数名称需要与实际函数名称、类型名称或其他相关联。参见 http://golang.org/pkg/testing/#hdr-Examples供引用。
godoc 示例的示例:https://godoc.org/github.com/creack/multio#example-Multiplexer--ReadWriter , 编码: https://github.com/creack/multio/blob/master/example_test.go
您会注意到,示例名为 ExampleMultiplexer_simple
ExampleMultiplexer_readWriter
。这是因为我想要两个示例,我可以简单地使用 ExampleMultiplexer
。这是有效的,因为我有一个类型称为(确切地说)Multiplexer
。如果你有一个功能,你可以这样做,但名称需要匹配。
当使用后缀时,后缀以小写字母开头非常重要,否则 godoc 将丢弃它。
所以回答你的问题:是的,你可以使用任意名称,但你仍然需要遵循 ExampleTypeName_suffix
的 godoc 样式(后缀首字母小写)
关于go - 为什么godoc不跳过golang中的例子?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/24519347/
谁能给我一个关于如何使用函数 crypt_r() 的例子吗? 在手册页中,不清楚返回的 char * 字符串是指向函数本身内部(在堆中)分配的内存块,还是仍然指向静态内存,如 crypt()? 最佳答
在 Spectre 中paper ,有一个利用越界数组访问的示例(第 1.2 节)。代码是 if (x < array1_size) y = array2[ array1[x] * 256 ];
这是 Grammar: difference between a top down and bottom up? 的后续问题 我从这个问题中了解到: 语法本身不是自上而下或自下而上的,而是解析器 有些
在java的构造函数中声明变量合法吗?示例。 Time(){ long timeMill = System.currentTimeMillis(); int secon
我一直在仔细研究 slick grid 的示例,并且想要 ping SO 社区并查询 Excel 电子表格编辑演示的示例?就存储而言,网格仅存储整数数据,并且网格将托管在 mvc3 razor 页面内
我很难将愚蠢的菜单置于我网站页面的中心。我知道我可以将外部 div 的宽度设置为 px 值,但我怎样才能让它以响应式网站为中心?这是页面: http://103.4.17.225/~america/i
我正在寻找可在 wordpress 上使用的主题。有时,页面会在调整大小的网络浏览器上正确加载,但在移动设备上却不能,即使尺寸相同,它也会加载某种错误(通常是错位)。例如,在此页面中 ( http:/
union { unsigned char raw[8]; struct { uint8_t gz_method; uint8_t flag;
我想使用 matchShapes() 函数在查询图像中查找对象。 假设我有一本书的模型图像,我想提取它的形状,然后尝试在另一幅图像中找到这本书(它的形状)。 我在谷歌上搜索了很多,但找不到任何关于如何
我正在寻找一个使用 inotify 的简单、简洁的示例gem 来检测目录的更改。 它缺少示例。 最佳答案 examples/watcher.rb 中有一个示例.该链接指向 aredridel 的 re
我一直在努力学习编程中的递归是什么,我需要有人来确认我是否已经完全理解它是什么。 我尝试考虑的方式是通过对象之间的碰撞检测。 假设我们有一个函数。当确定发生碰撞时调用该函数,并使用对象列表调用它以确定
我正在尝试学习如何在我正在处理的项目中使用 jBullet,我已经查看了源提供的演示,但我只是无法弄清楚这些演示如何显示对象。谁有好的资源可以指点我或提供一个在屏幕上显示一个或两个对象的基本示例? 在
我想在一个简单的 x,y 图表上绘制线条,以使用 JGraphT 在 JApplet 中显示。我找到的例子不是很有帮助。有人可以给我指出一些简单的 JGraphT 示例吗? 最佳答案 这里有一个例子,
在解决几何问题时,我遇到了一种称为滑动窗口算法的方法。 真的找不到任何关于它的学习 Material /细节。 算法是关于什么的? 最佳答案 我认为它更像是一种技术而不是一种算法。这是一种可用于各种算
我正在学习同步方法,以防止 Java 中的竞争条件和不良行为。我看到了以下示例,并被告知竞争条件非常微妙: public class Messages { private String messa
我有 100 万个 pdf,如何使用 hadoop 转换为文本并将其用于分析。目标是利用 hadoop 的强大功能将 pdf 数据提取为文本。 最佳答案 我已经在 Hadoop 上处理了一个 pdf
按照目前的情况,这个问题不适合我们的问答形式。我们希望答案得到事实、引用或专业知识的支持,但这个问题可能会引发辩论、争论、投票或扩展讨论。如果您觉得这个问题可以改进并可能重新打开,visit the
我读到过,由于堆栈展开,从析构函数中抛出不是一个好主意。我不确定我是否完全理解。所以我尝试了下面的例子 struct foo { ~foo() { throw 1;
任何人都可以告诉我一个简单的(代码)示例来展示 response.encodeURL() 的用法吗?我所有的搜索(包括 google 和 stackoverflow)只提供了 encodeURL()
我受困于 haskell 类型。 {-# LANGUAGE OverloadedStrings #-} module Main ( main ) where import qualified
我是一名优秀的程序员,十分优秀!