Skip to content

Commit

Permalink
fix: Use embedded config file
Browse files Browse the repository at this point in the history
  • Loading branch information
anoop2811 committed Jan 7, 2024
1 parent ed5d7cf commit 2770301
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 3 deletions.
8 changes: 6 additions & 2 deletions config/config.go
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
package config

import (
"embed"
"os"

"github.com/go-yaml/yaml"
Expand Down Expand Up @@ -29,8 +30,11 @@ type serverConfig struct {

var configuration *config

func LoadConfig(path string) error {
data, err := os.ReadFile(path)
//go:embed config.yaml
var configPath embed.FS

func LoadConfig() error {
data, err := configPath.ReadFile("config.yaml")
if err != nil {
return err
}
Expand Down
2 changes: 1 addition & 1 deletion main.go
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@ func main() {
}

func initConfig() {
if err := config.LoadConfig("config/config.yaml"); err != nil {
if err := config.LoadConfig(); err != nil {
log.Fatalf("error: %v", err)
}
}
Expand Down

0 comments on commit 2770301

Please sign in to comment.