file

package module
v1.0.1 Latest Latest
Warning

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

Go to latest
Published: Jun 6, 2026 License: MIT Imports: 8 Imported by: 0

README

bconfig/drivers/file

file is a configuration source driver for the bconfig package. It reads JSON, YAML, and YML files and parses them into hierarchical maps.

Installation

go get github.com/brian-nunez/bconfig/drivers/file

Usage

package main

import (
	"log"

	"github.com/brian-nunez/bconfig"
	"github.com/brian-nunez/bconfig/drivers/file"
)

func main() {
	// Sample yaml file
	// server:
	//   addr: localhost:8080
	cfg, err := bconfig.New(
		file.Source("config.yaml"),
	)
	if err != nil {
		log.Fatal(err)
	}

	addr := cfg.String("server.addr")
	log.Printf("Server address: %s", addr)
}

Documentation

Index

Constants

View Source
const DriverName = "file"

Variables

This section is empty.

Functions

func Source

func Source(path string) bconfig.Source

Source returns a bconfig.Source that loads configuration from the file at path.

Types

type Config

type Config struct {
	// Path is the path to the configuration file.
	Path string
}

func (Config) DriverName

func (Config) DriverName() string

DriverName returns the name of this driver.

Jump to

Keyboard shortcuts

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