A common problem that many people (including me) have faced when programming in Go, is to pin point the source of an error. Other programming languages provide you with a stack trace to tell you where the error came from, but Go does not have this behavior by default.
In this article, we will discuss how to use the
fmt, and the
github.com/pkg/errorslibraries to give us better error reporting.
When a user signs in to your application, their authorization has to be persisted across all other routes. In simpler words, this means that you have to know who is calling your HTTP server.
One way to do this is to store the users “session”. A session is started once a user logs in, and expires some time after that. Each logged in user has some reference to the session, which they send with their requests. We then use this reference to look up the user that it belongs to and return information specific to them.
Any application that involves password storage and authentication has to make sure that its passwords are safely stored. You cannot simply store the username and password of your users the way you store other types of data. In fact, it should be impossible for you to actually know the password of any of your users.
This post will go through how to securely store your users password by building a very simple web application in Go, and using a Postgres database to store your users credentials.
Go is known for how easy it is to build concurrent programs in it. But, with all this concurrency, comes the possibility of the dreaded data race – one of the hardest bugs to debug if you’re ever unfortunate enough to encounter it in your code.
In this post, we will go through a sample program that causes a data race, and detect the race condition with the race detector tool. We will then look at some of the methods to get around and solve the race condition, while still keeping the core logic of our code intact.
Linear regression is the process of fitting a linear equation to a set of sample data, in order to predict the output.
In order to do this, we assume that the input
X, and the output
Yhave a linear relationship.
Ymay or may not have a linear relationship. We just want to find the closest linear relationship between them, in order to explain the data that we observe.
We can get a better understanding of linear regression from the following chart:
The line is the linear relationship that we predicted based on the points which we observed.
If you want to get a brief recap of the theory behind linear regression, you can see my notes here
In order to perform linear regression with python, we will need to:
- Generate the sample data, and divide it into training and testing data.
- Create a linear regression model
- Fit our model using the training data
- Test our model using the testing data
Tensorflow is a machine learning library released by Google, which is now one of the most popular machine learning libraries currently in use. While the name “Tensorflow” might seem intimidating, it’s actually a really neat library that can be used for many things outside of machine learning as well.
In fact, there will be no further mention of machine learning in this post, since we are only going to learn about the basics of the Tensorflow library. Once, you understand how the library works, it’s application in AI and machine learning will come naturally.
Apache Kafka is a distributed streaming platform. It can be used for anything ranging from a distributed message broker to a platform for processing data streams.
Anyone approaching Kafka for the first time may find it intimidating, with the vast amount of documentation present. This post is written to help you get your hands dirty and run a distributed Kafka cluster on your system with the least effort.
There’s always a bit of friction when it comes to making JSON work with statically types programming language. One one hand, JSON data can be anything from a simple number, to a complex array of embedded objects. Working with a language like Go means you have to make the variable structure of JSON fit into structured variables.
Fortunately, Go tries to make this process as easy for us as possible, and gives us many options to work with when we want to parse our JSON data.
subscribe via RSS