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

settings

package
v0.1.20 Latest Latest
Warning

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

Go to latest
Published: Oct 24, 2026 License: MIT Imports: 9 Imported by: 0

Documentation

Overview

Package settings holds the rules for the settings a mod declares in its manifest: which declarations a build may carry, which values each setting accepts, and the value a player starts with. Hosts without a settings service keep players' values in a File.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func Canonical

func Canonical(setting *settingspb.Setting, value string) (string, bool)

Canonical returns value as the setting holds it and whether the setting accepts it: a choice's value, "true" or "false", or a number from min to max on a step from min.

func Default

func Default(setting *settingspb.Setting) string

Default returns the value a player starts with: the declared default, or the first choice, off or min when the setting declares none.

func Find

func Find(manifest *manifestpb.Manifest, key string) *settingspb.Setting

Find returns the setting named key that manifest declares, or nil.

func Validate

func Validate(manifest *manifestpb.Manifest) error

Validate checks the settings manifest declares.

Types

type File

type File struct {
	// contains filtered or unexported fields
}

File keeps players' settings in memory and, given a path, in a JSON file of settings.StoredSettings, the same file modlock-host keeps. It reads the file when opened and rewrites it on each change. A File is not safe for concurrent use.

func Open

func Open(path string) (*File, error)

Open reads the settings file at path, or starts empty when path is empty or the file does not exist. A file that does not decode starts empty, and the error says why.

func (*File) Store

func (f *File) Store(mod string, steamID uint64, key, value string) error

Store keeps the player's new value of the mod's setting and rewrites the file. The value stays in memory when the file cannot be written.

func (*File) Value

func (f *File) Value(mod string, steamID uint64, key string) (string, bool)

Value returns the value the player chose for the mod's setting and whether one is kept.

Jump to

Keyboard shortcuts

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