Join David Gassner for an in-depth discussion in this video Creating a simple HTTP server, part of Learning Go.
Go makes it very easy to create…a simple HTTP server application.…You use the same HTTP package…as is used to make web requests,…but now you're running an application…on a host computer that listens for…and responds to requests…from other web-connected devices.…I'm starting in this file, httpServer.go,…and it only has the custom function "checkError"…that I've created in previous applications.…I'll add to the import statement,…and I'll import the package "net/http."…Next, I'll create a struct.…
The name of the structure can be anything you like.…I'm just going to name it "Hello,"…and I'll say that it's a struct,…and it won't have any fields.…The purpose of this structure isn't to manage the data.…Instead, it will have a method named "serveHTTP."…The signature, or syntax, of this method…is defined by the HTTP package.…You have to follow it pretty precisely.…I'll create the function…and I'll assign its data type to "Hello,"…and I'll give it a value of h.…
Then I'll name the function ServeHTTP.…This must be the name of this function.…
- 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.