Re: [go-nuts] Shuffle Items in a Slice

2016-06-26 Thread Martin Geisler
On Fri, Jun 24, 2016 at 2:54 PM, Val wrote: > The playground caches everything, so running multiple times the same program > will just serve the previously generated output. Thanks, that's good to know! Makes a lot of sense too. > Also in the playground everything is frozen at some point in the

Re: [go-nuts] Re: Shuffle Items in a Slice

2016-06-26 Thread Martin Geisler
Hi Val On Fri, Jun 24, 2016 at 2:48 PM, Val wrote: > 2 implementations here : > http://www.programming-idioms.org/idiom/10/shuffle-a-list/1564/go > > As for the map iteration trick, the runtime doesn't guarantee to randomize > anything, although it often tries to, so developers don't rely on some

Re: [go-nuts] Re: Trouble querying REST API with net/http (api verified working with curl)

2016-06-26 Thread Kiki Sugiaman
I know this is a bit late, so perhaps you don't care anymore... Anyway, the server may not understand the "Get" method in this line: |req, err := http.NewRequest("Get", "https://"+host+".here.com:443/rest/json/flows";, nil) | On 27/06/16 08:22, mark mellar wrote: For anyone else having simila

Re: [go-nuts] Append to slice... what happens?

2016-06-26 Thread Dan Kortschak
On Mon, 2016-06-27 at 07:49 +0200, Martin Geisler wrote: > BTW, I was about to say that you could simplify the line one step > further with > > b := append(a[::len(a)], 3, 4) > > but that gives a compilation error: > > prog.go:11: middle index required in 3-index slice > > I wonder what the

Re: [go-nuts] Append to slice... what happens?

2016-06-26 Thread Martin Geisler
On Mon, Jun 27, 2016 at 12:34 AM, Jan Mercl <0xj...@gmail.com> wrote: > On Mon, Jun 27, 2016 at 12:26 AM Peter Kleiweg wrote: > >> I don't know what I expected, but it's weird. Don't mess with slices. > > Well, working as expected, considering slice backing array is possibly > shared wrt the resul

Re: [go-nuts] Append to slice... what happens?

2016-06-26 Thread Martin Geisler
Hi Henry, On Mon, Jun 27, 2016 at 3:55 AM, Henry wrote: > If you were to change the code a bit as follows > https://play.golang.org/p/VwtWRQBrEe , it will work as you expect. > > I think it is probably safer to instantiate a slice without specifying the > initial capacity. Having the capacity

[go-nuts] Re: Gomobile: Large .so/aar file size on Android

2016-06-26 Thread rajiivkanchan
Thanks for the response. We went ahead and re-wrote the Golang part in Java. Did not get a chance to test your suggestions. Thanks for your suggestions. On Monday, June 20, 2016 at 9:33:57 PM UTC+5:30, nsa...@gmail.com wrote: > > Did you try the beta > https://groups.google.com/forum/#!topic/g

[go-nuts] Re: Getting a pointer in a type switch gives a *interface {} if case lists several options

2016-06-26 Thread Constantin Konstantinidis
This is (old) documented issue https://github.com/golang/go/issues/460 related to multiple values in one case of the switch. On Sunday, June 26, 2016 at 5:40:55 PM UTC+2, Constantin Konstantinidis wrote: > > A part of the answer is in the specifications as the method set is > inherited from the

Re: [go-nuts] Is it safe enough to read uint without lock/atomic operation?

2016-06-26 Thread Jan Mercl
On Mon, Jun 27, 2016 at 5:44 AM 苏沛 wrote: Data race occurs when there are concurrent accesses to the same memory and at least one of them is a write. Channel capacity is never written to after a chan is created. -- -j -- You received this message because you are subscribed to the Google Group

[go-nuts] Is it safe enough to read uint without lock/atomic operation?

2016-06-26 Thread 苏沛
https://github.com/golang/go/blob/master/src/runtime/chan.go#L655 func reflect_chancap(c *hchan) int { if c == nil { return 0 } return int(c.dataqsiz) } -- 苏沛 -- You received this message because you are subscribed to the Google Groups "golang-nuts" gr

Re: [go-nuts] Append to slice... what happens?

2016-06-26 Thread Henry
If you were to change the code a bit as follows https://play.golang.org/p/VwtWRQBrEe , it will work as you expect. I think it is probably safer to instantiate a slice without specifying the initial capacity. -- You received this message because you are subscribed to the Google Groups "golang

Re: [go-nuts] russian language books about Go

