-
Notifications
You must be signed in to change notification settings - Fork 0
/
main.go
74 lines (59 loc) · 1.97 KB
/
main.go
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
/*
*/
package main
import (
"context"
"fmt"
"os"
"github.com/senzing-garage/go-helpers/jsonutil"
"github.com/senzing-garage/go-helpers/settings"
)
func main() {
if len(os.Args) > 2 && os.Args[1] == "-j" {
args := os.Args[2:]
for _, jsonText := range args {
normalized, err := jsonutil.Normalize(jsonText)
failOnError(err)
normSorted, _ := jsonutil.NormalizeAndSort(jsonText)
fmt.Println("- - - - - - - - - - - - - - - - - - - - ")
fmt.Println(normalized)
fmt.Println()
fmt.Println(normSorted)
fmt.Println()
}
return
}
ctx := context.TODO()
// ------------------------------------------------------------------------
// --- Build JSON from environment variables.
// ------------------------------------------------------------------------
iniParams, err := settings.BuildSimpleSettingsUsingEnvVars()
failOnError(err)
fmt.Println(iniParams)
// ------------------------------------------------------------------------
// --- Verify parameters
// ------------------------------------------------------------------------
err = settings.VerifySettings(ctx, iniParams)
failOnError(err)
// ------------------------------------------------------------------------
// --- Build JSON from map of key/values.
// ------------------------------------------------------------------------
attributeMap := map[string]string{
"licenseStringBase64": "8BD296A26F2034AAB436045...",
"senzingDirectory": "/path/to/senzing",
"configPath": "/another/path/for/config",
"resourcePath": "/yet/another/path/to/resources",
"supportPath": "/final/path/to/support",
}
iniParams2, err := settings.BuildSimpleSettingsUsingMap(attributeMap)
failOnError(err)
fmt.Println(iniParams2)
}
// ----------------------------------------------------------------------------
// Internal methods
// ----------------------------------------------------------------------------
func failOnError(err error) {
if err != nil {
panic(err.Error())
}
}