reload

package module
v0.0.0-...-2aaeead Latest Latest
Warning

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

Go to latest
Published: Dec 24, 2025 License: BSD-3-Clause Imports: 8 Imported by: 1

Documentation

Index

Examples

Constants

This section is empty.

Variables

View Source
var (
	// Logger collects output that is not covered in error returns.
	Logger *log.Logger = log.New(os.Stderr, "cfg/reload ", 1)
)

Functions

This section is empty.

Types

type Config

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

func New

func New(config *cfg.Config, path string) (*Config, error)

New takes a pointer to cfg.Confg and a path (file or directory) to watch and overwrite the config with the content of whatever file was written to since watching.

func Open

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

Open is a convenience function to Open the file, Load it into a cfg.Config and watch is for reloads.

Example
package main

import (
	"fmt"
	"log"

	"catinello.eu/cfg/reload"
)

func main() {
	f, err := reload.Open("example/test.cfg")
	if err != nil {
		log.Fatal(err)
	}
	defer f.Close()

	// use pointer to cfg.Config
	c := f.Cfg()

	v, err := c.Get("main", "key")
	if err != nil {
		log.Fatal(err)
	}

	fmt.Println(v)
}
Output:

value

func (*Config) Cfg

func (c *Config) Cfg() *cfg.Config

Cfg returns a pointer to the actual data as *cfg.Config.

func (*Config) Close

func (c *Config) Close() error

Close ends the Config-reload.

func (*Config) Hash

func (c *Config) Hash() []byte

Hash returns the file hash (sha3-512) for the last load.

func (*Config) Last

func (c *Config) Last() time.Time

Last returns the last load time.

func (*Config) Path

func (c *Config) Path() string

Path returns the used filesystem path.

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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