Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/lunixbochs/matter
Frontmatter library for Go (YAML and plaintext)
https://github.com/lunixbochs/matter
Last synced: 3 months ago
JSON representation
Frontmatter library for Go (YAML and plaintext)
- Host: GitHub
- URL: https://github.com/lunixbochs/matter
- Owner: lunixbochs
- License: mit
- Created: 2014-12-31T20:57:04.000Z (almost 10 years ago)
- Default Branch: master
- Last Pushed: 2014-12-31T23:44:27.000Z (almost 10 years ago)
- Last Synced: 2024-06-21T12:49:06.443Z (6 months ago)
- Language: Go
- Homepage:
- Size: 168 KB
- Stars: 0
- Watchers: 3
- Forks: 0
- Open Issues: 1
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
README
[![GoDoc](https://godoc.org/github.com/lunixbochs/matter?status.svg)](http://godoc.org/github.com/lunixbochs/matter)
[![Build Status](https://travis-ci.org/lunixbochs/matter.svg?branch=master)](https://travis-ci.org/lunixbochs/matter)matter
===A Go library for easily reading/writing files with frontmatter.
What is frontmatter?
---Files with YAML frontmatter attached usually look like this:
```
---
key: value
key: value
---
regular file contents.
```Installation
---go get github.com/lunixbochs/matter
Example
---```Go
package mainimport (
"fmt"
"log""github.com/lunixbochs/matter"
)type TestStruct struct {
Example string
KeyTwo string
}var dataTest = []byte("Example data.")
var structTest = &TestStruct{
Example: "Eggs",
KeyTwo: "Ham",
}func main() {
err := matter.WriteYAML("test.yml", structTest, dataTest, 0600)
if err != nil {
log.Fatal(err)
}front := &TestStruct{}
data, err := matter.ReadYAML("test.yml", front)
if err != nil {
log.Fatal(err)
}
fmt.Println(" frontmatter:", front)
fmt.Println(" data:", string(data))
}
```