# How to distinguish between Linux and Windows in the filebeat code？

**URL:** <https://discuss.elastic.co/t/how-to-distinguish-between-linux-and-windows-in-the-filebeat-code/98807>\
**Category:** Beats\
**Tags:** filebeat\
**Created:** [August 30, 2017, 7:53am UTC](https://discuss.elastic.co/t/how-to-distinguish-between-linux-and-windows-in-the-filebeat-code/98807 "2017-08-30T07:53:49Z")\
**Posts on this page:** 4\
**Page:** 1

<div class="post-metadata">

**Author:** ![caibaoying](https://avatars.discourse-cdn.com/v4/letter/c/dc4da7/32.png) [@caibaoying](https://discuss.elastic.co/u/caibaoying)\
**Post date:** [August 30, 2017, 7:53am UTC](https://discuss.elastic.co/t/how-to-distinguish-between-linux-and-windows-in-the-filebeat-code/98807/1 "2017-08-30T07:53:49Z")

</div>

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？

---

<div class="post-metadata">

**Author:** ![steffens](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/steffens/32/79630_2.png) [@steffens](https://discuss.elastic.co/u/steffens)\
**Post date:** [August 30, 2017, 2:23pm UTC](https://discuss.elastic.co/t/how-to-distinguish-between-linux-and-windows-in-the-filebeat-code/98807/2 "2017-08-30T14:23:11Z")

</div>

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](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.

---

<div class="post-metadata">

**Author:** ![caibaoying](https://avatars.discourse-cdn.com/v4/letter/c/dc4da7/32.png) [@caibaoying](https://discuss.elastic.co/u/caibaoying)\
**Post date:** [August 31, 2017, 1:35am UTC](https://discuss.elastic.co/t/how-to-distinguish-between-linux-and-windows-in-the-filebeat-code/98807/3 "2017-08-31T01:35:32Z")

</div>

Your answer solved my question, thank you.

---

<div class="post-metadata">

**Author:** ![system](https://us1.discourse-cdn.com/elastic/original/3X/1/a/1ac57faf039f6b580b3f104ef42a2a89e41014de.png) [@system](https://discuss.elastic.co/u/system)\
**Post date:** [September 28, 2017, 1:35am UTC](https://discuss.elastic.co/t/how-to-distinguish-between-linux-and-windows-in-the-filebeat-code/98807/4 "2017-09-28T01:35:34Z")

</div>

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