hcl

package
v0.5.1 Latest Latest
Warning

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

Go to latest
Published: Dec 13, 2022 License: MIT Imports: 1 Imported by: 0

README

hcl

GoDoc

The hcl package provides a config Decoder that unmarshals values from HCL formatted sources.

Example usage:

import (
    "fmt"

    "github.com/warthog618/config"
    "github.com/warthog618/config/blob"
    "github.com/warthog618/config/blob/decoder/hcl"
    "github.com/warthog618/config/blob/loader/file"
)

func main() {
    c := config.New(blob.New(file.New("config.hcl"), hcl.NewDecoder(),blob.MustLoad()))
    s := c.MustGet("nested[0].string").String()
    fmt.Println("s:", s)
    // ....
}

Note that the HCL parser always converts objects into arrays of objects, even if there is only one instance of the object, hence the need for the indexing of nested, nested[0], in the example above. There is no way to define a single nested object in HCL.

Documentation

Overview

Package hcl provides a HCL format decoder for config.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Decoder

type Decoder struct{}

Decoder provides the Decoder API required by config.Source.

func NewDecoder

func NewDecoder() Decoder

NewDecoder returns a HCL decoder.

func (Decoder) Decode

func (d Decoder) Decode(b []byte, v interface{}) error

Decode unmarshals an array of bytes containing HCL text.

Jump to

Keyboard shortcuts

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