The gofmt command by default reads from standard input and outputs to standard output. It doesn't need a temporary file.
Alternatively, use the go/ast package to parse Go source and go/printer to pretty print it. - elias On Monday, March 26, 2018 at 7:29:15 PM UTC+2, Darko Luketic wrote: > > How would I use something like gofmt to format a string in memory? > > I wouldn't want to write a temporary file then os.Exec gofmt and re-read > that file. > There has to be a better way. Did anyone do anything like that before? > -- 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. For more options, visit https://groups.google.com/d/optout.