Thanks to visit codestin.com
Credit goes to github.com

Skip to content

henriquemps/gyaml

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

17 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

GYAML

gyaml is a Go library for parsing and unmarshaling YAML files into Go structs. It supports loading data from files or directly from strings.

Features

  • YAML parsing and reading
  • Support for nested structures
  • Automatic value conversion
  • Array handling

Installation

To install the library, use:

go get github.com/henriquemps/gyaml

Usage

Example 1: Reading YAML from a file

package main

import (
    "fmt"
    "log"
    "github.com/henriquemps/gyaml"
)

type Config struct {
    Version string `yaml:"version"`
    App struct {
        Name string `yaml:"name"`
    } `yaml:"app"`
}

func main() {
    var config Config
    gyaml.FUnmarshal(&config, "config.yaml")
    fmt.Println("App Name:", config.App.Name)
}

Example 2: Reading YAML from a raw string

package main

import (
    "fmt"
    "log"
    "github.com/henriquemps/gyaml"
)

type Config struct {
    Version string `yaml:"version"`
    App struct {
        Name string `yaml:"name"`
    } `yaml:"app"`
}

func main() {
    yamlContent := `
    version: 1.0.0
    app:
      name: SampleApp
    `

    var config Config
    gyaml.Unmarshal(&config, yamlContent)
    fmt.Println("App Name:", config.App.Name)
}

Main Functions

FUnmarshal(dt any, path string)

Loads a YAML file and deserializes its content into a Go struct.

Unmarshal(dt any, v string)

Reads and processes a YAML provided as a string.

License

This project is licensed under the MIT license. See the LICENSE file for more details.

About

Modulo YAML para GO

Resources

License

Stars

Watchers

Forks

Packages

No packages published

Languages