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

问题描述:

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.

在Windows上运行本地godoc网络服务器时,如何强制godoc更新我的私有软件包文档? p>

在Windows上运行命令:“ godoc -http:6060”不会在私有软件包中更新新的godoc注释。 当我第一次运行命令时,它得到的注释已经存在,但是自从终止并重新启动命令以来,这些注释尚未更新。 有缓存或我可以清除的东西吗? p>

我在任何地方都找不到关于此的任何信息。 有一个确实很老的github问题(显然已修复),该问题由于年龄而冻结,并处理了当前(和我自己的)go1.8 Windows / amd64安装中godoc中不存在的-sync选项: https://github.com/golang/go/issues/3273 p> \ n

我在Linux上尝试过此操作,当我杀死并重新启动“ godoc -http:6060”命令后,它会立即更新。 p> div>

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.

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!