2016-06-26 Thread adonovan via golang-nuts
On Friday, 24 June 2016 03:10:56 UTC-4, Oleg Puchinin wrote: > > Hello ! > Where I can find subject ? > Hi Oleg, our book The Go Programming Language (gopl.io) is now available in Russian, thanks to Williams Press: http://www.williamspublishing.com/Books/978-5-8459-2051-5.html The ozon.ru site

[go-nuts] Webcam

2016-06-26 Thread JM
I searched the forum and there were a few posts but they were old. Looking for any updates I'm looking for a way to take a photo from my default webcam via code. I am using ComandCam now with exec.Command and it works fine, but it takes 3 seconds for each photo if i loop though and keep taking

Re: [go-nuts] Re: Any keyboard players here?

2016-06-26 Thread Daniel Skinner
Finally have a place to setup my keyboard and tgui-harm worked well, nice work. On Sun, Jun 26, 2016 at 3:25 AM wrote: > Hi Daniel, > > I already investigated your piano and snd projects at github, but could > not get them working: too much unknown libraries. Anyhow, it seemed to be > aiming at

Re: [go-nuts] Append to slice... what happens?

2016-06-26 Thread Jan Mercl
On Mon, Jun 27, 2016 at 12:26 AM Peter Kleiweg wrote: > I don't know what I expected, but it's weird. Don't mess with slices. Well, working as expected, considering slice backing array is possibly shared wrt the result of append. (Or other slice op, b/c slices _are_ values.) However, it's easy

[go-nuts] Append to slice... what happens?

2016-06-26 Thread Peter Kleiweg
This: https://play.golang.org/p/AE670rTMpE I don't know what I expected, but it's weird. Don't mess with slices. -- 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

[go-nuts] Re: Trouble querying REST API with net/http (api verified working with curl)

2016-06-26 Thread mark mellar
For anyone else having similar issues, I found I was able to work around this by using client.Get() rather than client.Do(). Still not sure what the root cause is though... Cheers. On Friday, June 24, 2016 at 7:32:36 AM UTC+1, mark mellar wrote: > > Good tip on using httputil to inspect the req

Re: [go-nuts] Where is .gosymtab in go binaries with cgo?

2016-06-26 Thread Ian Lance Taylor
On Sun, Jun 26, 2016 at 1:28 PM, Tamás Gulácsi wrote: > > 2016. június 26., vasárnap 21:42:15 UTC+2 időpontban Ian Lance Taylor a > következőt írta: >> >> On Sun, Jun 26, 2016 at 12:18 AM, Tamás Gulácsi >> wrote: >> > I want to find out the source package's given the binary. >> > >> > github.com/

[go-nuts] Re: formal verification in Go? someday perhaps?

2016-06-26 Thread wsc
I think a better question is: can go tools for formal verification become available? The distinction is that formal verification tools can be applied to hardware, protocols, assembly, software, etc. Why not do that in go? Most such tools are in C or C++, and the low level engines/components

Re: [go-nuts] Where is .gosymtab in go binaries with cgo?

2016-06-26 Thread Tamás Gulácsi
2016. június 26., vasárnap 21:42:15 UTC+2 időpontban Ian Lance Taylor a következőt írta: > > On Sun, Jun 26, 2016 at 12:18 AM, Tamás Gulácsi > wrote: > > I want to find out the source package's given the binary. > > > > github.com/FiloSottile/gorebuild (and github.com/rjeczalik/which) works

Re: [go-nuts] Unused var written in closure

2016-06-26 Thread Ian Lance Taylor
On Sat, Jun 25, 2016 at 12:34 PM, Val wrote: > Hello > It seems that this code doesn't compile : > > func main() { > var err error > err = f() > } > > prog.go:8: err declared and not used > > > but this one does : > > func main() { > var err error > g := func() { > err = f(

Re: [go-nuts] Where is .gosymtab in go binaries with cgo?

2016-06-26 Thread Ian Lance Taylor
On Sun, Jun 26, 2016 at 12:18 AM, Tamás Gulácsi wrote: > I want to find out the source package's given the binary. > > github.com/FiloSottile/gorebuild (and github.com/rjeczalik/which) works fine > with binaries built with the "go" tool. > But fails if cgo (and thus I think gcc) is included in the

Re: [go-nuts] Custom syscall.Sockaddr

2016-06-26 Thread Elliot Morrison-Reed
I added the SockaddrCAN type to the golang.org/x/sys/unix package, and it works great. I create an issue with links the patch and some test code. https://github.com/golang/go/issues/16188 On Fri, Jun 24, 2016 at 8:57 PM, Elliot Morrison-Reed wrote: > SocketCAN has been part of mainline linux s

