Skip to content
GitLab
Explore
Projects
Groups
Topics
Snippets
Projects
Groups
Topics
Snippets
/
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
Menu
MKCLOS
Core Development Platform
coreospackage
Commits
6adf24d5
Commit
6adf24d5
authored
7 years ago
by
Sandeep S. Shewalkar
Browse files
Options
Downloads
Plain Diff
Merge branch 'stagingbranch' into 'master'
uncommented the code See merge request
!15
parents
ad42299b
6babf86b
1 merge request
!15
uncommented the code
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
confighelper/configHelper.go
+15
-12
confighelper/configHelper.go
with
15 additions
and
12 deletions
confighelper/configHelper.go
+
15
−
12
View file @
6adf24d5
package
confighelper
import
(
"fmt"
"github.com/spf13/viper"
)
//InitViper function to initialize viper
func
InitViper
()
{
//
viper.SetConfigName("config") // name of config file (without extension)
//
viper.AddConfigPath(".") // optionally look for config in the working directory
//
err := viper.ReadInConfig()
//
//
Find and read the config file
//
if err != nil { // Handle errors reading the config file
//
panic(fmt.Errorf("Fatal error config file %s ", err))
//
}
viper
.
SetConfigName
(
"config"
)
// name of config file (without extension)
viper
.
AddConfigPath
(
"."
)
// optionally look for config in the working directory
err
:=
viper
.
ReadInConfig
()
// Find and read the config file
if
err
!=
nil
{
// Handle errors reading the config file
panic
(
fmt
.
Errorf
(
"Fatal error config file %s "
,
err
))
}
}
//GetConfig method to get configs from config file
func
GetConfig
(
keyName
string
)
string
{
// keyValue := viper.GetString(keyName)
// return keyValue
return
""
keyValue
:=
viper
.
GetString
(
keyName
)
return
keyValue
}
This diff is collapsed.
Click to expand it.
Preview
0%
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Save comment
Cancel
Please
register
or
sign in
to comment
Menu
Explore
Projects
Groups
Topics
Snippets