prettify the config before writing

This commit is contained in:
superwhiskers 2018-04-22 21:35:50 +00:00
parent 54a3e0a528
commit 7d0a52729d
2 changed files with 6 additions and 9 deletions

2
fs.go
View file

@ -266,7 +266,7 @@ func readJSONFile(file string) map[string]interface{} {
func writeJSONFile(file string, data map[string]interface{}) {
// turn go map into valid JSON
fileData, err := json.Marshal(data)
fileData, err := json.MarshalIndent(data, "", " ")
// handle errors
if err != nil {

View file

@ -217,12 +217,12 @@ func doCertGen(config string) {
if enableHTTPS == "y" {
// enable https in the config
configData["https"] = true
configData["config"].(map[string]interface{})["https"] = true
} else if enableHTTPS == "n" {
// keep https disabled
configData["https"] = false
configData["config"].(map[string]interface{})["https"] = false
}
@ -808,7 +808,7 @@ func setup(fileMap map[string]string) {
if method != "4" {
// prettify the JSON
pretty, err := json.MarshalIndent(config, "", " ")
stringifiedConfig, err := json.MarshalIndent(config, "", " ")
// error handling
if err != nil {
@ -822,7 +822,7 @@ func setup(fileMap map[string]string) {
}
// turn it into a string
prettifiedJSON := string(pretty[:])
stringifiedJSON := string(stringifiedConfig[:])
// confirm the preferences
var areSettingsOkay string
@ -842,7 +842,7 @@ func setup(fileMap map[string]string) {
fmt.Printf(" make https work \n")
fmt.Printf(" profit??? \n")
fmt.Printf(" \n")
fmt.Printf(prettifiedJSON)
fmt.Printf(stringifiedJSON)
fmt.Printf("\n \n")
fmt.Printf("-> (y|n) \n")
fmt.Printf("=============================================================\n")
@ -876,9 +876,6 @@ func setup(fileMap map[string]string) {
os.Exit(0)
}
// convert golang map to json
stringifiedConfig, err := json.Marshal(config)
// error handling
if err != nil {