In Go, you can create an if statement with an else if and else block using the following syntax:
main.go213 chars8 lines
To create an if statement with a condition of type string, you can simply use the == operator to check for equality between the string and the desired value. Here is an example:
main.go264 chars16 lines
In this example, if the value of the name
variable is "Bob", "Hello, Bob!"
will be printed. If the value of the name
variable is "Alice", "Hello, Alice!"
will be printed. Otherwise, "I don't know who you are."
will be printed.
gistlibby LogSnag