Setup a web server in Go, connect a SQL database server, and serve an API to perform CRUD commands on database entries
New
Created by Jens Schendel
English
Free
What you’ll learn
- Code and deploy a simple web server programmed in Google’s programming language Go (golang)
- Connect the web server to an already prepared PostgreSQL database server (as a service running in a docker container)
- Program the capabilities to perfom SQL statements and deploy a simple API accessable through buy GET/POST/PUT/DELETE
- Perform CRUD (Create, Read/Retrieve, Update, Delete/Destroy) commands on database entries
Requirements
- Basic Go programming knowlegde, better intermediate experience
- A working Go programming environment (Go installed, compiling, IDE)
- Access to a running PostgreSQL server (localhost or in the same network)
- Basic SQL knowledge
- Joy and curiosity trying new things
Description
Join me on an advanced short trip as we experience the development of a real-life coding project with Google’s programming language Go (golang). Together we will setup a web server, connect it to a PostgreSQL database server, and let it serve an API to perform CRUD (Create, Read/Retrieve, Update, Delete/Destroy) commands on database entries – the whole thing we build from scratch of course.
As a developer of web applications, you can quickly find yourself in a situation on a train ride or a flight where you urgently and quickly need a reliable web server. It must be accessible via an API and be able to execute CRUD commands like Create, Read/Retrieve, Update, and Delete/Destroy database entries. Of course, it should be a reliable and handy solution, which is available on different operating systems (Linux, macOS, Windows), have short compilation and fast execution times.
With the Go programming language from Google, a simple tool is available for creating a development server. In this course you will learn to set up such a web server and put it into operation. Rather, I want to show how Google’s programming language can be used to achieve respectable results in the shortest possible time in a real world scenario.
The fun of “ease of programming” is in the foreground here! So enjoy it, it’s free!
Why did Google develop a new programming language?
In Google’s words, “Go was born out of frustration with existing languages and environments for systems programming. Programming had become too difficult and the choice of languages was partly to blame. One had to choose either
- efficient compilation,
- efficient execution, or
- ease of programming;
all three were not available in the same mainstream language. Programmers who could were choosing ease over safety and efficiency by moving to dynamically typed languages such as Python and JavaScript rather than C++ or, to a lesser extent, Java. Go is an attempt to combine the ease of programming of an interpreted, dynamically typed language with the efficiency and safety of a statically typed, compiled language. It also aims to be modern, with support for networked and multicore computing.
Finally, working with Go is intended to be fast: it should take at most a few seconds to build a large executable on a single computer. To meet these goals required addressing a number of linguistic issues: an expressive but lightweight type system; concurrency and garbage collection; rigid dependency specification; and so on. These cannot be addressed well by libraries or tools; a new language was called for.“
In my humble opinion, Go is the best programming language you can learn today. I’ve worked with a few programming languages since I was introduced to programming through BASIC in the mid-80s, and Go is by far the best-designed language I’ve ever used.
Now start your computer and let’s have some fun coding a real webserver in Go!
Who this course is for:
- Beginner and intermediate Go programmers
- Full stack developers for web application and APIs
- Developer in need of a fast setup web server performing CRUD commands
Show less
Course content
5 sections • 15 lectures • 1h 52m total lengthCollapse all sections
Introduction & Setup2 lectures • 16min
- Project overview: introduction, prerequisites and requirements08:22
- Setup a PostgreSQL server and fill the first table manually08:06
Implementation of the Webserver6 lectures • 33min
- Setup the project with Go modules and creation of a first version05:42
- Creation of the model(s) – definition of the structure of the content to serve04:03
- Definition of the database connection07:16
- Creation of a first route – prepare the way to the services02:49
- Implementation of a first service – here we go!07:31
- The first run – a brief test05:33
Implementation of the remaining services4 lectures • 6min
- Implementation of a “create post” service02:05
- Implementation of a “get post” service01:55
- Implementation of an “update post” service01:27
- Implementation of a “delete post” service00:53
Brief test & goodbye2 lectures • 11min
- A brief test of all the functionalities and implemented features09:46
- Goodbye00:53
The “hidden track”1 lecture • 46min
- Learn how to solve a task which could come up in a job interview!45:55