Learn about the number types that are available in Go. This video covers integers of various types, floats, and zero values. It also explores the various formats of assignments that Go provides.
- [Instructor] Let's write a program…that calculates the mean, or average, of two numbers.…We declare two variables, x and y, of type int.…And like C or Java, the type comes after the variable name.…In Go, you have int8, int16, int32, int64,…and the unsigned versions of all of them.…The int type, without size,…depends on the system you are using,…and is the one you will usually use.…If you don't assign a value to a variable,…Go will assign the zero value for this type.…
In this case, it will be zero.…In lines 12 and 13, we assign values to x and y.…In line 15 and 16, we use fmt.Printf.…The Printf function gets a template to print…and then a value to fill this template.…The %v verb will print a Go object…and the %t verb will print its type.…In line 18, we define mean and in line 19,…we assign the value of x plus y divided by two.…
And in line 20, again we print the value of mean…and its type.…So let's run it.…go run mean.go.…And we see x is one with type of integer,…y is two with type of integer,…and the result is one, type of integer.…
- Go basic types, conditionals, and loops
- Go functions
- Object-oriented programming with Go
- Error handling
- Concurrent programming with channels
- Testing and project management
- Networking with JSON and HTTP
Skill Level Beginner
Programming Foundations: Fuzzy Logicwith Erin Colvin41m 50s Intermediate
Getting started1m 34s
1. Getting Started
2. Go Basics
5. Error Handling
7. Project Management
Next steps1m 12s
- 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.