Skip to content

docs(config): document dual-loader support (envconfig + env-tag)#89

Merged
ankurs merged 1 commit into
mainfrom
docs/dual-loader-tags
May 4, 2026
Merged

docs(config): document dual-loader support (envconfig + env-tag)#89
ankurs merged 1 commit into
mainfrom
docs/dual-loader-tags

Conversation

@ankurs
Copy link
Copy Markdown
Member

@ankurs ankurs commented May 4, 2026

Summary

  • The Config struct already carries both envconfig:"…" and env:"…" struct tags on every field, so it can be populated by either family of loaders. The type doc comment only mentioned envconfig, hiding this from env:-tag users.
  • Extended the Config doc comment to document dual-loader support and list the common compatible loaders (kelseyhightower/envconfig, caarlos0/env, sethvargo/go-envconfig, ilyakaznacheev/cleanenv).
  • Regenerated config/README.md via make doc.

No code or behavior changes — comment-only.

Test plan

  • make build clean
  • make lint clean (0 issues, govulncheck clean)
  • config/README.md regenerated via make doc; diff limited to the Config type paragraph and three line-number anchors

Summary by CodeRabbit

  • Documentation
    • Enhanced configuration documentation with clearer guidance on environment variable setup and supported configuration loaders.

The Config struct already carries both envconfig: and env: struct tags on
every field, so services can be loaded with kelseyhightower/envconfig or
any env:-tag loader (caarlos0/env, sethvargo/go-envconfig,
ilyakaznacheev/cleanenv). Surface this in the type doc comment so the
generated README and pkg.go.dev reflect the actual capability.
Copilot AI review requested due to automatic review settings May 4, 2026 15:46
@coderabbitai
Copy link
Copy Markdown

coderabbitai Bot commented May 4, 2026

📝 Walkthrough

Walkthrough

Documentation for the Config type is expanded to clarify environment variable population via both envconfig and env struct tags, with supported loader libraries listed. Source-link references in generated README sections are updated to reflect new code ranges.

Changes

Config Documentation Expansion

Layer / File(s) Summary
Core Documentation
config/config.go
Config package comment expanded to detail environment variable override mechanism, noting both envconfig and env struct tag support with loader examples.
Generated API Reference
config/README.md
Config type description in README clarified with environment variable population details; source-link line references updated to match new config.go ranges.

Estimated code review effort

🎯 1 (Trivial) | ⏱️ ~3 minutes

Poem

🐰 The config docs now shine so bright,
With tags and loaders spelled just right—
Both env and envconfig ways,
Explained in crystal, perfect phrase!
✨ Clarity hops on, hip-hip-hooray!

🚥 Pre-merge checks | ✅ 5
✅ Passed checks (5 passed)
Check name Status Explanation
Description Check ✅ Passed Check skipped - CodeRabbit’s high-level summary is enabled.
Title check ✅ Passed The title 'docs(config): document dual-loader support (envconfig + env-tag)' directly and clearly summarizes the main change: documenting the Config type's support for both envconfig and env-tag loaders.
Docstring Coverage ✅ Passed No functions found in the changed files to evaluate docstring coverage. Skipping docstring coverage check.
Linked Issues check ✅ Passed Check skipped because no linked issues were found for this pull request.
Out of Scope Changes check ✅ Passed Check skipped because no linked issues were found for this pull request.

✏️ Tip: You can configure your own custom pre-merge checks in the settings.

✨ Finishing Touches
📝 Generate docstrings
  • Create stacked PR
  • Commit on current branch
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Commit unit tests in branch docs/dual-loader-tags

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share
Review rate limit: 0/1 reviews remaining, refill in 60 minutes.

Comment @coderabbitai help to get the list of available commands and usage tips.

Copy link
Copy Markdown
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

This PR updates the config.Config type documentation to explicitly state that the struct supports both envconfig:"…" and env:"…" tag-based loaders, and regenerates the generated config API README accordingly.

Changes:

  • Expanded Config doc comment in config/config.go to document dual-loader compatibility and name common compatible libraries.
  • Regenerated config/README.md via make doc, updating the Config paragraph and adjusting GitHub source line anchors.

Reviewed changes

Copilot reviewed 2 out of 2 changed files in this pull request and generated no comments.

File Description
config/config.go Updates the Config type doc comment to document dual envconfig + env tag loader support.
config/README.md Regenerated API reference to reflect the updated Config documentation and updated line anchors.

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

Copy link
Copy Markdown

@coderabbitai coderabbitai Bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Actionable comments posted: 1

🤖 Prompt for all review comments with AI agents
Verify each finding against the current code and only fix it if needed.

Inline comments:
In `@config/config.go`:
- Around line 10-20: Update the package-level comment for the Config type to
avoid overclaiming that it provides "sensible defaults for all fields"; instead
state that the struct is populated from environment variables and relies on
explicit default tags where present and Go zero-values otherwise (e.g., optional
TLS path fields). Keep the note about supporting both `envconfig:"…"` and
`env:"…"` loaders and adjust the sentence that currently mentions "sensible
defaults for all fields" to read something like "zero-values or sensible
defaults" so the documentation for Config accurately reflects how the struct is
populated.
🪄 Autofix (Beta)

Fix all unresolved CodeRabbit comments on this PR:

  • Push a commit to this branch (recommended)
  • Create a new PR with the fixes

ℹ️ Review info
⚙️ Run configuration

Configuration used: defaults

Review profile: CHILL

Plan: Pro

Run ID: f54e779a-0447-41b7-9790-8f966c328a18

