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
corepkgv2
Commits
276fbd05
Commit
276fbd05
authored
6 years ago
by
Ajit Jagtap
Browse files
Options
Downloads
Plain Diff
Merge branch 'InitConfigData' into 'devbranch'
Init config data See merge request
!50
parents
6649debd
33beb087
Branches
Branches containing commit
Tags
Tags containing commit
2 merge requests
!54
Devbranch
,
!50
Init config data
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
configmdl/configmdl.go
+5
-0
configmdl/configmdl.go
configmdl/configmdl_test.go
+8
-0
configmdl/configmdl_test.go
with
13 additions
and
0 deletions
configmdl/configmdl.go
+
5
−
0
View file @
276fbd05
...
...
@@ -13,6 +13,11 @@ func InitConfig(fpath string, config interface{}) (toml.MetaData, error) {
return
toml
.
DecodeFile
(
fpath
,
config
)
}
// InitConfigData initConfig using byte array
func
InitConfigData
(
data
[]
byte
,
config
interface
{})
(
toml
.
MetaData
,
error
)
{
return
toml
.
Decode
(
string
(
data
),
config
)
}
// var config tomlConfig
// InitConfig("../testingdata/testData/config/config.toml", &config)
// fmt.Println(config.Name)
...
...
This diff is collapsed.
Click to expand it.
configmdl/configmdl_test.go
+
8
−
0
View file @
276fbd05
package
configmdl
import
(
"io/ioutil"
"testing"
"corelab.mkcl.org/MKCLOS/coredevelopmentplatform/corepkgv2/errormdl"
...
...
@@ -21,6 +22,13 @@ func TestInitConfig(t *testing.T) {
assert
.
True
(
t
,
config
.
Name
==
"github.com/OneOfOne/xxhash"
,
"this should not throw error"
)
}
func
TestInitConfigData
(
t
*
testing
.
T
)
{
var
config
tomlConfig
ba
,
_
:=
ioutil
.
ReadFile
(
"../testingdata/testData/config/config.toml"
)
InitConfigData
(
ba
,
&
config
)
assert
.
True
(
t
,
config
.
Name
==
"github.com/OneOfOne/xxhash"
,
"this should not throw error"
)
}
func
TestSaveConfig
(
t
*
testing
.
T
)
{
var
config
tomlConfig
InitConfig
(
"../testingdata/testData/config/config.toml"
,
&
config
)
...
...
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