Procyon|Docs
Configuration

Profiles

Use active and default profiles to load environment-specific configuration.

Profiles let one application load different values for development, staging, production, or another runtime mode.

Procyon keeps two profile sets:

  • Active profiles are explicit runtime choices.
  • Default profiles are used when no active profile is selected.

The built-in default profile is default.

Active profiles

Set active profiles when you know exactly which environment should be loaded.

resources/procyon.yml
procyon:
  profiles:
    active: dev

With dev active, Procyon loads the base file first and then looks for a profile-specific file:

resources/procyon-dev.yml
server:
  port: 3000

database:
  host: localhost

You can also select the active profile from the runtime environment:

terminal
$ go run . --procyon.profiles.active=prod
terminal
$ PROCYON_PROFILES_ACTIVE=prod go run .

Default profiles

Default profiles are fallback profiles. They are useful when local development should use a named profile unless the deployment explicitly chooses another active profile.

resources/procyon.yml
procyon:
  profiles:
    default: local

With no active profile set, Procyon loads resources/procyon-local.yml after the base file.

Loading order

Base configuration is loaded first. Then the selected profile files are loaded on top of it.

resources/procyon.yml
server:
  port: 8080
  readTimeout: 5

database:
  port: 5432
resources/procyon-prod.yml
server:
  port: 80

database:
  host: db.internal

For the prod profile, server.port and database.host come from procyon-prod.yml, while server.readTimeout and database.port still come from procyon.yml.

Programmatic profile changes

The environment also exposes methods for setting profiles from code. Use this from framework or integration setup code, before configuration-dependent components are initialized.

profiles.go
if err := env.SetActiveProfiles("prod"); err != nil {
    return err
}

if err := env.AddActiveProfiles("metrics"); err != nil {
    return err
}

if err := env.SetDefaultProfiles("local"); err != nil {
    return err
}

Profile names must not be empty or blank.

Keep profile selection in one place

Use base configuration, environment variables, command-line arguments, or early startup code to select profiles. Profile-specific files should only contain settings for that profile.