Download source code:
https://github.com/challenai/wtfcache
intro #
In this article, we will see how to build a distributed cache system from scratch, this is the first part of our articles.
set the basic environment #
First of all, let’s simply create a folder to store the new project, the command should look like this: mkdir cache
.
you should start a new go project with go mod init something
, for example: go mod init cacheme
,
then you can find a go.mod
file that appears in your directory.
Since we have a project, we can create a main.go
file in our project to print hello, world
:
package main
import "fmt"
func main() {
fmt.Println("vim-go")
}
Now, it’s time to run the project with go run main.go
,
you can also compile it to a binary with go build -o hello main.go
and input ./hello
to run this binary executable file.
the other things we could do (but not necessary) are listed as follows:
- add a
.gitignore
file so that we can ignore some useless files like .DS_Store in mac environment - add a read me so that everyone else can understand what this project is used for.
- add a license, I personally prefer some simple licenses like MIT or GPL3