XDG Base Directory Spec

CategoryEnvironment VariableDefault ValueFHS Approximation
Configuration$XDG_CONFIG_HOME$HOME/.config/etc
Data$XDG_DATA_HOME$HOME/.local/share/usr/share
State$XDG_STATE_HOME$HOME/.local/state/var/lib
Cache$XDG_CACHE_HOME$HOME/.cache/var/cache
package main
import (
  "os"
  "fmt"
  "log"
  "path/filepath"
)

func getConfigDir() (string, error) {
  configDir := os.Getenv("XDG_CONFIG_HOME")

  // If the value of the environment variable is unset, empty, or not an absolute path, use the default
  if configDir == "" || configDir[0:1] != "/" {
    homeDir, err := os.UserHomeDir()
    if err != nil {
      return "", err
    }
    return filepath.Join(homeDir, ".config", "my-application-name"), nil
  }

  // The value of the environment variable is valid; use it
  return filepath.Join(configDir, "my-application-name"), nil
}

func main() {
  config_dir, err := getConfigDir()
  if err != nil {
    panic(err)
  }

  fmt.Println(config_dir)
}

whichllm

uvx whichllm@latest


Your Clippy Config Should Be Stricter

# Workspace Cargo.toml

[workspace.lints.clippy]
# Don't Panic - prevent panics from unwraps and unsafe slicing or indexing
string_slice = "warn"
indexing_slicing = "warn"
unwrap_used = "warn"
panic = "warn"
todo = "warn"
unimplemented = "warn"
unreachable = "warn"
get_unwrap = "warn"
unwrap_in_result = "warn"
unchecked_time_subtraction = "warn"
panic_in_result_fn = "warn"
# Optional - see post for caveats
# expect_used = "warn"
# arithmetic_side_effects = "warn"

# Don't Fail Silently - prevent dropped futures and swallowed errors
let_underscore_future = "warn"
let_underscore_must_use = "warn"
unused_result_ok = "warn"
map_err_ignore = "warn"
assertions_on_result_states = "warn"

# Don't Do Bad Async Stuff - prevent deadlocks and concurrency bugs
await_holding_lock = "warn"
await_holding_refcell_ref = "warn"
if_let_mutex = "warn"  # only relevant on editions before 2024
large_futures = "warn"

# Don't Do Unsafe Things with Memory
mem_forget = "warn"
undocumented_unsafe_blocks = "warn"
multiple_unsafe_ops_per_block = "warn"
unnecessary_safety_doc = "warn"
unnecessary_safety_comment = "warn"

# Don't Do Potentially Incorrect Things with Numbers
float_cmp = "warn"
float_cmp_const = "warn"
lossy_float_literal = "warn"
cast_sign_loss = "warn"
invalid_upcast_comparisons = "warn"
# Optional - these effectively force you to document numeric invariants
# cast_possible_wrap = "warn"
# cast_precision_loss = "warn"
# cast_possible_truncation = "warn"

# Don't Do Bad Things That are Easy to Avoid
rc_mutex = "warn"
debug_assert_with_mut_call = "warn"
iter_not_returning_iterator = "warn"
expl_impl_clone_on_copy = "warn"
infallible_try_from = "warn"
dbg_macro = "warn"

# Don't `allow` Your Way Around These Lints - every suppression must be
# a deliberate #[expect(..., reason = "…")] rather than a silent #[allow]
allow_attributes = "warn"
allow_attributes_without_reason = "warn"
# Workspace clippy.toml

allow-indexing-slicing-in-tests = true
allow-panic-in-tests = true
allow-unwrap-in-tests = true
allow-expect-in-tests = true
allow-dbg-in-tests = true