Combining Conditional Statements in Golang Last Updated : 08 Jun, 2020 Comments Improve Suggest changes Like Article Like Report Go is a open-source programming language developed at Google by Robert Griesemer, Rob Pike, and Ken Thompson. Go is similar to C syntactically but with CSP style concurrency and many features of other robust programming language. Often refereed to as Golang because of the domain name, this language also has the If/else conditions. Usually the If/else/else if condition when written with one condition makes the program lengthy and increases the complexity thus we can combine two conditions. The conditions can be combined in the following ways :- Using &&(AND) Operator The And (&&) is a way of combining conditional statement has the following syntax: if (condition1) && (condition2) { ...... } Here, condition1 represents the first condition and condition2 represents the second condition. The && statement combines the conditions and gives the results in the following way: If condition1 is True and condition2 is also True, the result is True.If condition1 is True and condition2 is False, the result is False.If condition1 is False and condition2 is True, the result is False.If condition1 is False and condition2 is also False, the result is False. Go package main import "fmt" // AND Condition func main() { time := 18 if time > 10 && time < 18 { fmt.Println("Time for work") } } Using OR operator The OR way of combining conditional statement has the following syntax: if (condition1) || (condition2) { ....... } Here, condition1 represents the first condition and condition2 represents the second condition. The || statement combines the conditions and gives the results in the following way: If condition1 is True and condition2 is also True, the result is True.If condition1 is True and condition2 is False, the result is True.If condition1 is False and condition2 is True, the result is True.If condition1 is False and condition2 is also False, the result is False. Go package main import "fmt" // OR Condition func main() { time := 14 if time > 10 || time < 12 { fmt.Println("Hello geeks") } } Comment More infoAdvertise with us Next Article Combining Conditional Statements in Golang R riasehgal1999 Follow Improve Article Tags : Go Language Similar Reads Loop Control Statements in Go Language Loop control statements in the Go language are used to change the execution of the program. When the execution of the given loop left its scope, then the objects that are created within the scope are also demolished. The Go language supports 3 types of loop control statements: Break Goto Continue Br 3 min read Composition in Golang Composition is a method employed to write re-usable segments of code. It is achieved when objects are made up of other smaller objects with particular behaviors, in other words, Larger objects with a wider functionality are embedded with smaller objects with specific behaviors. The end goal of compo 5 min read strings.Contains Function in Golang with Examples strings.Contains Function in Golang is used to check the given letters present in the given string or not. If the letter is present in the given string, then it will return true, otherwise, return false. Syntax:Â func Contains(str, substr string) bool Here, str is the original string and substr is t 2 min read Comparing Pointers in Golang Pointers in Go programming language or Golang is a variable which is used to store the memory address of another variable. Pointers in Golang are also termed as the special variables. The variables are used to store some data at a particular memory address in the system. The memory address is always 3 min read How to use strconv.FormatBool() Function in Golang? Go language provides inbuilt support to implement conversions to and from string representations of basic data types by strconv Package. This package provides a FormatBool() function which is used to return true or false according to the value of x. To access FormatBool() function you need to import 2 min read Like