config

go
package config

import (
  "errors"
  "os"
  "strconv"

Config parsing with env defaults and strict validation

go config reliability
by Leah Thompson 1 tab
rust
use std::env;

fn main() {
    let port: u16 = env::var("PORT")
        .unwrap_or_else(|_| "8080".to_string())
        .parse()

Environment variables with std::env for configuration

rust config environment
by Marcus Chen 1 tab
rust
use serde::{Deserialize, Serialize};

#[derive(Debug, Clone, Serialize, Deserialize)]
pub struct AppConfig {
    #[serde(default)]
    pub server: ServerConfig,

Layered Config Loading From TOML File and Environment Variables in Rust

config serde toml
by codesnips 3 tabs
typescript
import { z } from "zod";

const booleanFromString = z
  .string()
  .transform((v) => v.trim().toLowerCase())
  .pipe(z.enum(["true", "false", "1", "0"]))

Type-Safe Environment Variable Parsing and Validation With Zod

config zod environment
by codesnips 3 tabs
typescript
import { z } from "zod";

const flagValueSchema = z.union([
  z.boolean(),
  z.object({
    rollout: z.number().min(0).max(100),

Typed Feature-Flag Gate with a Zod Config Loader and useFeatureFlag Hook in React

react feature-flags typescript-hooks
by codesnips 3 tabs
typescript
export const FLAG_REGISTRY = {
  newDashboard: {
    default: false as boolean,
    description: 'Renders the redesigned dashboard shell',
  },
  maxUploadMb: {

Feature flags with a typed registry

typescript feature-flags react
by codesnips 3 tabs
go
package flags

import (
  "context"
  "encoding/json"
  "sync/atomic"

Feature flag snapshot with periodic refresh and atomic reads

go config reliability
by Leah Thompson 1 tab
json
{
  "printWidth": 100,
  "tabWidth": 2,
  "semi": true,
  "singleQuote": true,
  "quoteProps": "as-needed",

Prettier config for consistent formatting

tooling prettier formatting
by codesnips 3 tabs
rust
use serde::Serialize;
use serde_json::Value;

#[derive(Debug, Clone, Serialize)]
#[serde(tag = "kind", rename_all = "lowercase")]
pub enum ChangeKind {

Diffing Two Config Snapshots Into a Typed Change List in Rust

rust serde config
by codesnips 3 tabs
go
package config

import (
  "io"

  "gopkg.in/yaml.v3"

Safe YAML decoding (KnownFields) for config files

go config yaml
by Leah Thompson 1 tab
go
package config

import (
  "fmt"
  "os"
  "strconv"

Robust environment parsing for bool/int with explicit defaults

go config reliability
by Leah Thompson 1 tab