---
title: "impossible-platform-comparison"
description: "Detect GOOS and GOARCH comparisons excluded by build constraints."
image: "https://strider.gempir.com/og.png"
---

> Documentation Index
> Fetch the complete documentation index at: https://strider.gempir.com/llms.txt
> Use this file to discover all available pages before exploring further.

# impossible-platform-comparison

**Default severity:** `warning`

A file's build constraints limit the operating systems and architectures on
which its code can run. Comparing `runtime.GOOS` or `runtime.GOARCH` with an
excluded known target has a fixed result.

Platform aliases are respected: Android satisfies the `linux` tag, iOS
satisfies `darwin`, and Illumos satisfies `solaris`.

## Bad

```go
//go:build linux

if runtime.GOOS == "windows" { // reported
unreachable()
}
```

## Good

```go
//go:build linux

if runtime.GOOS == "linux" {
	useLinuxPath()
}
```

Source: https://strider.gempir.com/analyzers/impossible-platform-comparison/index.mdx