[go-nuts] golang subnet calculation.

2016-06-26 Thread hellobhaskar
Hello I have a requirement to take a supernet ("10.0.0.0/8") and split it into small subnets say /24 size. is there any library which i can use ? in python netaddr has useful routines which i can use to do the same on a side note any one aware of open source IPAM suite written in golang. -- Y

[go-nuts] Difference between gowalker.org and godoc.org

2016-06-26 Thread DM
Can some one please explain me the difference between gowalker.org and godoc.org? I have viewed this thread . But that seems to be little old. -- You received this message because you a

[go-nuts] Re: Getting a pointer in a type switch gives a *interface {} if case lists several options

2016-06-26 Thread Constantin Konstantinidis
A part of the answer is in the specifications as the method set is inherited from the type https://golang.org/ref/spec#Method_sets On Wednesday, June 22, 2016 at 12:02:02 AM UTC+2, raido...@gmail.com wrote: > > I have encountered some unexpected and inconsistent behavior with type > switches. C

[go-nuts] Re: Unused var written in closure

2016-06-26 Thread Val
If such an implicit closure struct is implicitly what happens under the hood, then this is a very good explanation of the behavior. And indeed taking the address of err is regarded as a use . Thanks Andrew, thanks folks! On Sunday, June 26, 2016 at 3:49:51 P

[go-nuts] Re: Unused var written in closure

2016-06-26 Thread Andrew Mezoni
>> If you set the var statement outside the main func, the issue is gone because err is then a "global" var. Not quite correct. This is how it work and why `err` is used: package main import "fmt" type closure03 struct { err *error f func() error } func (c *closure03) fn() {

[go-nuts] Re: Unused var written in closure

2016-06-26 Thread Constantin Konstantinidis
The official statement is here https://golang.org/doc/faq#unused_variables_and_imports Compiling methods details are slightly above. On Sunday, June 26, 2016 at 3:15:15 PM UTC+2, Hotei wrote: > > > > On Saturday, June 25, 2016 at 3:34:57 PM UTC-4, Val wrote: >> >> Hello >> It seems that this code

[go-nuts] Re: Unused var written in closure

2016-06-26 Thread Hotei
On Saturday, June 25, 2016 at 3:34:57 PM UTC-4, Val wrote: > > Hello > It seems that this code doesn't > compile : > > func main() { > var err error > err = f() > } > > *prog.go:8: err declared and not used* > > > but this one

Re: [go-nuts] Getting a pointer in a type switch gives a *interface {} if case lists several options

2016-06-26 Thread raidopahtma
Yeah, the way I needed it was to pass a pointer of the correct type and have a value stored there. The problem is that when passing a pointer to an interface, it seems that the function is unable to figure out where that pointer points to (I guess there is an additional step of reflection needed

[go-nuts] Re: Unused var written in closure

2016-06-26 Thread Andrew Mezoni
But what you want if it (`err`) really not used in your example? func main() { var err error err = f() } -- 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

Re: [go-nuts] Re: Unused var written in closure

2016-06-26 Thread 'Murat Knecht' via golang-nuts
While that fixes the compile issue, the question remains: ‘Is the function binding regarded as a "use"?’ I, too, am interested in understanding *why* the compiler declares this closure non-usage as “fine”. On 06/26/2016 07:28 PM, Constantin Konstantinidis wrote: > If you set the var statement ou

[go-nuts] Re: Unused var written in closure

2016-06-26 Thread Constantin Konstantinidis
If you set the var statement outside the main func, the issue is gone because err is then a "global" var. Setting var inside main makes it a local "unused" var. If the returning code must be discarded then _ = f() also solves the issue. Regards, On Saturday, June 25, 2016 at 9:34:57 PM UTC+2, Va

Re: [go-nuts] Re: Any keyboard players here?

2016-06-26 Thread Daniel Skinner
I made some updates to the example and will make some more. I have some "text" stuff I'm in the middle of working on, but for the sake of moving things along, here's a sample of individual keys. https://drive.google.com/file/d/0B6hxg-gC2Uz_WXlyeno2YUo4Z00/view I did cheat a little by ignoring how

[go-nuts] Where is .gosymtab in go binaries with cgo?

2016-06-26 Thread Tamás Gulácsi
I want to find out the source package's given the binary. github.com/FiloSottile/gorebuild (and github.com/rjeczalik/which) works fine with binaries built with the "go" tool. But fails if cgo (and thus I think gcc) is included in the build procedure. A minimal example is attached to https://git