Skip to content

ccreater222/yaml-comment

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

2 Commits
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

yaml-comment

quickstart

package main

import (
	"fmt"
	yaml "github.com/ccreater222/yaml-comment"
)

type Test struct {
	Name     string `yaml:"name" head_comment:"head comment"`
	Nickname string `yaml:"nickname" line_comment:"line comment"`
	Age      int    `yaml:"age" foot_comment:"foot comment"`
}

func main() {
	t := Test{
		Name:     "a",
		Nickname: "b",
		Age:      0,
	}
	out, _ := yaml.Marshal(t)
	fmt.Println(string(out))
}

console output:

>go run examples/quickstart.go

name: a
# head comment
nickname: b # line comment
age: 0
# foot comment

About

An experimental pkg to set yaml comment by struct tag

Topics

Resources

License

Stars

Watchers

Forks

Packages

No packages published

Languages