Join David Gassner for an in-depth discussion in this video Programming conditional logic, part of Learning Go.
- I've been using simple, conditional logic…throughout this course, but it's worth reviewing…how Go's syntax for if statements differs…from classic C style languages.…The if statement in Go looks just like C or Java…for the most part, but it doesn't require parentheses…around the boolean condition.…In this file, I've declared one floating value…and one string.…And I'll add an if statement…and I'll set a condition of: x < 0…If this were C or Java, you would add the parentheses…around the condition, but in Go, you don't need them.…
One of the goals of Go is to reduce…the amount of required typing.…And Go's lexer knows how to find the condition…without those characters.…Then I'll add a pair of braces,…and I'll set the value of the result variable…to: less than zero.…I don't need the colon equals operator,…because I've declared the variable…and I declared it outside of the conditional block,…so I can still use it when the conditional block is done.…Then I'll add an else statement,…and I'll set the value of result,…once again using the equals operator.…
- Installing Go tools
- Creating and compiling a Go workspace
- Exploring variables, constants, and types
- Storing ordered and unordered values
- Grouping related values in structs
- Programming conditional logic and loops
- Defining and calling functions
- Handling errors
- Working with files
- Creating a simple HTTP server
Skill Level Beginner
1. Getting Started
2. Essential Go Skills
3. Managing Simple Values
4. Managing Complex Types and Collections
5. Managing Program Flow
6. Structuring Go Code
7. Working with Files and the Web
Next steps2m 26s
- Mark as unwatched
- Mark all as unwatched
Are you sure you want to mark all the videos in this course as unwatched?
This will not affect your course history, your reports, or your certificates of completion for this course.Cancel
Take notes with your new membership!
Type in the entry box, then click Enter to save your note.
1:30Press on any video thumbnail to jump immediately to the timecode shown.
Notes are saved with you account but can also be exported as plain text, MS Word, PDF, Google Doc, or Evernote.