WIP Specified header & footer now included in output #6
Loading…
Reference in New Issue
No description provided.
Delete Branch "headers_and_footers"
Deleting a branch is permanent. Although the deleted branch may continue to exist for a short time before it actually gets removed, it CANNOT be undone in most cases. Continue?
While this is functionally complete, it needs further changes. The new functionality:
main()
now creates a list ([]string) of files to processIt's important to note that headers and footers are also processed by the construct/deconstruct functions. This is a bit more flexible, but also is less effort to add in.
This version really mashes types together, changing type fairly often when there might be more appropriate ways to handle the same type. The main issue is that I opted to use strings.Builder to concatenate processed output because I read it was the faster way. This conflicted with the already prevalent use of bytes.Buffer though.
I'll need to do some more reading and thinking before I take another go at this. If you have any advice, feel free to let me know.
This all looks great! I think processing the header and footer with the body like this is the right way to go (rather than formatting them separately before running it all together)
@ -140,3 +140,3 @@
}
defer file.Close()
file.Write(outFile.Bytes())
file.WriteString(outFile)
This is cool. I didnt know io like this had a string method for write. It makes sense that it would... good switch!
Yeah the number of different functions available in the libraries is pretty impressive. I was trying to find out about
func (*file) Write
and saw it two below and was like HMMMM@ -194,2 +195,2 @@
if err != nil {
log.Fatalln("Error while reading file -", err)
//read and process files
var outFile = strings.Builder{}
I prefer strings.Builder these days (to bytes), I had been using bytes, for no particularly good reason, when I started this project.
Ah great, thank you for your advice on this. It explains a fair bit!
I thought about it more and want to avoid changing types as often as it currently is, for the sake of consistency. I'll do a bit more work on this, plus some documentation, and advise when done.
OK I'm pretty happy with this now. All functions that accept or return processed data now do so using a string. strings.StringBuilder is used for those string operations.
Documentation updated to include some information about using the -head and -foot flags.
Awesome! Merging in. This is great :)