Securing your web server is always a very important task since you normally don’t want any unauthorized users accessing your server. This tutorial should help you to set up Auth0 together with a Go web server using a JWT middleware for authorization.
First of all, of course, you don’t have to use Auth0 and can simply implement all the user management and signing stuff yourself. …
A brief introduction of how to read and write CSV files in Go.
Reading and writing CSV files is a pretty common use case in programming. Also, it is pretty easy to understand and implement due to the straightforward format of CSV files.
As always I prepared a small GitHub repository for you where you can check out the full code:
So let’s first start with defining some basic structures. In the next code snippet, you can see that a small helper method was implemented that only logs an error if available. This helper is called in the actual implementation…
As always you can check out the full example of this article in one of my GitHub repositories, so feel free to take it as a reference:
So let’s start our Go project from scratch. First, we have to create a new module:
// Create new project folder and 'cd' into it.
$ mkdir medium_go_fiber_swagger && cd medium_go_fiber_swagger// Create module called `medium_go_fiber_swagger`
$ go mod init medium_go_fiber_swagger
Next, we can already add the Fiber module to our module/application.
// Install Go Fiber module and add to `go.mod`
$ go get -u github.com/gofiber/fiber/v2
go.mod file should now look like…
Just imagine having a working Docker image with just~30KB of actual base image size, so you approximately don’t have any overhead at all. Let’s make it happen in this article.
So you might question if it is really possible to have your application run on a 30KB base image. Long story short: “Yes it is!”, even though there is of course also a drawback.
So let’s check some final results first. In the following image, you can see three different Docker images. All three images contain the same runnable Go application, a simple Hello-World program, nothing fancy.
A short introduction to installing Go on your system and creating your very first “Hello-World”-application in Go in under 10 minutes.
Visit https://golang.org/doc/install and download the appropriate installer.
You might know that other languages like C are using pointer arithmetic. So when using variables you can either “point” to a certain address in memory where the actual value of your variable is located (by reference) or have the value directly at hand (by value). Of course, deep under the hood, everything is stored in memory.
Securing your Cloud Run services from the public but allowing authenticated developers/users to access them.
When creating a Cloud Run service it’s possible to either set “unauthenticated” access — so it's available to the public internet — or to restrict the access. In most use cases the access should be restricted due to security reasons, especially for backend services. But you can also host your frontends on Cloud Run and here public access is desired, so everyone can use your app.
In one of my other articles — Easy Serverless Deployment Of Your React App Using Cloud Run — you…
But you can imagine that adding this code all the time is quite a lot of boilerplate and a lot you have to duplicate each time you…
Deploying your React App as a Docker container on a serverless environment using GCP Cloud Run and making it accessible on the public internet.
Before we start please make sure that you have the following parts ready:
How to build and run a lean Docker image for your React web application and why it is important.
I think we all can agree that a big Docker image size is never good. There are several reasons:
With one of my recent articles Decreasing your Node.js Docker image size by 90%! I already provided an example of how to decrease your Docker Image size from around 930MB to just 102MB for your Node.js application. …
Development Team Lead | Passionate Developer