Join David Gassner for an in-depth discussion in this video Defining and calling functions, part of Learning Go.
- As we've seen throughout this course,…Go is organized with packages…and packages have functions.…Your own application has its own package,…always named main, and it also has…the main function which is called automatically…by the run time as the application starts up.…You can define your own custom functions…and you can then organize them into their own packages.…I'll start in this video with custom functions…that are declared in the main package.…As long as the function definitions…and the code that calls them are in the same package,…the case of the function name can be either upper or lower.…
Below the main function I'll declare another function,…and I'll start with the func keyword.…And I'll name my simple function doSomething.…And then, within the braces, I'll call fmt.Println…and I'll pass in a string of…"Doing something!"…Then I'll go back up the main function…and I'll call the function.…I'll type do and Visual Studio code already knows…that the function exists,…and it lets me call it with autocomplete.…
- 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.