Re: [go-nuts] net/http: get does not work

2018-04-20 Thread John Shahid

Is any of the following set `HTTPS_PROXY', `HTTP_PROXY' ? The
DefaultTransport pays attention to those env vars to decide whether to
use a proxy or not. If that's not the case, what is the error that
you're getting ?

cheers,

-js

yyq2...@gmail.com writes:

> http.Get doesn't work with default transport, but works fine if I set a 
> custom as following(uncomment the two lines)
>
> package main
>
> import (
>   "net/http"
>   "io/ioutil"
>   "fmt"
>   "log"
> )
> func main() {
>   //tr := &http.Transport{}
>   //http.DefaultClient.Transport =tr
>   res, err:= http.Get("https://www.github.com/";)
>   if err != nil {
>   log.Fatal(err)
>   return
>   }
>
>   defer res.Body.Close()
>
>   body,err:=ioutil.ReadAll(res.Body)
>   if err != nil {
>   log.Fatal(err)
>   return
>   }
>
>   fmt.Println(string(body))
> }
>
> There is an error with less meaning:
> Get https://www.github.com/: unexpected EOF

-- 
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.
For more options, visit https://groups.google.com/d/optout.


[go-nuts]

2018-08-29 Thread John Shahid
-- 
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.
For more options, visit https://groups.google.com/d/optout.


[go-nuts] using go modules replace with old repos

2018-08-29 Thread John Shahid
Hi all,

Is there a way to use the go module `replace' directive for packages
that don't have go.mod yet ? I tried doing that and I get the following
error:

> go: parsing ../pkg/go.mod: open /path/to/pkg/go.mod: no such file or
> directory

According to https://github.com/golang/go/issues/24110 it looks like
this is the intended behavior.  My question is why the go tool (e.g. go
get) can deal with such package when downloading it from github and
could give it a pseudo version without a go.mod file but refuses to when
the source code is local.

I'm happy to construct a sample github project to repro the issue if
that is needed.

Thanks,

-js

-- 
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.
For more options, visit https://groups.google.com/d/optout.


Re: [go-nuts] Re: Is the go 1.11 godoc tool 'module-aware'?

2018-08-31 Thread John Shahid


Agniva De Sarker  writes:

> We will shift over the features from godoc to "go doc" before removing 
> support, so that the output remains consistent. I think there is already an 
> open issue for exactly what you have shown above. So no worries, things 
> will be the same.

Great, thanks!

>
> On Friday, 31 August 2018 02:16:54 UTC+5:30, John Shahid wrote:
>>
>>
>> Agniva De Sarker > writes: 
>>
>> > Also - note that godoc cli mode is going to go away. So "godoc -links=0 
>> > -html domain.com/group/project/v3/lib/foo" is not going to work after 
>> 1.12. 
>> > You should be using the http server. If you want command line help, use 
>> "go 
>> > doc". 
>>
>> Is there a way to get the same output as godoc ? `go doc' lists the 
>> exported symbols but not their documentation.  For example the following 
>> is what I get from `godoc' 
>>
>> func ResolveIPAddr(network, address string) (*IPAddr, error) 
>> ResolveIPAddr returns an address of IP end point. 
>>
>> The network must be an IP network name. 
>>
>> If the host in the address parameter is not a literal IP address, 
>> ResolveIPAddr resolves the address to an address of IP end point. 
>> Otherwise, it parses the address as a literal IP address. The 
>> address 
>> parameter can use a host name, but this is not recommended, 
>> because it 
>> will return at most one of the host name's IP addresses. 
>>
>> See func Dial for a description of the network and address 
>> parameters. 
>>
>>
>> as opposed to the following less useful `go doc' output: 
>>
>> func Pipe() (Conn, Conn) 
>> func ResolveIPAddr(network, address string) (*IPAddr, error) 
>> func ResolveTCPAddr(network, address string) (*TCPAddr, error) 
>>
>> I have been relying on this behavior for a long time to open up the 
>> documentation of a package and just search for the method I'm using. 
>> Instead of having to open the docs for each method/symbol separately. 
>>
>> Thanks, 
>>
>> -js 
>>

-- 
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.
For more options, visit https://groups.google.com/d/optout.


[go-nuts] Re: using go modules replace with old repos

2018-09-14 Thread John Shahid


Ping.

John Shahid  writes:

> Hi all,
>
> Is there a way to use the go module `replace' directive for packages
> that don't have go.mod yet ? I tried doing that and I get the following
> error:
>
>> go: parsing ../pkg/go.mod: open /path/to/pkg/go.mod: no such file or
>> directory
>
> According to https://github.com/golang/go/issues/24110 it looks like
> this is the intended behavior.  My question is why the go tool (e.g. go
> get) can deal with such package when downloading it from github and
> could give it a pseudo version without a go.mod file but refuses to when
> the source code is local.
>
> I'm happy to construct a sample github project to repro the issue if
> that is needed.
>
> Thanks,
>
> -js

-- 
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.
For more options, visit https://groups.google.com/d/optout.


[go-nuts] SSH Server maximum number of attempts

2017-01-13 Thread John Shahid
Hi all,

I was wondering if there is a way to limit the maximum number of failed
authentication attempts in an ssh server. looks like the serverAuthenticate

method won’t exit unless the authentication was successful or a i/o error
occurs during packet read/write. I see only three options here to limit the
number of failed authentications:

   1. panic in the Callbacks when the limit is reached
   2. modify the server config and remove the callbacks once the limit is
   reached
   3. patch the serverAuthenticate to support a new config parameter that
   specifies the maximum number of attempts.

I think the first two options are ugly. My colleague has a patch, i was
just wondering what everyone think of the idea before submitting the
changes.

Cheers,

JS
​

-- 
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.
For more options, visit https://groups.google.com/d/optout.


[go-nuts] go1.8 and json.NewDecoder(resp.Body)

2017-05-23 Thread John Shahid
Hi all,

Some background, we (CloudFoundry) noticed some weird behavior after
upgrading from go1.7.4 to go1.8.1. An http client that was polling 260
servers started showing more timeouts after the upgrade. After
investigating the issue we realized that the following pattern combined
with tls connection is the culprit:

resp, err := client.Get(url)
if err != nil {
panic(err)
}
defer resp.Body.Close()
m := map[string]string{}
err = json.NewDecoder(resp.Body).Decode(&m)
if err != nil {
panic(err)
}

The reason for this change in behavior between go1.7.4 and go1.8.1 is the
fix for issue#17355 . The new
behavior of the chunkedReader is causing the above code to not read the
entire body, i.e. it falls short of reading the last zero length chunk.
This causes the connection not to be reused on subsequent requests.

I created a small demo app . *note*
the demo app cannot be run on the playground since it listens and makes
network connections.

I honestly don’t know what’s the right way to fix this issue. One one hand
it seems like the reader and json decoder are following the api contract,
i.e. it’s not really a bug. On the other hand, I think that many go users
use the above pattern which causes very unexpected behavior that is hard to
debug.

The only way I can think of to fix this is either using
ioutil.ReadAll(resp.Body) combined with json.Unmarshal, or use
json.NewDecoder() followed by ioutil.ReadAll and discard the result.

What do you all think ?
​

-- 
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.
For more options, visit https://groups.google.com/d/optout.