First, you'll have to write wrappers around Windows APIs for service
functions (http://msdn.microsoft.com/en-us/library/windows/desktop/ms685942(v=VS.85).aspx).
That's the easy part.
The way windows services work is that a service executable registers a
service callback function that is called by Windows. It cannot be a Go
function because it has to use a specific, WINAPI calling convention
and it's unclear (to me) how that would interact with segmented stacks
in Go. You'll have to write some bridge function. Frankly, you'll
encounter problems that, while probably solvable given enough effort,
might not have been solved before by anyone.
Also be aware that services (written in any language) are severely
restricted in what APIs they can use (no GUI at all, because they run
headless, but also some networking calls are not supported etc.).
Having implemented a windows service once, I don't recommend it at
all.
Also, as far as I know, Go doesn't have cross-platform support for
file changes notifications (inotify/ReadDirectoryChanges()).
-- kjk
On Wed, Oct 5, 2011 at 5:06 PM, Nathan Trimble <nathan....@gmail.com> wrote:
I'm not sure about registering / running as a Windows Service, but I can't imagine it's too hard.
It'll be challenging to implement a Windows Service in Go.
... It cannot be a Go
function because it has to use a specific, WINAPI calling convention
and it's unclear (to me) how that would interact with segmented stacks
in Go. You'll have to write some bridge function.
Having implemented a windows service once, I don't recommend it at
all.
Also, as far as I know, Go doesn't have cross-platform support for
file changes notifications (inotify/ReadDirectoryChanges()).
There's even a library now to do system tray icons on Windows to say "hey user, I'm running. click here to launch your web browser to localhost:8080 and see my pretty web UI."