-1

I create simple go with comment in the application to the function and the package I tried godoc -html and my application and the result

<!--
    Copyright 2009 The Go Authors. All rights reserved.
    Use of this source code is governed by a BSD-style
    license that can be found in the LICENSE file.
-->

<!--
        Note: Static (i.e., not template-generated) href and id
        attributes start with "pkg-" to make it impossible for
        them to conflict with generated attributes (some of which
        correspond to Go identifiers).
-->

        <script type='text/javascript'>
        document.ANALYSIS_DATA = ;
        document.CALLGRAPH = ;
        </script>



                <p>
Package main provides logic ...
</p>

why I didn't see my other document ? and why the <p> for the package has spaces

// Package main provides logic.
package main
import (

}

some types.....

func main() {
}

// doLogic .....
// .....
// ....
func (sm *myI) doLogic (s *myStruct) bool {

}
Jonathan Hall
  • 75,165
  • 16
  • 143
  • 189
user1365697
  • 5,819
  • 15
  • 60
  • 96

1 Answers1

2

Unexported identifiers are not documented by default. Set at least ?m=all to see them:

The presentation mode of web pages served by godoc can be controlled with the "m" URL parameter; it accepts a comma-separated list of flag names as value:

all     show documentation for all declarations, not just the exported ones
methods show all embedded methods, not just those of unexported anonymous fields
src     show the original source code rather then the extracted documentation

For instance, https://golang.org/pkg/math/big/?m=all shows the documentation for all (not just the exported) declarations of package big. https://godoc.org/golang.org/x/tools/cmd/godoc

Peter
  • 29,454
  • 5
  • 48
  • 60
  • what should I need to add to the command godoc -html -src c:/Users/go/src/myProject ? – user1365697 Nov 07 '18 at 11:24
  • can I run it with godoc -http=:6060 ? P.S how I can export method ? – user1365697 Nov 07 '18 at 11:24
  • i run this command godoc -http=:6060 -goroot=$GOHOME and then i run http://localhost:6060?m=all then I succeed to get the struct but not the function – user1365697 Nov 07 '18 at 11:29
  • The main package can't be documented by the default godoc. See https://stackoverflow.com/questions/21778556/what-steps-are-needed-to-document-package-main-in-godoc – Peter Nov 07 '18 at 11:57