[go-nuts] Re: why would slice = slice[1:] allocate

2020-03-01 Thread so . peter . 05
Jason, Your example does not appear to support your claim. A benchmark: package main import ( "strconv" "testing" ) type A struct { B string } func mycode(slice []A) { slice = slice[1:] } func BenchmarkMycode(b *testing.B) { a := make([]A, 256) for i := range a {

[go-nuts] Re: How to break a long code into lines in Golang?

2017-07-26 Thread so . peter . 05
yihao yang, If you can't use a better name than Int64Flag_xxIntervalMS then at least make the code readable. For example, interval := time.Duration(*Int64Flag_xxIntervalMS) * time.Millisecond time.Sleep(interval - time.Since(timeStart)) Peter On Tuesday, July