1

I'm looking into writing a cross-platform (Windows/Debian/Darwin/Red Hat) service and am comparing language options. I really appreciate Go's cross-platform threading abilities and easy cross-compiling, but I want to make sure I'll be able to easily reach any native (eg. Windows Service) APIs when needed.

What sort of things should I be considering to drive my language decision?

ryno2019
  • 313
  • 2
  • 7
  • 2
    Choosing a language is like choosing a car; there are lots of them and every one has advantages and disadvantages. I would, however, encourage you to at least test-drive Go. – thwd Oct 09 '14 at 14:41
  • 1
    Wrong site for this kind of questions, however one of the best things about Go is the fact you can write OS-agnostic code and easily have `xx_windows.go` that will only run on windows and `xx_darwin.go`, etc. – OneOfOne Oct 09 '14 at 14:42

1 Answers1

1

Go has full support for calling into arbitrary Win32 API's via its core syscall package.

While calling out to raw Win32 via syscall is not exactly pretty to write (mostly because you're crossing the managed/unmanaged boundary, and back) and has no support from the compiler (akin to, say, that of Delphi), this works just OK, and generation of wrapper functions for such API calls can be automated—the Go core packages use this facility for themselves, other popular examples include the odbc package.

Note that there already exists winsvc—a library which interfaces Go with the Windows SCM and event log.

Also look at service which provides unified API for turning your program into a daemon/service using platform-native tools (it uses winsvc on Windows, IIRC).

kostix
  • 51,517
  • 14
  • 93
  • 176
  • Just to demonstrate, [this answer](http://stackoverflow.com/a/26124494/720999) contains a link to a small working program calling out into three Win32 API functions using the `syscall` package. – kostix Oct 09 '14 at 15:13