tinka alpha
tinkaalpha

Pick your path

tinka new creates every App from a starter kit: a ready-to-run App that it copies into a new directory, under your module path. Tinka has two official starter kits, skeleton and core, embedded in the Tinka CLI, so they always match the version of Tinka you installed. They differ in how much structure you start with, and this page helps you choose before you run tinka new.

The two starter kits

tinka new asks which kit to use, and shows what each one is beside its name:

Output
? Which starter kit would you like to use? (↑/↓ and Enter)
❯ skeleton  An App with Tinka's conventions, ready to grow
  core      The router and nothing else: structure it your way

Both kits give you a go.mod that pins act as a tool, a README.md listing act serve, act test and act build, a .gitignore, a home route and a test of it. Everything else differs:

skeleton core
Layout A package per kind of code: app, config, start and tests One main.go in the App’s root package
Configuration A typed config package that reads environment variables and .env files, and reports every missing or invalid one at boot tinka.HTTPConfig{} in code, with Tinka’s defaults
APP_KEY Generated into .env by tinka new, with a test key in .env.test None
Wired up for you The logger, the encrypter, an exception handler, a 30 second request timeout and health check routes The router
GET / returns {"hello":"world"} as JSON Hello from Tinka as text
Tests tests.App builds the App for tests, and tests/functional holds HTTP tests written with tinkatest main_test.go, written with net/http/httptest
Generators write to app/handlers, app/providers and the other packages, registered in start The root package, registered after tinka.New

The skeleton starter kit

The skeleton is the default. It gives every App the same shape, so you, your team, agents and the generators such as act make:handler all know where code goes:

Text
blog/
├── app/
│   ├── exceptions/
│   │   └── handler.go
│   └── handlers/
│       └── home.go
├── config/
│   ├── app.go
│   ├── config.go
│   ├── http.go
│   └── logger.go
├── start/
│   ├── app.go
│   ├── kernel.go
│   └── routes.go
├── tests/
│   ├── functional/
│   │   └── home_test.go
│   └── tests.go
├── main.go
├── go.mod
├── README.md
├── .env
├── .env.example
├── .env.test
└── .gitignore

Pick the skeleton when you are starting a new App, when several people or agents will work on it, or when you want the docs and generators to match your code exactly. Folder structure explains each directory and which package may import which.

The core starter kit

The core kit keeps the whole App in main.go. Its newApp function creates the App, registers one route and returns it, and main runs it:

Text
blog/
├── main.go
├── main_test.go
├── go.mod
├── README.md
└── .gitignore

Pick the core kit when you already have a structure in mind, when you are learning how the pieces fit before taking on conventions, or when you are adding Tinka to an existing Go module. Every Tinka package works on its own, so you add configuration, service providers and the rest as you need them. The generators work here too: they write into the root package and register what they create in the function that calls tinka.New.

How to choose

Answer one question: do you want Tinka to decide where your code goes?

Choose up front with --kit to skip the question, such as in a script or when an agent runs tinka new:

Terminal
tinka new blog --kit core

See the tinka new reference for every flag.

Where to go next

Once Installation has created your App, follow the path for what you want to build first:

Goal Start with
A guided build of a whole App The Tutorial
Serve a JSON API Routing, then the HTTP context, Response and the body parser
Report errors to clients Exception handling
Share services such as a database pool Dependency injection and service providers
Write Commands for the terminal The command line introduction, then Creating Commands
Test the App The testing introduction, then HTTP tests and console tests
Run it in production Deployment

See also: Installation, Folder structure, Scaffolding