如何强制Windows上的godoc在本地Web服务器中更新私有包的文档?

huangapple go评论107阅读模式
英文:

How to force Windows godoc to update private package documentation on local webserver in golang?

问题

在运行本地的godoc web服务器(Windows系统)时,如何强制godoc更新我的私有包文档?

在Windows上运行命令:"godoc -http :6060"并不会更新私有包中的新godoc注释。当我第一次运行该命令时,它获取了已经存在的注释,但在终止和重新启动命令后没有更新。是否有缓存或其他可以清除的东西?

我在任何地方都找不到相关信息。有一个非常古老的GitHub问题(显然已经修复),由于年代久远而被冻结,该问题涉及到了-sync选项,但在当前(以及我自己的)go1.8 windows/amd64安装的godoc中并不存在该选项:https://github.com/golang/go/issues/3273

我在Linux上尝试过,当我终止并重新启动"godoc -http :6060"命令时,它会立即更新。

英文:

How can I force godoc to update my private package documentation when running a local godoc webserver on Windows?

Running the command: "godoc -http :6060" on Windows doesn't update new godoc comments in private packages. When I first ran the command it got the comments that were already present but hasn't updated since when killing and restarting the command. Is there a cache or something I can clear?

I can't find anything about this anywhere. There's this really old github issue (that was apparently fixed) that is frozen due to age and deals with the -sync option that doesn't exist in godoc in the current (and my own) go1.8 windows/amd64 install: <https://github.com/golang/go/issues/3273>

I tried this on Linux and it updates immediately when I kill and restart the "godoc -http :6060" command.

答案1

得分: 0

从技术上讲,这不是一个与Go相关的问题,而是与文件夹内容更改时的命令执行相关的问题。

对于标准的HTTP Go程序(具有路由器并侦听特定端口的程序),有一些解决方案,但对于GoDoc来说并不多。这是因为操作系统依赖模型,操作系统需要有一种方法来检测和侦听目录中的更改。

也许这里的一些内容可以帮助你,但这将需要一些Bash脚本编写,如果你使用的是Windows系统和/或没有Bash,这可能不是一个选项。

对于Go的HTTP项目,有CodeGangsta的Gin包Pilu的Fresh。两者都非常好用!

英文:

Technically this is not a Go related problem, but more related to the execution of a command when the contents of a folder change.

There are some solutions for standard HTTP Go programs -- those who have a router and listen on an specific port -- but nothing too much for GoDoc. This is because of the os-dependant model, where the OS needs to have a way to detect and listen for changes in the directory.

Maybe something from here may help you out, but it will require some bash scripting -- which may not be an option if you're on Windows and/or don't have Bash.

For Go HTTP projects, there's CodeGangsta's Gin package and Pilu's Fresh. Both work great!

答案2

得分: 0

Patrick的回答指引了我正确的方向。解决方法是将整个包文件夹移动到另一个文件夹中,然后再次运行“godoc -http :6060”命令来强制更新。

对于只创建godoc而言,这个方法很有效。但如果不更改导入或将文件夹移回原处,就无法实际构建任何内容。

奇怪的是,在执行此操作并将其移回后,godoc现在能够识别到我的更新内容,而无需移动包文件夹。

英文:

Patrick's answer pointed me in the right direction. The solution was to move the entire package folder into another folder and then run the "godoc -http :6060" command again which forced the update.

For just creating a godoc, this works fine. You just can't actually build anything without changing imports or moving the folder back.

Strangely, after doing this and moving it back, godoc is now recognizing my updates without moving the package folder.

huangapple
  • 本文由 发表于 2017年4月15日 00:00:20
  • 转载请务必保留本文链接:https://go.coder-hub.com/43415100.html
匿名

发表评论

匿名网友

:?: :razz: :sad: :evil: :!: :smile: :oops: :grin: :eek: :shock: :???: :cool: :lol: :mad: :twisted: :roll: :wink: :idea: :arrow: :neutral: :cry: :mrgreen:

确定