-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
14 changed files
with
70 additions
and
15 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,55 @@ | ||
package main | ||
|
||
import ( | ||
"fmt" | ||
"io/ioutil" | ||
"os" | ||
|
||
"github.com/overtalk/helmsman" | ||
fileSource "github.com/overtalk/helmsman/source/file" | ||
) | ||
|
||
const str = `{ | ||
"A": "this is the test of a ", | ||
"B": "this is the test of bbb" | ||
}` | ||
|
||
type ConfigDemo struct { | ||
A string `json:"A"` | ||
B string `json:"B"` | ||
} | ||
|
||
func GetConfig(path string) (*ConfigDemo, error) { | ||
c := &ConfigDemo{} | ||
fc := fileSource.NewFileConfig(path) | ||
if err := fc.ParseConfig(config.JsonFormat, c); err != nil { | ||
return nil, err | ||
} | ||
|
||
return c, nil | ||
} | ||
|
||
func main() { | ||
// write config data to tmp file | ||
tmpFile, err := ioutil.TempFile("", "temp_file") | ||
if err != nil { | ||
fmt.Println(err) | ||
return | ||
} | ||
defer os.Remove(tmpFile.Name()) // clean up | ||
|
||
// write data to the temp file | ||
if err := ioutil.WriteFile(tmpFile.Name(), []byte(str), 0777); err != nil { | ||
fmt.Println(err) | ||
return | ||
} | ||
|
||
c, err := GetConfig(tmpFile.Name()) | ||
if err != nil { | ||
fmt.Println(err) | ||
return | ||
} | ||
|
||
fmt.Println(c.A) | ||
fmt.Println(c.B) | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,4 +1,4 @@ | ||
module helmsman | ||
module github.com/overtalk/helmsman | ||
|
||
go 1.13 | ||
|
||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,7 +1,7 @@ | ||
package source | ||
|
||
import ( | ||
"helmsman" | ||
"github.com/overtalk/helmsman" | ||
"io/ioutil" | ||
"os" | ||
) | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,7 +1,7 @@ | ||
package github | ||
|
||
import ( | ||
"helmsman" | ||
"github.com/overtalk/helmsman" | ||
"context" | ||
"errors" | ||
|
||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,7 +1,7 @@ | ||
package source | ||
|
||
import ( | ||
"helmsman" | ||
"github.com/overtalk/helmsman" | ||
"errors" | ||
|
||
"github.com/xanzy/go-gitlab" | ||
|