Skip to content

gopsql/goconf

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

9 Commits
 
 
 
 
 
 
 
 
 
 

Repository files navigation

goconf

Use Go file as config file.

a := struct {
	Foo string `
Lorem ipsum dolor sit amet, consectetur adipiscing elit, sed do eiusmod tempor
incididunt ut labore et dolore magna aliqua.`
	Hello string
}{
	"Bar", "World",
}
c, err := goconf.Marshal(a)
if err != nil {
	panic(err)
}
fmt.Println(string(c))
// Output:
// package config
//
// const (
// 	// Lorem ipsum dolor sit amet, consectetur adipiscing elit, sed do eiusmod tempor
// 	// incididunt ut labore et dolore magna aliqua.
// 	Foo = "Bar"
//
// 	Hello = "World"
// )

For custom data types, Marshal() uses its String() method, Unmarshal() uses its SetString() method.

Examples: