Skip to content

Commit

Permalink
add env.go (#10)
Browse files Browse the repository at this point in the history
  • Loading branch information
JunNishimura committed Jul 15, 2023
1 parent 9fb6f4f commit f2a2b0d
Showing 1 changed file with 30 additions and 0 deletions.
30 changes: 30 additions & 0 deletions env.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,30 @@
package main

import (
"fmt"

"github.com/spf13/viper"
)

const (
configPath = "$HOME/.config/chatify"
)

func setEnv() {
// token setting
viper.AddConfigPath(configPath)
viper.SetConfigName("token")
viper.SetConfigType("json")

// client setting
viper.SetConfigName("client")
viper.SetConfigType("yaml")
viper.MergeInConfig()

// load
if err := viper.ReadInConfig(); err != nil {
if _, ok := err.(viper.ConfigFileNotFoundError); ok {
fmt.Println("config file does not exist")
}
}
}

0 comments on commit f2a2b0d

Please sign in to comment.