It seems it is because it is "package main".

See $GOPATH/src/golang.org/x/tools/godoc/static/package.html template.

"IsMain" is set if the package is called "main". Looks like there is no
way to output examples in that case.


Janne Snabb
sn...@epipe.com

On 2017-03-06 19:25, mhhc...@gmail.com wrote:
> 
> thanks for your reply.
> 
> yeah, that s right, ok, but what about TOC#5 ?
> 
> That should work too,
> 
> To achieve this we can use a "whole file example."
> A whole file example is a file that ends in |_test.go        |✓
> contains exactly one example
> function,                                         ✓
> no test or benchmark
> functions,                                                     ✓
> and at least one other package-level declaration.                          ✓
> When displaying such examples godoc will show the entire file.
> 
> : x
> 
> https://github.com/mh-cbon/emd/blob/master/main_test.go
> 
> 
> On Monday, March 6, 2017 at 5:42:32 PM UTC+1, Janne Snabb wrote:
> 
>     Your example function is named ExampleMain(). This means that it is
>     supposed to document function Main() or type Main.
> 
>     However, there is no function Main() or type Main in the package. Thus
>     the example is not visible in the documentation because there is
>     nothing
>     for it to attach to.
> 
>     See for example the following about the naming rules:
> 
>     https://blog.golang.org/examples#TOC_4
>     <https://blog.golang.org/examples#TOC_4>.
> 
> 
>     Janne Snabb
>     sn...@epipe.com <javascript:>
> 
>     On 2017-03-06 17:35, mhh...@gmail.com <javascript:> wrote:
>     > Hi,
>     >
>     > in my package here, what did i do wrong so the ExampleMain won t
>     show up ?
>     >
>     > https://github.com/mh-cbon/emd
>     >
>     > https://godoc.org/github.com/mh-cbon/emd
>     <https://godoc.org/github.com/mh-cbon/emd>
>     >
>     > Im expecting to see
>     > https://github.com/mh-cbon/emd/blob/master/main_test.go#L13
>     <https://github.com/mh-cbon/emd/blob/master/main_test.go#L13>
>     >
>     > Note, go test works fine.
>     >
>     > thanks!
>     >
>     > --
>     > You received this message because you are subscribed to the Google
>     > Groups "golang-nuts" group.
>     > To unsubscribe from this group and stop receiving emails from it,
>     send
>     > an email to golang-nuts...@googlegroups.com <javascript:>
>     > <mailto:golang-nuts+unsubscr...@googlegroups.com <javascript:>>.
>     > For more options, visit https://groups.google.com/d/optout
>     <https://groups.google.com/d/optout>.
> 
> -- 
> You received this message because you are subscribed to the Google
> Groups "golang-nuts" group.
> To unsubscribe from this group and stop receiving emails from it, send
> an email to golang-nuts+unsubscr...@googlegroups.com
> <mailto:golang-nuts+unsubscr...@googlegroups.com>.
> For more options, visit https://groups.google.com/d/optout.

-- 
You received this message because you are subscribed to the Google Groups 
"golang-nuts" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to golang-nuts+unsubscr...@googlegroups.com.
For more options, visit https://groups.google.com/d/optout.

Reply via email to