Skip to content

Latest commit

 

History

History
162 lines (106 loc) · 2.57 KB

File metadata and controls

162 lines (106 loc) · 2.57 KB

GVM Configuration Guide

Configuration File Location

GVM v2.0.0 uses a configuration file at:

$GVM_ROOT/config/gvm.conf

Typically: ~/.gvm/config/gvm.conf

Configuration Options

GVM_DEFAULT_GO_VERSION

Default Go version to use when no version is specified.

Example:

GVM_DEFAULT_GO_VERSION="go1.21.0"

Default: (empty - uses system default)

GVM_BINARY_BASE_URL

Base URL for downloading Go binaries.

Example:

GVM_BINARY_BASE_URL="https://go.dev/dl"

Default: https://go.dev/dl

Note: Can use a mirror if needed.

GVM_SOURCE_URL

Source repository URL for Go source code.

Example:

GVM_SOURCE_URL="https://github.com/golang/go"

Default: https://github.com/golang/go

GVM_LOG_RETENTION_DAYS

Number of days to retain log files before automatic cleanup.

Example:

GVM_LOG_RETENTION_DAYS="30"

Default: 30

GVM_AUTO_CLEANUP

Enable automatic cleanup of old logs and cache.

Values: true, false

Example:

GVM_AUTO_CLEANUP="true"

Default: true

GVM_CACHE_ENABLED

Enable caching of version lists and metadata.

Values: true, false

Example:

GVM_CACHE_ENABLED="true"

Default: true

GVM_CACHE_TTL

Cache time-to-live in seconds.

Example:

GVM_CACHE_TTL="3600"

Default: 3600 (1 hour)

Editing Configuration

Manual Editing

Edit the configuration file directly:

nano ~/.gvm/config/gvm.conf

Using GVM Functions

In scripts, use configuration functions:

# Get a value
default_version=$(gvm_get_config default_go_version "go1.21.0")

# Set a value
gvm_set_config default_go_version "go1.21.0"

Environment Variables

Environment variables still work and override configuration file values:

export GVM_BINARY_BASE_URL="https://mirror.example.com/go/dl"
export GVM_CACHE_ENABLED="false"

Configuration Priority

  1. Environment variables (highest priority)
  2. Configuration file (gvm.conf)
  3. Default values (lowest priority)

Example Configuration

Complete example gvm.conf:

# GVM Configuration File
# Default Go version
GVM_DEFAULT_GO_VERSION="go1.21.0"

# Download URLs
GVM_BINARY_BASE_URL="https://go.dev/dl"
GVM_SOURCE_URL="https://github.com/golang/go"

# Logging
GVM_LOG_RETENTION_DAYS="30"
GVM_AUTO_CLEANUP="true"

# Caching
GVM_CACHE_ENABLED="true"
GVM_CACHE_TTL="3600"

Reloading Configuration

Configuration is automatically loaded when GVM starts. To reload:

source ~/.gvm/scripts/gvm

Or restart your terminal session.