[go-nuts] Re: Nil Channels and Case Evaluation

2017-12-30 Thread silviucapota
Hi, I think your answer can be found in this section: https://golang.org/ref/spec#SendStmt "Both the channel and the *value expression are evaluated* before communication begins" cheers, silviu On Sunday, 31 December 2017 01:44:31 UTC-5, dc0d wrote: > > Assume there is this select statement:

[go-nuts] Nil Channels and Case Evaluation

2017-12-30 Thread dc0d
Assume there is this select statement: for { select { // ... // ... case rcvd <- first(): } } The rcvd channel will be set to nil or a chan value, by it's own case or other cases. If the rcvd channel is nil, that case should have no effect. But even when rcvd channel is n

[go-nuts] Re: Embedded WebBroser

2017-12-30 Thread Houzuo Guo
Happy new year. Check out this code snippet: https://github.com/HouzuoGuo/laitos/blob/master/browser/renderer.go It uses a PhantomJS that is capable of executing javascript and rendering CSS to render web pages. By running a web server in PhantomJS the code snippet interacts with the live brows

Re: [go-nuts] How to know if interface{} data is nil w/o reflecting?

2017-12-30 Thread Matt Harden
I don't know what you mean by "reference type" - as I understand it, that's not a meaningful phrase in Go. Did you mean "interface"? If so, we store pointers in interfaces all the time in Go. When we set an interface variable i to x, we are semantically making a copy of x and storing it in i. We wo

[go-nuts] Re: private global un-used variable passing compile - is it intended or a bug?

2017-12-30 Thread Vasko Zdravevski
I think this part of the spec explains this behavior as an "implementation restriction": https://golang.org/ref/spec#Variable_declarations Implementation restriction: A compiler may make it illegal to declare a > variable inside a function body >

[go-nuts] Why does http client try to connect via IPv6 address when IPv6 is not enabled on machine

2017-12-30 Thread bryantcall
I've done quite a bit of searching and can't seem to find a definitive answer to my problem. I am periodically seeing errors where my code is doing an http get request to a web service which offers both IPv4 and IPv6 connectivity. My code is running in a docker container without IPv6 enabled o

Re: [go-nuts] Channels vs Callbacks in API

2017-12-30 Thread thepudds1460
On a semi-related note, I think there is a fair amount of wisdom in the "Synchronous Functions" section of the Code Review Comments golang wiki page (including it is not written as an absolute and starts with the word "Prefer"). https://github.com/golang/go/wiki/CodeReviewComments#synchronous-f

[go-nuts] private global un-used variable passing compile - is it intended or a bug?

2017-12-30 Thread leafbebop
Hi all, suddenly I found the code package main import ( "fmt" ) var x=3 func main() { fmt.Println("Hello, playground") } It works fun, which surprised me. I mean, I get the idea that public global variable can be exported so it will not trigger "the declared but not used" error, but

Re: [go-nuts] Re: select is still a little unfair if there are more than 4 cases?

2017-12-30 Thread Michael Jones
I did not mean to encourage a battle about this, and certainly not in the context of channel selection fairness. The top N-bits of the worst LCG would be just fine for selecting among 2^N alternatives. Though unstated, my comment back in October was that it would be nice to have all pseudo-random

Re: [go-nuts] How to know if interface{} data is nil w/o reflecting?

2017-12-30 Thread matthewjuran
Storing a pointer in a reference type seems absurd to me. Matt On Friday, December 29, 2017 at 11:07:31 PM UTC-6, Matt Harden wrote: > > I really wish Go had not chosen to propagate Hoare's billion-dollar > mistake. I do realize it's all tied up with the idea that initialization is > cheap and

[go-nuts] Any "established" code practice for encapsulation

2017-12-30 Thread asaaveri
All: This is mostly for internal i.e. not public struct and interfaces. I have structs but I don't want code to access the fields directly. I want to write some interfaces. I am experimenting with lowercase for struct names and upper case for interface name but hide all accessors. For examp

Re: [go-nuts] Re: select is still a little unfair if there are more than 4 cases?

2017-12-30 Thread Юрий Соколов
Xorshift32 is not faster than PCG32. Xorshift64+ in a sense 2x32 is at least as fast as PCG32, and that is used in a tip. Multiplication used after rng to calculate integer in a range 0<=x написал: It was stated earlier in the thread that tip was using xorshift32+multiplication. I assumed that was

Re: [go-nuts] Embedded WebBroser

2017-12-30 Thread fgergo
Hi Jason, sorry about being slightly OT, though I've seen this on various other lists recently: "...calling simple html and maybe java script?" I'm curious, what do you mean when you write "calling html"? Which mechanism or concept do you mean when "calling html"? thanks, Gergely Födémesi On F

Re: [go-nuts] Re: GoLang dependency -> dep installation Issue , Burrow golang tool issues

2017-12-30 Thread Arun Singh
Thanks, I'll check it out. On Dec 30, 2017 11:15 AM, "Matt Harden" wrote: > It's probably better to install the latest binary from the releases page ( > https://github.com/golang/dep/releases), which is the first > recommendation under Setup. > > On Mon, Dec 11, 2017 at 3:11 AM Arun Singh wrote