How to distinguish between Linux and Windows in the filebeat code?


(Panda) #1

I read the filebeat source, and read the filebeat have multiple versions, I would like to ask how to distinguish file and how Linux and Windows operating system, how to distinguish between 32-bit system and 64-bit system?


(Steffen Siering) #2

It depends.

On can distinguish OS and architecture by conditional compilation. For some intro have a look at: https://dave.cheney.net/2013/10/12/how-to-use-conditional-compilation-with-the-go-build-tool

A many used packages (from stdlib) have a unified interface and use conditional compilation -> no special handling required in filebeat.

Sometimes it's easier just to dynamically check. One can use runtime.GOOS to check if the binary is running on windows.


(Panda) #3

Your answer solved my question, thank you.


(system) #4

This topic was automatically closed 28 days after the last reply. New replies are no longer allowed.