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

2018-05-08 Thread Ian Lance Taylor
On Tue, May 8, 2018 at 6:17 PM, Michael Cohen wrote: > > It seems to me that the compiler should at least warn when someone is > comparing an interface to nil (or maybe the linter should warn). It does not > seem that this could ever be what you actually want and it is always a > subtle bug just w

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

2018-05-08 Thread Michael Cohen
Thanks Ian for the thorough explanation - again I apologize for asking noob questions :-). The issue in this case was this error: panic: value method github.com/shirou/gopsutil/process.Process.String called using nil *Process pointer which seems to be coming from the go runtime itself. Certainly

[go-nuts] Re: multiple vendored x/net causing trouble (x/net/trace panic)

2018-05-08 Thread Michael Andersen
I have also been bugged by this several times and been forced to use dep (which works). This is the only package that I have had problems with (other than cgo symbols colliding, which is a similar problem). On Monday, May 7, 2018 at 10:05:19 PM UTC-7, Alex Buchanan wrote: > > This panic has caus

Re: [go-nuts] Go could really use a while statement

2018-05-08 Thread 'Bryan Mills' via golang-nuts
On Thursday, May 3, 2018 at 4:25:34 AM UTC-4, rog wrote: > > FWIW, the thing I miss sometimes is the equivalent of C's: > > while((x = next()) != nil) { > something() > } > > In Go you need to do either: > > for x = next(); x != nil; x = next() { > something()

Re: [go-nuts] [reflect] the type of the return value from reflect.Value.Call() is different

2018-05-08 Thread Ian Lance Taylor
On Sat, May 5, 2018 at 10:02 AM, wrote: > I found that > > If a function returns interface{} > Try to invoke it through reflect.Value.Call() > The type of return value will be a pointer > > For example: (https://play.golang.org/p/gyimxUzUVYf) > package main > > import ( > "fmt" > "reflect" > ) >

[go-nuts] Busted auth providers

2018-05-08 Thread jwinters
It seems like `https://www.gitlab.com` needs to be added to the list of busted auth providers in golang/oauth2. Instead of maintaining a list of these providers, can we just send the `client_id` and `client_secret` in both the auth header and the body with every request? -- You received this

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

2018-05-08 Thread Ian Lance Taylor
On Tue, May 8, 2018 at 7:19 AM, Michael Cohen wrote: > > Well no - the error I get is that I am attempting to call String() method on > a null receiver - so the caller just passed me a regular nil object. The > issue is that I am trying to make a generic polymorphic function which > should be able

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

2018-05-08 Thread Jakob Borg
> On 8 May 2018, at 16:19, Michael Cohen wrote: > > Well no - the error I get is that I am attempting to call String() method on > a null receiver - so the caller just passed me a regular nil object. They passed you a totally legit fmt.Stringer which then panicked when you called String() on

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

2018-05-08 Thread Michael Cohen
Well no - the error I get is that I am attempting to call String() method on a null receiver - so the caller just passed me a regular nil object. The issue is that I am trying to make a generic polymorphic function which should be able to handle whatever is thrown at it - so I guess reflect is nece

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

2018-05-08 Thread Jakob Borg
On 8 May 2018, at 15:26, scude...@gmail.com wrote: But this crashes when foo is really a nil pointer to a type which does support Stringer. The crash isn’t on “your” side though, it’s presumably inside the String() method. Hence, the caller passed you something invalid

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

2018-05-08 Thread scudette
In my case, being a new go learner the following bit of code stumped me. I am receiving a interface{} value and I am trying to figure out the best way to print it. If the value supports the fmt.Stringer() interface then I want to use that, otherwise i can do some other things. So I came up with

Re: [go-nuts] globals defined by stringer utility

2018-05-08 Thread Mark Nahabedian
Thanks Rob. I wasn't concerned with the format if the code but of the (admittedly unlikely) chance that other code could accidentally collide with those globals. On May 8, 2018 2:35 AM, Rob Pike wrote: I don't see that it matters much either way. It's clean enough as it is. It's generated co

Re: [go-nuts] Re: go 1 on Ubuntu 18.04

2018-05-08 Thread Jesper Louis Andersen
On Tue, May 8, 2018 at 9:43 AM Dave Cheney wrote: > Please allow me to clarify, anyone other than Jan never needs to set > GOROOT. > > While I do agree with this advice, it unfortunately doesn't teach people as to why it is a bad idea to set GOROOT, and what kinds of troubles you are likely to ru

Re: [go-nuts] Re: go 1 on Ubuntu 18.04

2018-05-08 Thread Wojciech S. Czarnecki
On Tue, 08 May 2018 06:52:06 + Jan Mercl <0xj...@gmail.com> wrote: > On Mon, May 7, 2018 at 10:02 PM Dave Cheney wrote: > > > Top tip: you never need to set GOROOT. Please don’t set GOROOT, it’ll > just cause confusing errors for you in the future. > > The formulation quoted above is not

Re: [go-nuts] Re: go 1 on Ubuntu 18.04

2018-05-08 Thread Jan Mercl
On Tue, May 8, 2018 at 9:43 AM Dave Cheney wrote: > Please allow me to clarify, anyone other than Jan never needs to set GOROOT. In the absence of the proof to the contrary, please let me note that the above quoted is not correct ;-) -- -j -- You received this message because you are sub

Re: [go-nuts] Re: go 1 on Ubuntu 18.04

2018-05-08 Thread Dave Cheney
Please allow me to clarify, anyone other than Jan never needs to set GOROOT. -- 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 golang-nuts+unsubscr...@googlegroups