Re: [go-nuts] Why does Go ignore HTTP_PROXY and HTTPS_PROXY if the proxy address is localhost

2021-04-14 Thread Adrian Ho

On 14/4/21 6:39 am, Orson Cart wrote:

So, to clarify:

1/ I have a proxy (Fiddler) running locally on port 
2/ my /etc/hosts file has an entry as follows: 127.0.0.1 fiddler
3/ My HTTP_PROXY and HTTPS_PROXY environment variables are set to 
http://fiddler:  and https://fiddler: 
 respectively


if I then issue a request via curl then that request is picked up by 
the proxy.
However if I make the same request from my go application, the request 
appears to bypass the proxy and is sent directly. I'm perplexed.


The "Name Resolution" section in https://golang.org/pkg/net/ says:

On Unix systems, the resolver has two options for resolving names. It 
can use a pure Go resolver that sends DNS requests directly to the 
servers listed in /etc/resolv.conf, or it can use a cgo-based resolver 
that calls C library routines such as getaddrinfo and getnameinfo.


By default the pure Go resolver is used, because a blocked DNS request 
consumes only a goroutine, while a blocked C call consumes an operating 
system thread.


That might have some bearing on your problem. To see if it's the case, 
as the page suggests:


export GODEBUG=netdns=cgo   # force cgo resolver


Best Regards,
Adrian

--
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.com.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/golang-nuts/2709afa1-a037-8d3c-3fe0-f469588e3c8e%4003s.net.


Re: [go-nuts] Why does Go ignore HTTP_PROXY and HTTPS_PROXY if the proxy address is localhost

2021-04-13 Thread Adrian Ho

On 14/4/21 6:39 am, Orson Cart wrote:

So, to clarify:

1/ I have a proxy (Fiddler) running locally on port 
2/ my /etc/hosts file has an entry as follows: 127.0.0.1 fiddler
3/ My HTTP_PROXY and HTTPS_PROXY environment variables are set to 
http://fiddler:  and https://fiddler: 
 respectively


if I then issue a request via curl then that request is picked up by 
the proxy.
However if I make the same request from my go application, the request 
appears to bypass the proxy and is sent directly. I'm perplexed.


The "Name Resolution" section of https://golang.org/pkg/net/ says:

On Unix systems, the resolver has two options for resolving names. It 
can use a pure Go resolver that sends DNS requests directly to the 
servers listed in /etc/resolv.conf, or it can use a cgo-based resolver 
that calls C library routines such as getaddrinfo and getnameinfo.


By default the pure Go resolver is used, because a blocked DNS request 
consumes only a goroutine, while a blocked C call consumes an operating 
system thread.


That might have some bearing on your problem. To see if it's the case, 
as the page suggests:


export GODEBUG=netdns=cgo   # force cgo resolver


Best Regards,
Adrian

--
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.com.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/golang-nuts/7c2a779f-90c7-a018-953f-221332e1fec3%4003s.net.


Re: [go-nuts] Re: Contributing to golang based project on github - collaboration best practice

2021-02-03 Thread Adrian Ho

On 3/2/21 2:21 pm, Volker Dobler wrote:

To create a Github PR: git push to your fork (add it as an additional
git remote) and create the PR. The "fork" is just a vehicle for a
Github PR and nothing you do work on (or try to build).

For a concrete example of what Volker's talking about, see the `git` 
commands and general workflow in Homebrew's docs on creating pull 
requests: https://docs.brew.sh/How-To-Open-a-Homebrew-Pull-Request


--
Best Regards,
Adrian

--
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.com.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/golang-nuts/29aa4bcb-5c01-afa7-ee8d-531c0f6c01dc%4003s.net.


Re: [go-nuts] Significance of Mon Jan 2 15:04:05 -0700 MST 2006?

2020-02-29 Thread Adrian Ho
On 28/2/20 5:53 pm, Steve Mynott wrote:
> I was just wondering what was the significance, if any, of the magic
> time layout as used by time.Parse()?
>
Here's my answer from 2015, long before I started learning Go:
https://www.quora.com/Why-is-the-Golang-reference-time-Jan-2-2006-at-3-04pm-MST?share=1


-- 
Best Regards,
Adrian

-- 
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.com.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/golang-nuts/1f6ae4fe-d180-2137-7f5b-ed5ae1843737%4003s.net.


Re: [go-nuts] Re: Question re fcns that return multiple values

2019-08-07 Thread Adrian Ho
On 7/8/19 9:44 PM, lgod...@gmail.com wrote:
> f( g() ) compiles  when g returns exactly the number of args that f()
> requires, but if g() returns only 1/2 that number  f (g(), g() ) wont
> compile !! ...Is this not a Golang absurdity  ??

On the contrary, it's a good example of Go's pragmatism, allowing some
relatively safe syntactic sugar without opening a Pandora's box of
complete generality.

