Getting Started with Go: Functions & Object Orientation
Go
| Beginner
- 12 videos | 1h 7m 18s
- Includes Assessment
- Earns a Badge
Go is a statically-typed, multi-paradigm programming language supporting functional and procedural programming, and while Go is not an object oriented programming language out of the box, it does provide types and methods that can conveniently be used to emulate object oriented programming. In this course, you'll explore how to define and write functions and you'll learn how functions can be declared with receivers to create methods in Go. You'll explore how pointers and pointer variables are used in Go and you'll learn how to experiment with structs as objects and interfaces that explicitly define the relationship between objects. You'll explore how data types in Go can have state and behavior associated with them, and lastly, you'll explore how a lightweight form of object orientation is achieved in Go.
WHAT YOU WILL LEARN
-
Discover the key concepts covered in this courseRecognize how functions and methods are created and used in goRecognize how object orientation can be achieved in go even though it is not strictly an object oriented languageDeclare and write functions in goUse parameters to pass data to functions in goWork with data returned by functions in go
-
Declare and call variadic functions in goDefine and initialize structs in goCreate and work with methods in goImplement an interface in go to define a method setCreate a structured data type as an object in go with methods that can interact with itSummarize the key concepts covered in this course
IN THIS COURSE
-
1m 39sIn this video, you’ll learn more about the course and your instructor. In this course, you’ll learn to define and write functions. You’ll also learn how functions can be declared with receivers to create methods in Go. You’ll explore how pointers and pointer variables are used in Go. You’ll experiment with structs as objects and interfaces that define relationships between objects. You’ll explore how data types in Go have state and behavior associated with them. FREE ACCESS
-
5m 52sIn this video, you’ll learn more about functions and methods in Go. A function is a set of code that takes zero or more inputs and produces zero or more outputs. These are important in software programs because by writing functions, you can break up programs into smaller chunks, making them more manageable. Typically, functions are written to solve very generalized problems and are designed to be called over and over. FREE ACCESS
-
6m 48sIn this video, you’ll learn more about how object orientation can be achieved in Go, even though it’s not an object-oriented programming language. In object-oriented programming, you have the concept of objects and data types that have state and behavior. State, in this case, is the data and behavior is the code. While Go doesn’t have an object type, it has the struct type. The struct type has named fields as attributes of an object. FREE ACCESS
-
5m 36sIn this video, you’ll watch a demo. You’ll learn to declare and write functions in Go. To start, open Visual Studio Code. On the Visual Studio Code main page, you’ll open a folder in the Visual Studio Code explorer by typing Ctrl+K, and then Ctrl+O. That opens an Open Folder dialog. You’ll open your projects/demo folder, and choose Select Folder. Close the Welcome screen. In Explorer, go to your demo folder and select New File. FREE ACCESS
-
10m 45sIn this video, you’ll watch a demo. In this demo, you’ll pass parameters to functions. Sometimes when calling a function, you need to pass data to the function. On your local development machine, open Visual Studio Code. In Visual Studio Code Explorer, select the New File icon, and name this file main.go. In your editing canvas, you’ll start typing package. From the options, select pkgm package main and main function to create the code. FREE ACCESS
-
5m 50sIn this video, you’ll watch a demo. In this demo, you’ll work with data being returned from functions. A function's signature includes the result declaration. This specifies the return values are if there are any in the function. You’ll open Visual Studio Code. In Visual Studio Code Explorer, select the New File icon, and name this new file main.go. In the main editing canvas, start typing package, and select package main and main function. FREE ACCESS
-
6m 31sIn this video, you’ll watch a demo. To get started, you’ll open Visual Studio Code. In Visual Studio Code Explorer, select New File and create a new file. Call it main.go. The last parameter of a function signature may have a type prefixed with three dots. This is called the pack operator. The pack operator is used when you declare variadic functions because the arguments are packed into a slice when passed to the function. FREE ACCESS
-
8m 53sIn this video, you’ll watch a demo. In this demo, you’ll define and initialize a struct. You’ll first open Visual Studio Code and in Visual Studio Code Explorer, you’ll select the New File icon. Next, you’ll create a new file called file main.go. In the editing canvas, set up a package by typing pk. Then select pkgm, package main and main function. Go will create the code for you. FREE ACCESS
-
4m 31sIn this video, you’ll watch a demo. In this demo, you’ll create and write a method. You’ll open Visual Studio Code. In Visual Studio Code Explorer, select the New File icon. Name this file main.go. In the editing canvas, type pk to bring up a context menu with options the Go extension provides. Press Enter to select pkgm. This creates the package main and main function. Place your cursor at the start of line 3. FREE ACCESS
-
5m 11sIn this video, you’ll watch a demo. In this demo, you’ll implement an interface in Go. You’ll open Visual Studio Code. In Visual Studio Code Explorer, select the New File icon, and name the new file main.go. In the editing canvas, press Ctrl+V and paste in your code. On line 1 package main, and in your import block, you’ll import the format that’s on line 3. Line 5 is where you’ll define your interface. FREE ACCESS
-
4m 46sIn this video, you’ll watch a demo. In this demo, you’ll create and work with objects in Go. You’ll open Visual Studio Code. In Visual Studio Code Explorer, select the New File icon. Give the new file the name main.go. In the editing canvas, press Ctrl+V to paste in the code. In the import block, you’ll import the format package. On line 7, you’ll define an interface. This interface is named Shape. FREE ACCESS
-
56sIn this video, you’ll summarize what you’ve learned in this course. You’ve examined how functions and methods are implemented and how object orientation is achieved in Go. You explored functions and methods in Go by declaring, writing, and using parameters and returned data with functions. You worked with variadic functions and defined and initialized structs. You also declared and wrote methods, implemented interfaces, and explored how to use data types and methods. FREE ACCESS
EARN A DIGITAL BADGE WHEN YOU COMPLETE THIS COURSE
Skillsoft is providing you the opportunity to earn a digital badge upon successful completion on some of our courses, which can be shared on any social network or business platform.
Digital badges are yours to keep, forever.