Help us shape the future of Go! Take the 2026 Go Developer Survey

config

package
v0.2.0 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Aug 27, 2026 License: MIT Imports: 2 Imported by: 0

Documentation

Overview

Package config resolves the diff render settings for a session, layering the JJ_DIFF_* environment variables over a set of built-in defaults.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Config

type Config struct {
	ViewMode        ViewModeType
	TabWidth        int
	ShowWhitespace  bool
	ShowLineNumbers bool
	WordLevelDiff   bool
}

Config is the fully resolved settings for a session. Every field has a usable zero-value replacement from DefaultConfig, so callers never build one by hand.

func DefaultConfig

func DefaultConfig() Config

DefaultConfig returns the settings that apply when no environment variable is set: unified layout, line numbers on, whitespace and word-level diff off, tabs four columns wide.

func LoadConfig

func LoadConfig() Config

LoadConfig reads the JJ_DIFF_* environment variables over DefaultConfig. A value that cannot be understood is ignored rather than reported, so the default survives and startup never fails on a typo. Booleans are true only for "1", "true", "yes", or "on", and JJ_DIFF_TAB_WIDTH is honored for 1 to 16.

func (Config) ToRenderOptions

func (c Config) ToRenderOptions() RenderOptions

ToRenderOptions drops the layout choice and keeps the fields that affect a single rendered line.

type RenderOptions

type RenderOptions struct {
	TabWidth        int
	ShowWhitespace  bool
	ShowLineNumbers bool
	WordLevelDiff   bool
}

RenderOptions carries the per-line rendering settings without the layout choice, so a renderer can be handed only what affects a single line of output.

type ViewModeType

type ViewModeType string

ViewModeType selects how the two sides of a diff are laid out.

const (
	ViewModeUnified    ViewModeType = "unified"
	ViewModeSideBySide ViewModeType = "side-by-side"
)

Diff layouts. The string values are also what JJ_DIFF_VIEW_MODE accepts, which is why they are spelled as user-facing words rather than as an int enum.

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL