Course Overview
Working with web applications in Go is remarkably easy, but it does not take too long to realize that in a lot of cases, we end up writing the same kind of code every time we start a new project. You might need to read JSON, write JSON, upload files, or any of the commonly used features of a given web application. In other words, we often rewrite code that we have already written, many times over.
Rather than simply copying and pasting code from one project to another, it makes sense to take advantage of Go modules -- reusable code that can be included in a project by simply issuing a "go get" command. That way, if new functionality is added to that module, any project that imports it can take advantage of that functionality simply by updating its dependencies, and if a bug is discovered, you can fix it by updating the module; every project that uses that module gets the bug fix with a single "go get -u" command.
Building a robust, secure, well-tested module is not difficult, but it does require careful planning to ensure that it will work across different operating systems.
This course will take you through the steps necessary to produce a module that includes many of the tasks commonly used in web applications, including:
reading JSON
writing JSON
producing well formatted, informative error messages
uploading one or more files to a server, and limiting uploads by mime type and file size
creating directories on the server
generating random strings
downloading static files
posting JSON to a remote service
creating a URL safe slug from a string
We'll build our module using Go 1.18's new workspaces tools, and we'll ensure that the entire module is well-tested.
Our final module will not have any external dependencies, and will only use functionality found in Go's standard library.
By the time you have finished this course, you'll have a Go module that will make starting a new web application much faster, and you won't be depending on someone else's code to do so.
FAQ
FAQ area empty
Course curriculum
Chương 1 Introduction 3 bài · 6 phút
Chương 2 Project Setup 3 bài · 10 phút
-
Installing Go 1:31
-
Installing an IDE 3:14
-
Setting up our Go Workspace 4:59
Chương 3 Getting Started with the Module 5 bài · 19 phút
-
What we'll cover in this section 0:53
-
Creating a function to generate a random string 5:11
- Trying out our new module in a simple Go application Học thử 3:40
-
Writing a test for our RandomString function 3:15
- Pushing our module up to GitHub Học thử 5:58
Chương 4 Uploading one or More Files 8 bài · 1 giờ 9 phút
-
What we'll cover in this section 1:23
-
Getting started with the UploadFiles method 24:26
- Adding a project to our workspace to test uploading files Học thử 1:31
-
Trying out our new upload functionality 12:19
- Adding a convenience method, UploadOneFile Học thử 5:55
-
Writing a test for the UploadFiles method in our module 15:29
-
Writing a test for UploadOneFile 4:34
-
Pushing our changes to GitHub 3:04
Chương 5 Creating Directories if they do not exist 6 bài · 10 phút
-
What we'll cover in this section 0:52
-
Writing the CreateDirIfNotExists method 2:20
-
Trying out our new method 2:21
-
Writing a test for CreateDirIfNotExists 2:12
-
Updating the UploadFiles method to take advantage of our new method 1:32
-
Updating our readme and pushing changes to GitHUB 1:09
Chương 6 Generating Slugs 5 bài · 17 phút
-
What we'll cover in this section 0:42
-
Writing the Slugify method for our module 3:43
-
Adding an app-slug project to our Go workspace and trying things out 3:32
-
Update our tests 7:57
-
Pushing our changes to GitHub 1:30
Chương 7 Downloading a Static File 5 bài · 20 phút
-
What we'll cover in this section 0:58
-
Writing the DownloadStaticFile function 3:59
-
Trying things out 7:52
-
Writing a test for DownloadStaticFile 5:49
-
Pushing our changes to GitHub 1:16
Chương 8 Working with JSON 15 bài · 1 giờ 19 phút
-
What we'll cover in this section 0:56
-
Reading JSON 8:34
-
Improving error messages in ReadJSON 8:09
-
Writing a test for ReadJSON 7:37
-
Adding additional cases to our table test for ReadJSON 6:41
-
Writing JSON 3:53
-
Writing a test for WriteJSON 2:49
-
Creating the ErrorJSON function 2:48
-
Writing a test for ErrorJSON 4:01
-
Pushing JSON to a remote service 6:54
-
Writing a test for PushJSONToRemote 6:17
-
Setting up our simple web app and adding some HTML 4:49
-
Getting started with the web app 5:36
-
Handling a simple JSON Post 4:33
-
Handling pushing to a remote service 5:21
Chương 9 Tagging a release & Semantic Versioning 4 bài · 11 phút
-
What we'll cover in this section 1:03
-
What is semantic versioning? 2:06
-
Tagging version 1.0.0 of our module 2:10
-
Updating the version to 2.0.0 6:10
Chương 10 Trying our module out 4 bài · 15 phút
-
What we'll cover in this section 0:39
-
Creating a simple (dummy) API 3:08
-
Importing our toolkit module to the project and trying one endpoint 3:05
-
Trying out the login handler 7:42
Requirment
-
Some experience with the Go programming language is required.
Outcomes
-
How to build a platform agnostic, re-usable Go module
-
How to share your module with other Go developers
-
How to write tests for your module
-
How to manage multiple versions of your module
-
How to use Go 1.18's new go work feature, workspaces
0 Student
9 Courses
0 review