The 'If' statement is used to check a certain condition within a function.
<p dir="auto">We can create a simple program to see 'if' in action. <p dir="auto"> <br /> <p dir="auto">package main <p dir="auto">import "fmt" <p dir="auto">func main(){ <pre><code>x := 1 for i <= 50{ if i % 5 == 0 {fmt.Println(i)} i++ } <p dir="auto">} <p dir="auto"> <br /> <p dir="auto">This program will print the multiples of 5 upto 50. <p dir="auto"> <p dir="auto">Breakdown Of The Program <p dir="auto"> <ul> <li>We declared the variable 'i' and set its initial value to 1. <li>Then, we created a 'for' loop that will run until the value of i hits 50. <li>After that, we use the if statement to check if 'i' is divisible by 5 or not. If it is divisible by 5, it will be printed only if it is divisible by 5. <p dir="auto"> <br /> <p dir="auto"> <br /> <br /> <p dir="auto"><strong>Previous Posts In The Series <p dir="auto"> <br /> <p dir="auto"><a href="https://steemit.com/programming/@technological/introduction-to-go-programming-language-part-1-learn-go" target="_blank" rel="nofollow noreferrer noopener" title="This link will take you away from hive.blog" class="external_link">Introduction To 'Go' Programming Language(Learn 'Go' - Part 1) <p dir="auto"> <p dir="auto"><a href="https://steemit.com/programming/@technological/25-basic-keywords-of-the-go-programming-language-part-2-learn-go" target="_blank" rel="nofollow noreferrer noopener" title="This link will take you away from hive.blog" class="external_link">25 Basic Keywords Of The Go Programming Language (Learn 'Go' - Part 2) <p dir="auto"> <p dir="auto"><a href="https://steemit.com/programming/@technological/how-to-set-the-go-programming-environment-on-your-system" target="_blank" rel="nofollow noreferrer noopener" title="This link will take you away from hive.blog" class="external_link">How To Set The Go Programming Environment On Your System?(Learn 'Go' - Part 3) <p dir="auto"> <p dir="auto"><a href="https://steemit.com/programming/@technological/create-your-first-program-in-go-language-learn-go-part-4" target="_blank" rel="nofollow noreferrer noopener" title="This link will take you away from hive.blog" class="external_link">Create Your First Program In Go Language (Learn 'Go' - Part 4) <p dir="auto"> <p dir="auto"><a href="https://steemit.com/programming/@technological/strings-in-go-learn-go-part-5" target="_blank" rel="nofollow noreferrer noopener" title="This link will take you away from hive.blog" class="external_link">Strings In 'Go'(Learn 'Go' - Part 5) <p dir="auto"> <p dir="auto"><a href="https://steemit.com/programming/@technological/booleans-in-go-learn-go-part-6" target="_blank" rel="nofollow noreferrer noopener" title="This link will take you away from hive.blog" class="external_link">Booleans In 'Go'(Learn 'Go' - Part 6) <p dir="auto"> <p dir="auto"><a href="https://steemit.com/programming/@technological/numbers-in-go-learn-go-part-7" target="_blank" rel="nofollow noreferrer noopener" title="This link will take you away from hive.blog" class="external_link">Numbers In 'Go'(Learn 'Go' - Part 7) <p dir="auto"> <p dir="auto"><a href="https://steemit.com/programming/@technological/variables-in-go-learn-go-part-8" target="_blank" rel="nofollow noreferrer noopener" title="This link will take you away from hive.blog" class="external_link">Variables In 'Go'(Learn 'Go' - Part 8) <p dir="auto"> <p dir="auto"><a href="https://steemit.com/programming/@technological/constants-in-go-learn-go-part-9" target="_blank" rel="nofollow noreferrer noopener" title="This link will take you away from hive.blog" class="external_link">Constants In 'Go'(Learn 'Go' - Part9) <p dir="auto"> <p dir="auto"><a href="https://steemit.com/programming/@technological/multiple-variables-in-go-learn-go-part10" target="_blank" rel="nofollow noreferrer noopener" title="This link will take you away from hive.blog" class="external_link">Multiple Variables In 'Go'(Learn 'Go' - Part10) <p dir="auto"> <p dir="auto"><a href="https://steemit.com/programming/@technological/for-loop-in-go-learn-go-part-11" target="_blank" rel="nofollow noreferrer noopener" title="This link will take you away from hive.blog" class="external_link">For Loop In 'Go'(Learn 'Go' - Part11) <hr /> <p dir="auto"> <br /> <p dir="auto"><strong>Upcoming Posts <p dir="auto"> <p dir="auto"><strong>Switch In 'Go'(Learn 'Go' - Part 13)
Congratulations @technological! You have completed some achievement on Steemit and have been rewarded with new badge(s) :
<p dir="auto"><a href="http://steemitboard.com/@technological" target="_blank" rel="noreferrer noopener" title="This link will take you away from hive.blog" class="external_link"><img src="https://images.hive.blog/768x0/https://steemitimages.com/70x80/http://steemitboard.com/notifications/posts.png" srcset="https://images.hive.blog/768x0/https://steemitimages.com/70x80/http://steemitboard.com/notifications/posts.png 1x, https://images.hive.blog/1536x0/https://steemitimages.com/70x80/http://steemitboard.com/notifications/posts.png 2x" /> Award for the number of posts published <p dir="auto">Click on any badge to view your Board of Honor. <p dir="auto">To support your work, I also upvoted your post!<br /> For more information about SteemitBoard, click <a href="https://steemit.com/@steemitboard" target="_blank" rel="noreferrer noopener" title="This link will take you away from hive.blog" class="external_link">here <p dir="auto">If you no longer want to receive notifications, reply to this comment with the word <code>STOP <p dir="auto"><strong>Do not miss the <a href="https://steemit.com/steemitboard/@steemitboard/steemitboard-new-level-notifications" target="_blank" rel="noreferrer noopener" title="This link will take you away from hive.blog" class="external_link">last announcement<span> from <a href="/@steemitboard">@steemitboard! <blockquote> <p dir="auto">Do you like <strong>SteemitBoard's project? <strong><a href="https://v2.steemconnect.com/sign/account-witness-vote?witness=steemitboard&approve=1" target="_blank" rel="noreferrer noopener" title="This link will take you away from hive.blog" class="external_link">Vote for its witness and <strong>get one more award!