-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat: initial documentation and interface thoughts
- Loading branch information
Showing
10 changed files
with
77 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,5 @@ | ||
ifndef GODOCPORT | ||
godoc: GODOCPORT = 8080 | ||
endif | ||
godoc: | ||
godoc -http=:$(GODOCPORT) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,34 @@ | ||
// Package gofig provides a library for loading configuration into a struct type. It also provides | ||
// notification functionality (for parsers supporting it) for when configuration changes whilst the | ||
// application is running, allowing you to hot reload your application when configuration changes. | ||
// | ||
// At it's core Gofig takes no 3rd party dependencies, parsers are implemented as their own sub | ||
// modules, which may take 3rd party dependencies so you only get what you decide to use. | ||
// | ||
// Gofig It aims to provide a simple set of interfaces and API's to make it easy for users to implement | ||
// their own parsers beyond those bundled within the parsers package. | ||
// | ||
// Example. | ||
// | ||
// package main | ||
// | ||
// import ( | ||
// "go.krak3n.codes/gofig" | ||
// "go.krak3n.codes/gofig/parsers/toml" // because why aren't you using TOML? | ||
// ) | ||
// | ||
// type MyConfig struct { | ||
// Foo string `gofig:"foo"` | ||
// Bar string `gofig:"bar"` | ||
// } | ||
// | ||
// func main() { | ||
// var cfg MyConfig | ||
// | ||
// // gofig.Must will panic on error | ||
// fig := gofig.Must(gofig.New(&cfg)) | ||
// gofig.Must(fig.Parse(toml.File("/path/to/my/config.toml"))) | ||
// | ||
// // Use your config | ||
// } | ||
package gofig |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,3 @@ | ||
module go.krak3n.codes/gofig | ||
|
||
go 1.13 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,23 @@ | ||
package gofig | ||
|
||
// Gofig default configuration. | ||
const ( | ||
DefaultStructTag = "gofig" | ||
) | ||
|
||
// A Parser parses configuration. | ||
type Parser interface { | ||
Parse() error | ||
} | ||
|
||
// A Notifier notifies via a channel if changes to configuration have occurred. | ||
// Remember to check the error on the channel. | ||
type Notifier interface { | ||
Notify() <-chan error | ||
} | ||
|
||
// A ParseNotifier can parse config and notify on changes to configuration. | ||
type ParseNotifier interface { | ||
Parser | ||
Notifier | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,3 @@ | ||
module go.krak3n.codes/gofig/parsers/json | ||
|
||
go 1.13 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
package json |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,3 @@ | ||
module go.krak3n.codes/gofig/parsers/toml | ||
|
||
go 1.13 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
package toml |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,3 @@ | ||
module go.krak3n.codes/gofig/parsers/yaml | ||
|
||
go 1.13 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
package yaml |