Question about example in effective go document

3 views
Skip to first unread message

zben

unread,
Nov 11, 2009, 9:56:07 PM11/11/09
to golang-nuts
Where does the variable s get its value in this? Should it really be
b?

func (b ByteSize) String() string {
switch {
case s >= YB:
return fmt.Sprintf("%.2fYB", b/YB)
case s >= PB:
return fmt.Sprintf("%.2fPB", b/PB)
case s >= TB:
return fmt.Sprintf("%.2fTB", b/TB)
case s >= GB:
return fmt.Sprintf("%.2fGB", b/GB)
case s >= MB:
return fmt.Sprintf("%.2fMB", b/MB)
case s >= KB:
return fmt.Sprintf("%.2fKB", b/KB)
}
return fmt.Sprintf("%.2fB", b)
}

Ian Lance Taylor

unread,
Nov 12, 2009, 12:25:15 AM11/12/09
to zben, golang-nuts
Um, yes. Thanks. Actually, I see that it has already been fixed.

Ian

Charles Cranston

unread,
Nov 12, 2009, 8:21:00 AM11/12/09
to Ian Lance Taylor, golang-nuts
I was totally floored. Within 10 minutes of posting I got a "good catch" email from Rob!
He said he was going to fix it, and I guess he did.

It's weird getting emails from one of your gods.
"At both ends of the political spectrum, these overly simplified stories resonate with deeper themes of distrust (for the left, it is distrust in the executive branch, for the right, it is distrust in, well, the left). They are easily contrasted with one another, thus feeding into a convenient but inaccurate zero-sum meta-narrative. Day by day, the public receives the message that policy involves a binary choice between black-and-white alternatives with apocalyptic stakes. The net effect is to shrink the political space within which reasonable, sustainable policies might be crafted with bipartisan support."

--Robert Chesney


Charles Cranston
http://web.me.com/ke3he
zb...@umd.edu








Reply all
Reply to author
Forward
0 new messages