Quick actions

cmd+k|ctrl+k

Navigation

Languages

if, switch, goto / goto statements / Essential Go

Snippet info

Language

Go

Visibility

public

Author

kkowalczyk

Created

2019-03-26T09:40:46Z

Updated

2019-03-26T09:40:46Z

package main

import "fmt"

func printIsOdd(n int) {
	if n%2 == 1 {
		goto isOdd
	}
	fmt.Printf("%d is even\n", n)
	return

isOdd:
	fmt.Printf("%d is odd\n", n)
}

func main() {
	printIsOdd(5)
	printIsOdd(18)
}
INFO