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
| Flag | Short | Default | Description |
|---|---|---|---|
--skip-deps | false | Skip running go mod tidy | |
--skip-wire | false | Skip running Wire DI code generation | |
--skip-gqlgen | false | Skip running gqlgen GraphQL code generation |
Examples
Initialize a freshly cloned project:
git clone https://github.com/myorg/myapp.git
cd myapp
gofasta initInitialize but skip gqlgen (useful if you do not use GraphQL):
gofasta init --skip-gqlgenSkip all code generation steps (only install dependencies):
gofasta init --skip-wire --skip-gqlgenWhat It Does
When you run gofasta init, the CLI performs the following steps in order:
- Verify project structure — checks that the current directory contains a valid Gofasta project (looks for
go.modandconfig/config.yaml) - Install dependencies — runs
go mod tidyto download and synchronize all Go module dependencies - Generate Wire code — runs
wire ./app/di/...to generate the dependency injection container from your provider definitions - Generate GraphQL code — runs
gqlgen generateto create Go types and resolvers from your.graphqlsschema files - 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
| Scenario | Command |
|---|---|
| Starting a brand-new project from scratch | gofasta new myapp |
| Cloning an existing project from Git | gofasta init |
Pulling changes that modified wire.go or GraphQL schemas | gofasta init |
| Setting up the project on a new machine | gofasta init |
| CI/CD pipeline setup step | gofasta init --skip-wire --skip-gqlgen |
Related
- gofasta new — create a new project from scratch
- gofasta wire — regenerate only Wire DI code
- gofasta dev — start the development server
- Installation