Corgi allows you to use both ifs and switches, without having to use - code.
If
Just write an if as you otherwise would in Go, minus the trailing {.
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.
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.
}
}
Switch
Similarly, you can write a switch just like in go, just without { and :.
- s := "abc"
p
switch s
case "foo", "bar"
> foo, bar
case "abc", "def", "jkl"
> alphabet
s := "abc"
// <p>
switch s {
case "foo", "bar":
// > foo, bar
case "abc", "def", "jkl":
// > alphabet
}
// </p>