Skip to content

Instantly share code, notes, and snippets.

@iamsyahidi
Created June 9, 2021 01:55
Library viper usage to read .yaml file
package config
import (
"log"
"github.com/spf13/viper"
)
func GetConfig() {
viper.SetConfigName("App")
viper.SetConfigType("yaml")
viper.AddConfigPath("./configurations")
err := viper.ReadInConfig()
if err != nil {
log.Fatal("config error : ", err.Error())
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment