npx skills add ...
npx skills add encoredev/skills --skill encore-go-getting-started
npx skills add encoredev/skills --skill encore-go-getting-started
Bootstrap a brand-new Encore Go project from zero. Only for first-time CLI install and `encore app create` — not for architecture or feature questions.
A minimal Encore Go app:
This file marks the root of your Encore app. The id is your app's unique identifier.
In Encore Go, any package with an //encore:api endpoint becomes a service:
The dashboard shows:
| Command | Description |
|---|---|
encore run | Start the local development server |
encore test | Run tests (uses go test under the hood) |
encore db shell <db> | Open a psql shell to a database |
encore gen client | Generate API client code |
encore app link | Link to an existing Encore Cloud app |
Create a migration:
encore-go-api skill)encore-go-auth skill)encore-go-pubsub), cron jobs (encore-go-cron), buckets (encore-go-bucket), secrets (encore-go-secret), or caching (encore-go-cache)encore app link then git push encoremy-app/
├── encore.app # App configuration
├── go.mod # Go module
└── hello/ # A service (package with API)
└── hello.go # API endpoints// encore.app
{
"id": "my-app"
}// hello/hello.go
package hello
import "context"
type Response struct {
Message string `json:"message"`
}
//encore:api public method=GET path=/hello
func Hello(ctx context.Context) (*Response, error) {
return &Response{Message: "Hello, World!"}, nil
}# Start the development server
encore run
# Your API is now available at http://localhost:4000# Opens the local development dashboard
encore run
# Then visit http://localhost:9400type GetUserParams struct {
ID string
}
type User struct {
ID string `json:"id"`
Name string `json:"name"`
}
//encore:api public method=GET path=/users/:id
func GetUser(ctx context.Context, params *GetUserParams) (*User, error) {
return &User{ID: params.ID, Name: "John"}, nil
}// db.go
package hello
import "encore.dev/storage/sqldb"
var db = sqldb.NewDatabase("mydb", sqldb.DatabaseConfig{
Migrations: "./migrations",
})-- hello/migrations/1_create_table.up.sql
CREATE TABLE items (
id SERIAL PRIMARY KEY,
name TEXT NOT NULL
);import "encore.dev/storage/sqldb"
type Item struct {
ID int
Name string
}
func getItem(ctx context.Context, id int) (*Item, error) {
item, err := sqldb.QueryRow[Item](ctx, db, `
SELECT id, name FROM items WHERE id = $1
`, id)
if err != nil {
return nil, err
}
return item, nil
}