Skip to content

Commit

Permalink
Embedded config
Browse files Browse the repository at this point in the history
  • Loading branch information
Artem Yadelskyi committed Jan 30, 2022
1 parent 20f02ce commit 73cdb14
Show file tree
Hide file tree
Showing 3 changed files with 6 additions and 3 deletions.
File renamed without changes.
File renamed without changes.
9 changes: 6 additions & 3 deletions main.go
Original file line number Diff line number Diff line change
@@ -1,6 +1,8 @@
package main

import (
"bytes"
_ "embed"
"fmt"
"os"
"strconv"
Expand All @@ -12,11 +14,12 @@ import (
"github.com/mymmrac/chipper/tests"
)

//go:embed config.yaml
var configData []byte

func main() {
viper.SetConfigName("config")
viper.SetConfigType("yaml")
viper.AddConfigPath(".")
if err := viper.ReadInConfig(); err != nil {
if err := viper.ReadConfig(bytes.NewBuffer(configData)); err != nil {
fmt.Printf("Failed to read config: %v\n", err)
os.Exit(1)
}
Expand Down

0 comments on commit 73cdb14

Please sign in to comment.