I was perusing the code for the standard log package (src/log/log.go - The 
Go Programming Language <https://golang.org/src/log/log.go?s=7868:7895#L244>) 
and was wondering why the formatHeader method (line 92) takes a pointer to 
byte slice since the only call to this method line (163) calls it with the 
address of its own byte slice member (and it only has one such member).

To be clear, I'm not wondering why formatHeader takes a pointer to a byte 
slice instead of a byte slice--indeed the itoa function above it does this, 
and must do this--but rather why does it need the buffer parameter at all, 
since it's a method and therefore already has access to its buffer.

Is it simply to make the method more general, for possible future changes, 
so that it can format headers using its flag and prefix settings but write 
the header to some other buffer instead of its own?  Or is there a deeper 
design reason that I'm missing?

Please note that I'm not trying to criticize but rather trying to 
understand.  I often look at how code is written in the standard library to 
improve my own code.

William

-- 
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.

Reply via email to