> For the complete documentation index, see [llms.txt](https://mavolin.gitbook.io/corgi/llms.txt). Markdown versions of documentation pages are available by appending `.md` to page URLs; this page is available as [Markdown](https://mavolin.gitbook.io/corgi/learning-corgi/if-and-switch.md).

# If and Switch

Corgi allows you to use both `if`s and `switch`es, without having to use `- code`.

## If

Just write an if as you otherwise would in Go, minus the trailing `{`.

{% tabs %}
{% tab title="Corgi" %}

```pug
import 
  "strings"
  "math/rand"



func F()

- s := "fOo"

if s == "foo"
  p s is 'foo'!
else if strings.EqualFold(s, "foo")
  p s is almost 'foo'!
  
if r := rand.Intn(11); r >= 5
  p I forsee great fortune for you today.

```

{% endtab %}

{% tab title="Go" %}

```go
import (
    "strings"
    "math/rand"
    _io "io"
)

func F(_w _io.Writer) error {

    s := "foo"
    
    if s == "foo" {
        // p s is 'foo'!
    } else if strings.EqualFold(s, "foo") {
        // p s is almost 'foo'!
    }
    if r := rand.Intn(11); r >= 5 {
        // p I forsee great fortune for you today.
    }
}
```

{% endtab %}
{% endtabs %}

## Switch

Similarly, you can write a switch just like in go, just without `{` and `:`.

{% tabs %}
{% tab title="Corgi" %}

```pug
- s := "abc"
p
  switch s
    case "foo", "bar"
      > foo, bar
    case "abc", "def", "jkl"
      > alphabet


```

{% endtab %}

{% tab title="Go" %}

```go
s := "abc"
// <p>
  switch s {
  case "foo", "bar":
    // > foo, bar
  case "abc", "def", "jkl":
    // > alphabet
  }
// </p>
```

{% endtab %}
{% endtabs %}
