https://github.com/lwch/yaml
yaml support include
https://github.com/lwch/yaml
Last synced: 2 months ago
JSON representation
yaml support include
- Host: GitHub
- URL: https://github.com/lwch/yaml
- Owner: lwch
- License: mit
- Created: 2021-10-09T03:46:12.000Z (over 3 years ago)
- Default Branch: main
- Last Pushed: 2022-07-11T08:43:04.000Z (almost 3 years ago)
- Last Synced: 2025-01-03T17:26:00.023Z (4 months ago)
- Language: Go
- Size: 6.84 KB
- Stars: 0
- Watchers: 2
- Forks: 1
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
README
# yaml
yaml support include
## render
str, _ := yaml.Render("test/main.yaml")
fmt.Println(str)render result:
includes:
#include /home/lwch/src/yaml/test/include.d/*.yaml
#+++++ /home/lwch/src/yaml/test/include.d/include.yaml +++++
next:
#include /home/lwch/src/yaml/test/next.yaml
#+++++ /home/lwch/src/yaml/test/next.yaml +++++
title: next
#----- /home/lwch/src/yaml/test/next.yaml -----
#----- /home/lwch/src/yaml/test/include.d/include.yaml -----the relative path will convert to absolute path by current file path
## decode
var ret struct {
Includes struct {
Next struct {
Title string `yaml:"title"`
} `yaml:"next"`
} `yaml:"includes"`
}
_ := yaml.Decode("test/main.yaml", &ret)
fmt.Println(ret)