From the course: Build a Microservice with Go

Unlock the full course today

Join today to access over 24,700 courses taught by industry experts.

Set up the database client

Set up the database client - Go Tutorial

From the course: Build a Microservice with Go

Set up the database client

- [Instructor] Now we need to build an interface in a client and implement them in order to start executing our code, and we're going to start with the database layer to do this. Now I tend to write my code such that I create an interface in a client and I wrap whatever I'm using in that client to give me a layer of abstraction in case I need to do anything specific to using it, and that's what we're going to do here. So in our implementation, we are going to create a new directory and this is called Internal. And this is a way to prevent your code from being exported out if someone brings it in. This is just a practice that I do on a regular basis when I'm writing code. Now in here we are going to create a new directory and we will simply call this database, and now we are going to create a new go file called client. Okay, so let's define our type and this is going to be a database client, and this will be our interface.…

Contents