In this tutorial we'll create a simple Encore app together. The app will be a simple todo list.
If you don't have Encore installed, go ahead and set it up now. If you're not sure, run the following command in your terminal (indicated by the $ sign):
$ encore version
If Encore is installed you will see the version of the installation. If not, you will
see something like
encore: command not found.
We'll start by creating an app. An app in Encore represents your whole application; it's suitable for everything from a small todo list app to a large project run by many different teams across the globe.
First change directory to where you would like to store your source code
cd in your command line. Then, create your app with the following command:
$ encore create myapp
This will create the
myapp directory inside your current directory. If you
into this directory, you should see the following files:
myapp/ encore.app go.mod hello/ hello.go
myapp/ is the containing directory for your whole application. The name is not
important and you can change it as you please.
encore.app contains the configuration Encore needs to connect your code to the right
application on the Encore servers.
go.mod is the Go module definition for the app. If you're not sure what this is,
you might want to read more about Go modules.
hello/ is a Go package that defines a service. Services are just like regular Go packages
but they also contain Encore API endpoints and may have resources like SQL databases attached
to them. More about this later.
hello/hello.go is a Go file with a simple Encore API endpoint. We'll dig into it in greater
To make sure everything is set up correctly,
cd into the
myapp directory if you haven't already
and in your command line run the command:
$ encore run
You should see output that looks like this:
Running on http://localhost:4060 9:30AM INF registered endpoint endpoint=World service=hello
Now, open a new command line window and use
curl to make an HTTP request towards your server:
$ curl http://localhost:4060/hello.World
You should see as a response:
In that case, you're all set up and ready to go! Press
Ctrl-C to stop the server.
If everything looks good, you are ready to move on to part 2 of the tutorial.