Hi I have an application that I wrote that uses JSON for the config file. 
The application is a chatbot I use internally and allows users to run linux 
commands to get information both locally and via ssh. The chatbot interface 
uses basic html to render the output so 90% of the time I want to have the 
output be surrounded by "<pre>" and "</pre>". But not every one running the 
application may want this, their chatbot may run a commands that that uses 
other HTML formatting. So I created a directive in the config file allowing 
the user to configure this:

        "HTMLFormat": {
                "Start": "<pre>",
                "Finish": "</pre>"
        }

The problem is that this config file also contains a password -- so I allow 
the user to put in clear text the password, and on restart the password 
gets encrypted, and then I do a simple json.Marshal and rewrite the config 
with the encrypted password:

            file, err := json.MarshalIndent(config, "", "   ")
            errorHandle(err, "Json Marshal", false)
            err = ioutil.WriteFile(cFile, file, 0644)
            errorHandle(err, "Write Config", false)

In the above, 'config' is the struct that contains all the directive, 
'cFile' is the config file being written.  When the file gets written it 
looks like this:
 has toIn the json there is a directive for the application to add html 
formatting to the start of its output.

        "HTMLFormat": {
                "Start": "\u003cpre\u003e",
                "Finish": "\u003e\/pre\u003e"
        }

Any idea why it's doing this?

-- 
You received this message because you are subscribed to the Google Groups 
"golang-nuts" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to golang-nuts+unsubscr...@googlegroups.com.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/golang-nuts/8a7a344a-55aa-468a-8346-c1db036d8372%40googlegroups.com.

Reply via email to