📥 Commits

Reviewing files that changed from the base of the PR and between 2964bf5 and 0a548ea.

📒 Files selected for processing (2)
  • config/README.md
  • config/config.go

Comment thread config/config.go
Comment on lines +10 to +20
// Config is the configuration for the Coldbrew server.
// It is populated from environment variables and has sensible defaults for all
// fields so that you can just use it as is without any configuration.
// The following environment variables are supported and can be used to override
// the defaults for the fields.
//
// Each field carries both `envconfig:"…"` and `env:"…"` struct tags, so the
// struct can be populated by either family of loaders:
// - github.com/kelseyhightower/envconfig (the cookiecutter default)
// - any `env:`-tag loader, e.g. github.com/caarlos0/env,
// github.com/sethvargo/go-envconfig, or github.com/ilyakaznacheev/cleanenv
Copy link
Copy Markdown

@coderabbitai coderabbitai Bot May 4, 2026

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

⚠️ Potential issue | 🟡 Minor | ⚡ Quick win

Nudge GoDoc wording to avoid over-claiming “defaults for all fields”.

The comment says the config “has sensible defaults for all fields,” but a few fields appear to rely on Go’s zero-value behavior (no explicit default:"..." tag), e.g. optional TLS path fields. Consider softening this to “zero-values/sensible defaults” to keep the documentation precisely aligned with how loaders behave.

📝 Proposed doc wording tweak
-// It is populated from environment variables and has sensible defaults for all
-// fields so that you can just use it as is without any configuration.
+// It is populated from environment variables. Fields have sensible zero-values
+// (and many include explicit `default:"..."` tags), so you can typically use it
+// without any configuration.
📝 Committable suggestion

‼️ IMPORTANT
Carefully review the code before committing. Ensure that it accurately replaces the highlighted code, contains no missing lines, and has no issues with indentation. Thoroughly test & benchmark the code to ensure it meets the requirements.

Suggested change
// Config is the configuration for the Coldbrew server.
// It is populated from environment variables and has sensible defaults for all
// fields so that you can just use it as is without any configuration.
// The following environment variables are supported and can be used to override
// the defaults for the fields.
//
// Each field carries both `envconfig:"…"` and `env:"…"` struct tags, so the
// struct can be populated by either family of loaders:
// - github.com/kelseyhightower/envconfig (the cookiecutter default)
// - any `env:`-tag loader, e.g. github.com/caarlos0/env,
// github.com/sethvargo/go-envconfig, or github.com/ilyakaznacheev/cleanenv
// Config is the configuration for the Coldbrew server.
// It is populated from environment variables. Fields have sensible zero-values
// (and many include explicit `default:"..."` tags), so you can typically use it
// without any configuration.
// The following environment variables are supported and can be used to override
// the defaults for the fields.
//
// Each field carries both `envconfig:"…"` and `env:"…"` struct tags, so the
// struct can be populated by either family of loaders:
// - github.com/kelseyhightower/envconfig (the cookiecutter default)
// - any `env:`-tag loader, e.g. github.com/caarlos0/env,
// github.com/sethvargo/go-envconfig, or github.com/ilyakaznacheev/cleanenv
🤖 Prompt for AI Agents
Verify each finding against the current code and only fix it if needed.

In `@config/config.go` around lines 10 - 20, Update the package-level comment for
the Config type to avoid overclaiming that it provides "sensible defaults for
all fields"; instead state that the struct is populated from environment
variables and relies on explicit default tags where present and Go zero-values
otherwise (e.g., optional TLS path fields). Keep the note about supporting both
`envconfig:"…"` and `env:"…"` loaders and adjust the sentence that currently
mentions "sensible defaults for all fields" to read something like "zero-values
or sensible defaults" so the documentation for Config accurately reflects how
the struct is populated.

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks for the nudge. I am going to leave this as-is for two reasons:

  1. The "sensible defaults for all fields" wording predates this PR; this change is scoped to documenting dual-loader support, and rewording the rest of the Config doc comment would expand the scope.
  2. The fields without an explicit default:"..." tag (e.g., GRPCTLSCertFile, GRPCTLSKeyFile) rely on zero-values intentionally — empty paths mean "TLS off", which is the sensible default for an optional integration. So the original claim still holds.

Happy to revisit doc-accuracy improvements as a separate PR if useful.

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@ankurs, that's a fair and well-reasoned position — particularly point 2. Empty string for GRPCTLSCertFile/GRPCTLSKeyFile meaning "TLS off by default" is a deliberate and sensible zero-value, so "sensible defaults for all fields" holds true. I'll withdraw the suggestion.


✏️ Learnings added
Learnt from: ankurs
Repo: go-coldbrew/core PR: 89
File: config/config.go:10-20
Timestamp: 2026-05-04T15:53:36.067Z
Learning: In the `go-coldbrew/core` repository (`config/config.go`), fields in the `Config` struct that lack an explicit `default:"..."` tag (e.g., `GRPCTLSCertFile`, `GRPCTLSKeyFile`) rely on Go zero-values intentionally — for example, empty TLS path strings mean "TLS is disabled", which is the correct sensible default for optional integrations. The doc comment "sensible defaults for all fields" is therefore accurate and intentional.

Note: Learnings are effective only in the context of similar code segments. To apply general coding guidelines, please configure review instructions. You can manage existing learnings in the app.

@ankurs ankurs merged commit 9c3fafe into main May 4, 2026
8 checks passed
@ankurs ankurs deleted the docs/dual-loader-tags branch May 4, 2026 15:55
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants