Re: [go-nuts] Strange behaviour of left shift

2018-12-05 Thread James Bardin
On Wednesday, December 5, 2018 at 11:55:25 AM UTC-5, Michel Levieux wrote: > > Well the only thing I do in the main is : > > fmt.Println(v) >> > > Shouldn't the compiler statically type v to uint64? > I don't get the need to force type of v to uint64? > > Nope. You're passing an untyped constant

[go-nuts] Re: Strange behaviour of left shift

2018-12-05 Thread James Bardin
On Wednesday, December 5, 2018 at 11:36:32 AM UTC-5, Michel Levieux wrote: > > which I assume works pretty well. But if I do the same in a test main and > try to 'go run' it, with this line : > > const v = 1 << 64 - 1 >> >> > I get the following error : > > ./testmain.go:8:13: constant

[go-nuts] Re: Go routines hanging

2018-05-05 Thread James Bardin
On Saturday, May 5, 2018 at 9:30:25 AM UTC-4, s...@whites.team wrote: > > Hi James, > > Thanks for the tip - could you elaborate on your idea of a 'busy loop'? Is > this a loop that is blocked, or just one that is currently operating on > something? I'm not sure what causes GC to act on

[go-nuts] Re: Go routines hanging

2018-05-05 Thread James Bardin
On Saturday, May 5, 2018 at 6:27:54 AM UTC-4, s...@whites.team wrote: > > debug.SetGCPercent(-1) > stops the issue occurring - so I think we're onto a winner with the > garbage collection idea! Is there something I'm doing wrong that is causing > this GC binning off all of my go routines? >

[go-nuts] if i catch resp.StatusCode != http.StatusOK and return early from my function, do i still have to close resp.Body??

2018-01-28 Thread James Bardin
Yes, always close the body in order to ensure the network connection is released. If you want to be able to reuse the connection, you should attempt to consume the body as well. -- You received this message because you are subscribed to the Google Groups "golang-nuts" group. To unsubscribe

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

2018-01-02 Thread James Bardin
The net dialer sorts the addresses according to RFC6724, which means that since you don't have ipv6 enabled they go to the end of the list, but doesn't remove them entirely. Also if you're using the DefaultTransport from the net/http package, it has DualStack enabled which means that ipv4 and

[go-nuts] Re: What does the 1st :8 do in -- slice := (*[1 << 30]byte)(unsafe.Pointer())[:8:8]

2017-12-13 Thread James Bardin
On Wednesday, December 13, 2017 at 8:49:07 AM UTC-5, M.P. Ardhanareeswaran wrote: > > var i uint64 = 0xdeedbeef01020304 >> >> slice := (*[1 << 30]byte)(unsafe.Pointer())[:8:8] >> >> The fist 8 is the length, and the second is capacity. See "Full Slice Expressions" specification here:

Re: [go-nuts] Re: Should net.Conn transform function retain the original data segmentation?

2017-11-20 Thread James Bardin
On Mon, Nov 20, 2017 at 12:01 PM, James Bardin <j.bar...@gmail.com> wrote: > Though in this case I assume you must be using a TCP connection, so there > is no concept of a "message" and hence to direct connection between the > write size and the read size. If something ot

[go-nuts] Re: Should net.Conn transform function retain the original data segmentation?

2017-11-20 Thread James Bardin
Dave, should I then file a bug against net.UDPConn? ;) Though in this case I assume you must be using a TCP connection, so there is no concept of a "message" and hence to direct connection between the write size and the read size. If something other than UDP is expecting the full message in a

[go-nuts] Re: Why bytes Buffer's ReadFrom method blocked when read from a UDP connection?

2017-09-20 Thread James Bardin
You shouldn't use bufio around a UDP connection. The reads are a fixed size, so there's no "batching" of reads that could happen, and you can't do a partial read of a UDP packet, so you're going to lose data as soon if the buffer attempts to top off with a read smaller than the next packet

[go-nuts] Re: How to run escape analysis on subpackage

2017-09-14 Thread James Bardin
On Thursday, September 14, 2017 at 10:58:27 AM UTC-4, Diego Medina wrote: > > > go build -gcflags "-m -m" github.com/me/project-name/packagea and nothing > prints out, > > > Nothing printed because it was already installed. You could update the timestamp on any of the package files, remove

[go-nuts] Re: net: unclear how to confirm synchronously that a net.TCPListener is closed

2017-09-11 Thread James Bardin
On Monday, September 11, 2017 at 5:53:10 AM UTC-4, Shivaram Lingamneni wrote: > > > 1. Using `Listener.Close()` to interrupt the `Listener.Accept()` call > on the other goroutine > 2. Using a channel to tell the other goroutine that it should call > `Listener.Close()` itself and exit > 3.

[go-nuts] Re: Go 1.9 introduced error on UDP Multicast JoinGroup

2017-08-28 Thread James Bardin
On Sunday, August 27, 2017 at 7:36:22 PM UTC-4, oldCoderException wrote: > > No. I just downloaded and used 1.9 on its release last week. I've > reverted to 1.8.3 for now and, as mentioned, it's working fine for me. > > >>> Are you certain you also have the latest version of

[go-nuts] Re: runtime.GOOS case

2017-08-07 Thread James Bardin
They will always be lowercase, as the values are all defined in the code const GOOS = `android` const GOOS = `darwin` const GOOS = `dragonfly` const GOOS = `freebsd` const GOOS = `linux` const GOOS = `nacl` const GOOS = `netbsd` const GOOS = `openbsd` const GOOS = `plan9` const GOOS = `solaris`

[go-nuts] Re: Do we need to close response.Body before closing it?

2017-07-05 Thread James Bardin
On Wednesday, July 5, 2017 at 6:50:10 AM UTC-4, Yulrizka wrote: > > > So in conclusion my question is do we need to always read the resp.Body > before closing it? > > Yes, you need to read the body to reuse the connection, otherwise there may be still be data waiting to be read. You dug

[go-nuts] Re: why this goroutine always faster than main goroutine?

2017-06-20 Thread James Bardin
It's only polite to let other's know when cross-posting questions, to avoid wasting time. https://stackoverflow.com/questions/44657084/why-main-goroutine-always-be-the-second-to-be-invoked The answer and comments there seems to cover most aspects of the behavior you're seeing. On Tuesday,

[go-nuts] Re: How to set value to empty interface{}

2017-04-11 Thread James Bardin
On Tuesday, April 11, 2017 at 10:10:25 AM UTC-4, Th3x0d3r wrote: > > AFAIK empty interfaces{} are passed by reference > > Nothing in go is "pass by reference". The interface value is always copied. -- You received this message because you are subscribed to the Google Groups "golang-nuts"

[go-nuts] Re: Shiny examples don't work on macOS Sierra 10.12.4

2017-04-01 Thread James Bardin
See https://golang.org/issue/19734 On Saturday, April 1, 2017 at 1:39:36 PM UTC-4, Dmitry Kravchenko wrote: > > After update to macOS Sierra 10.12.4 Shiny examples don't work anymore. > > iMac-Dmitry:~ dmitrykravchenko$ go env > > GOARCH="amd64" > > GOBIN="/Users/dmitrykravchenko/gowsp/bin" > >

[go-nuts] Re: I cannot understand this channel behavior, is one channel ops affect another channel ops

2017-04-01 Thread James Bardin
Wasn't this already answered for you here? https://stackoverflow.com/questions/43152776/is-it-one-channel-ops-affect-another-channel-ops On Saturday, April 1, 2017 at 1:35:12 PM UTC-4, Khalid Adisendjaja wrote: > > I made this simple script, trying to understand how is channel working, >

[go-nuts] Re: gwenn/gosqlite, go1.8, runtime error: cgo argument has Go pointer to Go pointer

2017-03-08 Thread James Bardin
That package documents the behavior on all the relevant methods: > Cannot be used with Go >= 1.6 and cgocheck enabled. If you trust the author to have written something that is correct despite the checks done by cgo, you can disable cgocheck to use those methods. On Wednesday, March 8, 2017

Re: [go-nuts] sort.Slice arguments

2017-03-08 Thread James Bardin
On Wednesday, March 8, 2017 at 10:01:08 AM UTC-5, Val wrote: > > > - or the code in the less function will have to refer to the same > (unnamed) resliced portion, which is imo convoluted : fix 1 > or fix 2 > . >

Re: [go-nuts] A naive question, why not move the len and cap fields of string and slice types into the underlying types?

2017-03-03 Thread James Bardin
On Friday, March 3, 2017 at 11:47:10 AM UTC-5, T L wrote: > > > Yes, the suggestion needs more allocations in creating new string and > slice values. > But it makes copying string and slice values a little faster and a little > less memory consuming. > > In most cases there is no difference

[go-nuts] Re: Problem calling http.HandlerFunc

2017-03-03 Thread James Bardin
The method expression (*Api).ListHandler yields a function with the signature func(*Api, http.ResponseWriter, *http.Request) To use the method value with the signature func(http.ResponseWriter, *http.Request) you need an instance of `*Api` to call its method, so you can't

Re: [go-nuts] Slice from interface doesn't work as expected

2017-03-02 Thread James Bardin
All assignments are a copy, so there's no way to modify a slice value that is in an interface{} Just like if this were a function argument, you will need a pointer in order to modify the value. https://play.golang.org/p/kOdXUCiT_F On Thursday, March 2, 2017 at 9:01:48 AM UTC-5, Cornel

Re: [go-nuts] Re: Handshake failed when using builtin TLS package: no cipher suite supported by both client and server

2017-02-08 Thread James Bardin
ypt) >> to get HTTPS certificate. Output of SSLLabs in both cases is: >> >> Chrome 49 / XP SP3 >> <https://www.ssllabs.com/ssltest/viewClient.html?name=Chrome=49=XP%20SP3=136> >> Server >> sent fatal alert: handshake_failure >> >> And no ciphe

[go-nuts] Re: Handshake failed when using builtin TLS package: no cipher suite supported by both client and server

2017-02-06 Thread James Bardin
What cipher quite is negotiated when you connect to the Heroku proxy? What version of Go are you using on the server, and are you using the default tls.Config? I don't have that client directly available to test with, but does your particular client show the expected information when you

Re: [go-nuts] Re: Dynamic select/channel causes data race

2017-02-02 Thread James Bardin
Can you point to the actual source you're using? The filenames and line numbers in the stack traces don't line up with the file you linked originally. -- You received this message because you are subscribed to the Google Groups "golang-nuts" group. To unsubscribe from this group and stop

[go-nuts] Re: Dynamic select/channel causes data race

2017-02-02 Thread James Bardin
Can you post the actual output from the race detector? On Thursday, February 2, 2017 at 12:43:09 PM UTC-5, Aaron Wood wrote: > > Hi all, > > I'm seeing a very strange issue that I'm not quite sure how to fix: > > https://github.com/mesos/mesos-go/blob/next/backoff/backoff.go#L25 >

[go-nuts] Re: HTTP requests bottlenecks

2017-02-02 Thread James Bardin
First things I notice are that you're overriding the default dialer with one that doesn't timeout, and you've commented out ReadTimeout in the client. Both of those could indefinitely hold up client connections regardless of the DoTimeout call, which just ensures that the Do function returns

[go-nuts] Re: About "Declaring Empty Slices" of CodeReviewComments

2017-01-31 Thread James Bardin
None of those values are escaping or being used. Your only allocation is probably the call to fmt.Fprint. This isn't something that really needs a benchmark, it should be obvious that t is nil in `var t []string`, and t is not nil in `t := []string{}`. The former doesn't allocate a slice

Re: [go-nuts] HTTP Server - Force close connection after response

2017-01-17 Thread James Bardin
thing. On Tuesday, January 17, 2017 at 7:06:44 AM UTC-5, James Bardin wrote: > > No, it signals to the client that the connection will be closed after the > completion of the response. -- You received this message because you are subscribed to the Google Groups "golang-nuts" gr

[go-nuts] Re: http/2 client vs. GOAWAY

2017-01-12 Thread James Bardin
Form the SO link the frame was sent with ErrCode=NO_ERROR, which I would assume would be handled silently by the transport. Not ruing out the ALBs doing something strange, but I would open an issue none the less. On Wednesday, January 11, 2017 at 5:18:54 PM UTC-5, Brian Fallik wrote: > >

[go-nuts] Re: How to close all existing connections on http server

2017-01-03 Thread James Bardin
Up until now you had to implement that yourself. In go1.8 the http.Server will have Close and Shutdown methods: - https://tip.golang.org/pkg/net/http/#Server.Close - https://tip.golang.org/pkg/net/http/#Server.Shutdown On Tuesday, January 3, 2017 at 10:52:29 AM UTC-5, laxman.v...@gmail.com

[go-nuts] Re: Downloading go1

2016-12-01 Thread James Bardin
Can you build it from source? The repo of course contains the entire history. On Thursday, December 1, 2016 at 4:57:30 PM UTC-5, freeformz wrote: > > For $reasons I need to download the original linux amd64 version of go1. > > Older go versions are stored under >

[go-nuts] Re: net.Conn.Read() performance

2016-12-01 Thread James Bardin
Conn.Read is a much higher level construct the using the syscalls directly. The largest part of the overhead is coordinating with the network poller. There's also a slight overhead of using the net.Conn interface, so asserting the value to a *net.TCPConn may save you a little (though I'm not

[go-nuts] Re: net/http and errors.

2016-11-28 Thread James Bardin
If you want to assert your way down to the original error, the order of the structures returned from http.Get is: if err, ok := err.(*url.Error); ok { if err, ok := err.Err.(*net.OpError); ok { if err, ok := err.Err.(*net.DNSError); ok { fmt.Println("DNS ERROR:", err) } } } Again though, the

[go-nuts] Re: [Help] In a multi-threads application, when main function spins, the whole application hangs up

2016-11-21 Thread James Bardin
On Monday, November 21, 2016 at 2:23:37 PM UTC-5, zhaoguo wang wrote: > > Hi all, > > I wrote a simple application: the main function creates two goroutines, > while these two goroutines use RPC to do simple communication continually. > > I found > *if the main function falls into a busy loop

Re: [go-nuts] Re: http.NewRequest stopped to check SSL certificate validity every time

2016-11-19 Thread James Bardin
On Sat, Nov 19, 2016 at 11:33 AM, Vasily Korytov wrote: > It stays there for days, so I'm not sure. And the client is supposed to be > created and destroyed in a function that terminates, so I'm really > surprised by that. > > The connection can stay there for as long as

[go-nuts] Re: http.NewRequest stopped to check SSL certificate validity every time

2016-11-19 Thread James Bardin
Chances are that you're getting better reuse of the client connections. If you want to ensure that you reconnect periodically use Request.Close when you don't want the connection maintained, or call Transport.CloseIdleConnections occasionally between requests to force the connections to

Re: [go-nuts] Re: httputil.ReverseProxy adding 100+ ms of latency on localhost - any ideas?

2016-11-17 Thread James Bardin
On Thu, Nov 17, 2016 at 5:47 PM, Tom wrote: > I agree that creating a ReverseProxy object every time is inefficent with > regards to transports - but surely that wouldnt cause the additional > latency? Depends on what exactly you're measuring and how you're testing. A DNS

[go-nuts] Re: httputil.ReverseProxy adding 100+ ms of latency on localhost - any ideas?

2016-11-17 Thread James Bardin
While it might not be the initial problem, you're creating a new proxy and a new http.Transport on every request. At the end of that request that transport will probably still contain the open connection which you can no longer use. That's going to tie up the FD until the keepalive can kill

[go-nuts] Re: Concurrently read map entries into a channel

2016-11-06 Thread James Bardin
On Sunday, November 6, 2016 at 12:00:33 AM UTC-4, Keith Randall wrote: > > > You cannot modify the map in another goroutine while iterating. Iterating > is considered a read operation for the entire duration of the read. Writes > happening simultaneously with reads are a data race. > "Entire

Re: [go-nuts] CGO: Go string -> void*/length

2016-10-31 Thread James Bardin
C.CBytes does essentially this, but you either need to start with a []byte, or the string conversion could be a second copy. I don't see a need for a separate version CString without the null when you can just pass the length-1. In the rare case that the extra byte makes a difference, you

[go-nuts] Re: http ssl "can't identify protocol"

2016-09-20 Thread James Bardin
It would really help if we had some complete code to reproduce the issue. It sounds like the server isn't closing connections, but with only these simple handlers I don't see where that could happen. Are there any Hijack calls, x/net/ipv4, or network related syscalls anywhere in your code?

[go-nuts] Re: net/http: In the infinite loop, refused all requests.

2016-09-19 Thread James Bardin
A busy loop is always a programming error, and there's no reason to do this is your code. If you actually did have a loop with no function calls that's somehow useful, you could add occasional calls to runtime.Gosched() to yield to the scheduler. -- You received this message because you

[go-nuts] How example can be run in test?

2016-09-16 Thread James Bardin
This is fixed in master. In go1.7 the Examples and Benchmarks aren't run if there are no Test functions. -- 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] go get creating strange git messages in bash. Any ideas what causes this ?

2016-09-15 Thread James Bardin
On Thu, Sep 15, 2016 at 5:53 PM, Joe Blue wrote: > thanks James > > You lost me here. > Where's here? O can try to provide more detail if you let me know what you're not following. If you go into each repo that's not working and checkout master, "go get -u" will work again.

[go-nuts] go get creating strange git messages in bash. Any ideas what causes this ?

2016-09-15 Thread James Bardin
You have a few repos that aren't on a branch, so git can't pull and fast forward. You can checkout master in those repos, or delete them altogether and the next `go get` will fetch the current master branch. -- You received this message because you are subscribed to the Google Groups

[go-nuts] C.dll callback golang func will stuck

2016-09-09 Thread James Bardin
You have a busy loop in main. Use another method to block, like a read in stdin, wait for a signal, etc. -- 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] Cgo Pointer Arithmetic

2016-09-01 Thread James Bardin
On Thursday, September 1, 2016 at 8:45:02 AM UTC-4, Luke Mauldin wrote: > > After I added the unsafe.Pointer conversion the code compiled: > https://play.golang.org/p/QTPyhZzKZH > > So my understanding is that line 15 is jut a pointer type conversion to > slice that is backed by the C array,

Re: [go-nuts] Re: net.Conn.Write is failing in golang

2016-08-26 Thread James Bardin
On Fri, Aug 26, 2016 at 5:46 AM, wrote: > I found it's hard to match *this particular error (*"broken pipe"*)*, and > handle it accordingly, is there a solution? > What do you want to do with this particular error? How would you handle it differently than any other

[go-nuts] Re: Search for Another JSON Package

2016-08-24 Thread James Bardin
Can you use the json.Number type? https://play.golang.org/p/pKZeDJHkKK On Wednesday, August 24, 2016 at 5:30:10 AM UTC-4, dc0d wrote: > > Is there a JSON package that have these characteristics? > > >- can marshal numeric integer values to strings (like >using `json:",string"` tag) >

[go-nuts] Differences in archive/zip between 1.6.3 / 1.7

2016-08-17 Thread James Bardin
Hi Radek, There were a lot of performance improvements in the compress/flate package. https://tip.golang.org/doc/go1.7#minor_library_changes -- You received this message because you are subscribed to the Google Groups "golang-nuts" group. To unsubscribe from this group and stop receiving

Re: [go-nuts] Is there a function in standard lib to convert []T to a []interface{}?

2016-08-03 Thread James Bardin
https://github.com/golang/go/issues/15209 On Wednesday, August 3, 2016 at 11:20:01 AM UTC-4, T L wrote: > > > > On Wednesday, August 3, 2016 at 10:53:34 PM UTC+8, Jessta wrote: >> >> On 4 Aug 2016 12:36 a.m., "T L" wrote: >> > >> > Often, I need converting a []T to

[go-nuts] Re: how to apply netutil.LimitListener() to ListenAndServeTLS()'s listener? how to fetch ListenAndServeTLS()'s listener?

2016-08-03 Thread James Bardin
The issue here in essence is that an http.Server doesn't store a new.Listener to expose, it only operates on one provided to the Serve method. Without changing the api, there's no way to expose a listener in an http.Server in a way that doesn't interfere with the other methods. However, I

Re: [go-nuts] Re: http response issue with leaking handles

2016-07-29 Thread James Bardin
On Fri, Jul 29, 2016 at 2:01 AM, wrote: > Thanks James, are there any golang tools which could have caught this > issue. I know go vet didnt. Caught the issue of using the first odd pattern for closing the response Body? There's no tool that can detect general logic

Re: [go-nuts] Re: http response issue with leaking handles

2016-07-28 Thread James Bardin
ady closed" > > I am interested in looking at it. I didnt find it here > https://golang.org/pkg/net/http/ > > > On Thursday, July 28, 2016 at 8:10:30 AM UTC-7, James Bardin wrote: >> >> >> On Thu, Jul 28, 2016 at 11:08 AM, Ian Davis <m...@iandavis.c

Re: [go-nuts] Re: http response issue with leaking handles

2016-07-28 Thread James Bardin
On Thu, Jul 28, 2016 at 11:08 AM, Ian Davis wrote: > Great. Very clear. > > To those looking for this: it's a new comment added after 1.6.2 > Thanks, forgot I was on master. Yes, this was implied by the error handling example in the docs, but now is much more explicit. --

Re: [go-nuts] Re: http response issue with leaking handles

2016-07-28 Thread James Bardin
On Thu, Jul 28, 2016 at 10:39 AM, Ian Davis wrote: > Is it? The http package only says: > > "When err is nil, resp always contains a non-nil resp.Body. Caller should > close resp.Body when done reading from it." > > It doesn't say anything about the case where err != nil > >

[go-nuts] Re: Someone reads req.Body even after client.Do ends in an http request,

2016-07-25 Thread James Bardin
To put it another way, excluding error conditions, the request isn't done until you've consumed the response body and closed it. On Monday, July 25, 2016 at 3:11:01 PM UTC-4, fabian@gmail.com wrote: > > Hi, > > first, two points on the more obvious aspects: > >- The ContentLength header

Re: [go-nuts] Segmentaion fault / static binary

2016-07-18 Thread James Bardin
FWIW, the "github.com/xeodou/go-sqlcipher" library isn't being linked correctly, and it seems to be trying to load /lib/x86_64-linux-gnu/libcrypto.so at runtime. Not sure what's at fault off hand, but "github.com/xeodou/go-sqlcipher" might be making some assumptions about being dynamically