To illustrate Rob Griesemer's point, in his comment that I linked to in
my earlier reply
(https://github.com/golang/go/issues/973#issuecomment-142733515),
consider the following package that's maintained by someone else (your
colleague or an Internet stranger):

===

package mu

func CalcDispersion (in []float64) (variance float64, stddev float64) {
... }

func CalcAvg (in []float64) (sma21 float64, ema21 float64) { ... }

===

Then you use it as follows, assuming a future Go version that allows
"spreading" of multi-valued function returns:

===

v, sd := mu.CalcDispersion(i)

sma, ema := mu.CalcAvg(i)

func delta (a, b float64) float64 { return a-b }

d1 := delta(mu.CalcDispersion(i))

d2 := delta(mu.CalcAvg(i))

func me (variance float64, stddev float64, sma21 float64, ema21 float64)
float64 { ... }

m := me(mu.Alpha(i), mu.Beta(i))

===

All well and fine, until one day, the package interface changes after
some discussion:

===

package mu

func CalcDispersion (in []float64) (variance float64, stddev float64,
range float64) { ... }

func CalcAvg (in []float64) (sma21 float64) { ... }

===

Yes, that's a breaking change, and the Go compiler helpfully screams at
you on every assignment statement ...except the last one. And since the
compiler was silent about that last line, you're almost certainly gonna
miss the HUGE logic error in it...and spend days scratching your head at
the absurd results your program throws up.

-- 
Best Regards,
Adrian

-- 
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.com.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/golang-nuts/504b90aa-afea-02b7-dfd9-eabf9eace9dc%4003s.net.


Re: [go-nuts] Re: Question re fcns that return multiple values

2019-08-06 Thread Adrian Ho
On 6/8/19 10:07 PM, lgod...@gmail.com wrote:
> Here a specific example:
>
> The following compiles and runs as expected
> m1x,m1y := ec.scalarMult(16,28,33)  
> m2x,m2y := ec.scalarMult( 1,28,33)
> rx,ry := ec.add (m1x,m1y, m2x, m2y)
>
>
> However this stmt :    rx,ry= ec.add(ec.scalarMult(16,28,33),
> ec.scalarMult( 1,28,33))  gives the following compiler error ...
>
> # command-line-arguments
> .\ECurve.go:272:14: not enough arguments in call to ec.add
> .\ECurve.go:272:28: multiple-value ec.scalarMult() in single-value context
>
This is a VERY different case than the overly-simplified example you
posted earlier.

Jan Mercl has already posted the part of the Go language spec that
mentions this, so I'll just note that this was raised almost 10 years
ago, and Rob Griesemer explained why it was a Bad Idea to allow it here:
https://github.com/golang/go/issues/973#issuecomment-142733515

-- 
Best Regards,
Adrian

-- 
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.com.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/golang-nuts/422d6f3a-4c79-fd8e-ad50-4d217f37728f%4003s.net.


Re: [go-nuts] Question re fcns that return multiple values

2019-08-05 Thread Adrian Ho
On 6/8/19 11:38 AM, lgod...@gmail.com wrote:
> For f1 defined as func f1(k1, k2, k3 int) (x1, x2 int) {..} 
> and f2 defined as func f2(x,y int)           (xR int)       {..} 
>
> Why does the compiler complain about the call stmt 
> f2 ( f1 (1,2,3)  )   ??
>
It shouldn't. What little you posted is perfectly legal in Go:
https://play.golang.org/p/CHx9_LQCCEx

Something else is wrong with your code, methinks.

-- 
Best Regards,
Adrian

-- 
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.com.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/golang-nuts/52e36d01-3558-e9aa-a71b-808ceb59b2d1%4003s.net.


Re: [go-nuts] Hexadecimal floats

2019-07-26 Thread Adrian Ho
On 26/7/19 9:20 PM, Jan Mercl wrote:
> In a program that generates C, I'm using big.Float.Text
> (https://golang.org/pkg/math/big/#Float.Text) to produce the exact
> value of the C floating point literal. As it turns out, the function
> does not support Inf values. Instead of encoding the exact bits of the
> Inf value, the resulting string is simply "Inf".
>
> I'm looking for possibly existing, open source Go code that does the
> conversion properly both for C floats (Go float32) and C doubles (Go
> float64). So far I was not able to find anything. I can surely roll my
> own code, but I'd very much like to use a well tested code if someone
> can point me to such.
>
> TIA

Section 7.12.4 of the C99 standard says that  defines the
*INFINITY* macro to represent positive infinity, and the way it's
defined in the standard suggests that negative infinity can be
represented by simply negating that constant. Doing it this way works
portably across all standard C compilers and architectures.

Is there a reason you can't simply post-process Text() output to replace
"Inf" with "INFINITY"? That's just a simple "if" test.

-- 
Best Regards,
Adrian

-- 
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.com.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/golang-nuts/b6efb830-e465-fe37-8be4-27233e27d60f%4003s.net.