Re: [go-nuts] Does anyone know how to implement dynamic two-dimensional arrays ??

2019-04-20 Thread Marcin Romaszewicz
I fixed your example with some explanatory comments: https://play.golang.org/p/zwt78CPwxk_o package main import ( "fmt" ) func main() { Af(5) } func Af ( N int) { //Initialize outer array, you get an array of 25 nil arrays M := make( [][]uint16, N*N,N*N) for y:=0; y< N; y++ { // Initi

Re: [go-nuts] Does anyone know how to implement dynamic two-dimensional arrays ??

2019-04-20 Thread Burak Serdar
On Sat, Apr 20, 2019 at 11:10 PM wrote: > > Here's the snippet I'm trying to run > > package main > import ( "fmt" ) > > func main() { > Af(5) > } > > func Af ( N int) { > > //var M = new([N][N]uint16) !compiler error > //var M = make([N][N]uint16)!compiler error The above two will not w

[go-nuts] Does anyone know how to implement dynamic two-dimensional arrays ??

2019-04-20 Thread lgodio2
Here's the snippet I'm trying to run package main import ( "fmt" ) func main() { Af(5) } func Af ( N int) { //var M = new([N][N]uint16) !compiler error //var M = make([N][N]uint16)!compiler error //var M = make([][]uint16, N*N) ## run-time error // run-time error M := make( [][]u

[go-nuts] binary.Read cgo fields

2019-04-20 Thread immueggpain
binary.Read can't set unexported fields, right? But my structs are defined in C, and I can't make all C source code using capital fields.. What could I do? -- You received this message because you are subscribed to the Google Groups "golang-nuts" group. To unsubscribe from this group and stop r

[go-nuts] Re: The smaller argument a time.Sleep call takes, the more allocations?

2019-04-20 Thread T L
Ah, yes, it is number of runs. What a silly question. :) On Saturday, April 20, 2019 at 10:37:18 PM UTC+8, Uli Kunitz wrote: > > The first number in the benchmark output provides the number of iterations > the test is run. It has nothing to do with the number of allocations. The > default bench

Re: [go-nuts] The smaller argument a time.Sleep call takes, the more allocations?

2019-04-20 Thread andrey mirtchovski
You need the -benchmem flag to get a report of allocations: $ go test -bench=. -benchmem goos: darwin goarch: amd64 BenchmarkTestSleep_2000-4 1 2005447537 ns/op 456 B/op 3 allocs/op BenchmarkTestSleep_1000-4 1 1001627153 ns/op 64 B/op 1 allocs/op BenchmarkT

[go-nuts] Re: The smaller argument a time.Sleep call takes, the more allocations?

2019-04-20 Thread Uli Kunitz
The first number in the benchmark output provides the number of iterations the test is run. It has nothing to do with the number of allocations. The default benchmark time is 1 second, explaining the number of iterations you are observing. You can change the time using the -benchtime flag. --

[go-nuts] The smaller argument a time.Sleep call takes, the more allocations?

2019-04-20 Thread T L
The following benchmark is modified from https://github.com/golang/go/issues/30802 package main import ( "testing" "time" ) func SleepTest(milliseconds time.Duration) { time.Sleep(time.Millisecond * milliseconds) } func BenchmarkTestSleep_2000(b *testing.B) { for i := 0; i < b.

[go-nuts] Working outside of VCS - parent/child modules

2019-04-20 Thread whitehexagon via golang-nuts
https://github.com/golang/go/wiki/Modules#can-i-work-entirely-outside-of-vcs-on-my-local-filesystem For a simple parent/child module relationship this seems to work, since the 'replace' work-around is in the parent go.mod. But when the childA depends on childB, then the 'replace' directive in