Home >Backend Development >Golang >How Can I View My Go Package Documentation Locally in a Browser?

How Can I View My Go Package Documentation Locally in a Browser?

DDD
DDDOriginal
2024-11-23 01:47:14925browse

How Can I View My Go Package Documentation Locally in a Browser?

Viewing Package Documentation Locally in a Browser

You wish to view the package documentation locally as seen on godoc.org. However, using godoc -http=:6060 only shows standard library documentation and not your own package documentation.

In GOPATH Mode:

Run godoc -http. This will serve documentation for all packages in your GOPATH, including your own. Access your package documentation by navigating to http://localhost:6060/pkg/your/package.

In Module-Aware Mode:

GOPATH and modules cannot be used together. To view module package documentation locally:

  1. Place your module sources in a folder like /some/folder/src.
  2. Run godoc -goroot=/some/folder -http=:6060

The above is the detailed content of How Can I View My Go Package Documentation Locally in a Browser?. For more information, please follow other related articles on the PHP Chinese website!

Statement:
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn