Naming conventions

snake_case Go, kebab-case TS, plural routes, plural tables.

5 mineasy

Grit names things consistently so you never have to guess what to call your new file. This is a 5-minute lesson — but it's the one that makes your future code look like it belongs.

The full table

ThingConventionExample
Go filessnake_caseuser_handler.go
Go structsPascalCasetype User struct
Go funcs (exported)PascalCaseGetUsers()
Go funcs (private)camelCaseparseToken()
TS fileskebab-caseuse-users.ts
React componentsPascalCaseDataTable.tsx
API routesplural, lowercase/api/users
DB tablesplural snake_caseblog_posts
Zod schemasPascalCase + SchemaUserSchema

The pattern behind the table

Three principles cover everything:

  1. Go uses snake_case for filenames + PascalCase for types and exported funcs. That's the Go community convention. Grit doesn't fight it.
  2. TS uses kebab-case for filenames + PascalCase for components. The kebab-case convention is from React Router / Next.js — readable in URLs.
  3. API routes and DB tables are plural. /api/users, users table — a user is a single resource; the collection is plural. Avoids the "is it /user or /users?" debate.
These are the same conventions Google's style guide, Airbnb's React guide, and most production Go codebases use. Nothing exotic — just one place that picks all of them and applies them consistently.

Quick check

You're adding a React Query hook that fetches invoices. What's the filename?

Try it

Look at your scaffolded project. Find three files across web, admin, and api — pick one from each. In notes.md, write the filename + which convention it follows.

What's next

Files are named. Next — how Grit's API responses are shaped. One envelope every endpoint follows. Memorise it once, use it forever.

Spot a typo? Have an idea?

Help us improve this lesson. One click opens a GitHub issue with the lesson URL pre-filled — suggest clearer wording, report a bug, or request more depth. The course keeps improving thanks to learners like you.

Suggest an improvement on GitHub