Skip to Content

gofasta init

Initializes an existing Gofasta project that was cloned from a repository or copied from another machine. This command installs Go dependencies, runs Google Wire dependency injection generation, and runs gqlgen GraphQL code generation to ensure the project is ready to build and run.

Use this command instead of gofasta new when you already have the project source code and just need to set up the development environment.

Usage

gofasta init [flags]

Run this command from the root directory of your Gofasta project (the directory containing go.mod).

Flags

FlagShortDefaultDescription
--skip-depsfalseSkip running go mod tidy
--skip-wirefalseSkip running Wire DI code generation
--skip-gqlgenfalseSkip running gqlgen GraphQL code generation

Examples

Initialize a freshly cloned project:

git clone https://github.com/myorg/myapp.git cd myapp gofasta init

Initialize but skip gqlgen (useful if you do not use GraphQL):

gofasta init --skip-gqlgen

Skip all code generation steps (only install dependencies):

gofasta init --skip-wire --skip-gqlgen

What It Does

When you run gofasta init, the CLI performs the following steps in order:

  1. Verify project structure — checks that the current directory contains a valid Gofasta project (looks for go.mod and config/config.yaml)
  2. Install dependencies — runs go mod tidy to download and synchronize all Go module dependencies
  3. Generate Wire code — runs wire ./app/di/... to generate the dependency injection container from your provider definitions
  4. Generate GraphQL code — runs gqlgen generate to create Go types and resolvers from your .graphqls schema files
  5. Verify build — confirms the project compiles successfully
$ gofasta init Verifying project structure... Running go mod tidy... Generating Wire DI code... Generating GraphQL resolvers... Build verified successfully. Project initialized!

When to Use

ScenarioCommand
Starting a brand-new project from scratchgofasta new myapp
Cloning an existing project from Gitgofasta init
Pulling changes that modified wire.go or GraphQL schemasgofasta init
Setting up the project on a new machinegofasta init
CI/CD pipeline setup stepgofasta init --skip-wire --skip-gqlgen
Last updated on