if else statement

We'll have a longer discussion about conditinal statements later, but it is quite hard to do anything useful without them so let's have a quick look at an if - else construct. Here we check if the value in the name variable equals to the string Go and depending on the success of this comparision we print something.

package main

import (

func main() {
    var name string
    fmt.Print("What is the name of this langauage? ")

    if name == "Go" {
        fmt.Println("Yes, that's the answer!")
    } else {