Article Publishing
~ golang code similar to strwrap1
For Delphi KOL/MCK has functions such as Str2File and File2Str, or FileToString and StringToFile, StrLoadFile. Strwrap1.pas has a similar function. Basically it converts a file to a string (instead of loading up a TStringList with create/free code bloat and line noise).

In GoLang, something like this might be the way to obtain the same goal:

func FileToString(filename string) string {
    content, err := ioutil.ReadFile(filename)
    if err != nil {
        fmt.Printf("Problem occurred: %v\n", err)
        return ""
    }
    return string(content)
}

And a StringToFile() function would then use
    ioutil.WriteFile // ...
The function is defined as:
    func WriteFile(filename string, data []byte, perm os.FileMode) error

This may already be implemented somewhere in go code already in library.
TODO: find out (reinventing the wheel).
Copyright © War Strategists, M.G. Consequences 2009-2017    Help! Edit Page