[go-nuts] is this code thread safety?

2017-11-01 Thread sheepbao
package main import "time" import "fmt" import "sync/atomic" func main() { die := make(chan struct{}) i := int32(0) closed := func() { select { case <-die: atomic.AddInt32(&i, 1) default: close(die) fmt.Println("closed") }

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

2017-11-01 Thread 'Bryan Mills' via golang-nuts
On Wednesday, November 1, 2017 at 10:32:21 AM UTC-4, Ian Lance Taylor wrote: > > On Wed, Nov 1, 2017 at 4:18 AM, > wrote: > > > > Ayan, imagine I am part of a development team. In our program I have a > > pointer r: > > > > r *myType > > > > My variable r can be nil, because that is a valid

[go-nuts] Re: Appengine and main package

2017-11-01 Thread Chris Broadfoot
You can use a main package. package main import ( "net/http" "google.golang.org/appengine" ) func main() { http.HandleFunc(...) appengine.Main() } On Wednesday, November 1, 2017 at 12:04:14 AM UTC-7, Tamás Gulácsi wrote: > > Just move your main to a realmain pkg, and have a shim th

[go-nuts] Possible dep issue: package revision in Gopkg.lock doesn't match constraint in Gopkg.toml

2017-11-01 Thread Dave Cheney
I hit the same bug https://github.com/golang/dep/issues/1231 TLDR, you have to use [[override]] when the package is not directly imported by code in your project. Protist: github.com/heptio/contour has a working Gopkg.toml, I suggest copying that into your project and running dep ensure --

Re: [go-nuts] Possible dep issue: package revision in Gopkg.lock doesn't match constraint in Gopkg.toml

2017-11-01 Thread David Anderson
You could file a bug against dep, that's probably the quickest way to get your issue looked at. With that said, dep is not expected to work with the Kubernetes client library right now. I filed https://github.com/kubernetes/client-go/issues/318 a couple days ago, and the install instructions just

[go-nuts] Possible dep issue: package revision in Gopkg.lock doesn't match constraint in Gopkg.toml

2017-11-01 Thread Justin Lovero
Hi everyone, I'm migrating a project from *glide* to *dep* and I'm running into an issue with *dep* pulling down the wrong revision of a dependency. I've got the following constraint set in my Gopkg.lock file: [[constraint]] name = "github.com/ugorji/go" revision = "ded73eae5db7e7a0ef6f55aa

Re: [go-nuts] Is the Go build for 1.9.2 (or maybe 1.4) meant to create $HOME/pprof/?

2017-11-01 Thread Ian Lance Taylor
On Tue, Oct 31, 2017 at 9:16 PM, Lucio wrote: > > That's what I found (I was building as root, if that makes a difference), > but I was rather surprised to find a "pprof" when the only Go activity I > still recall from yesterday was a fresh Go build, first go1.4, then go1.9.2. We need to vendor a

[go-nuts] [ANN] Moka: a Golang mocking framework built by me, feedback welcome!

2017-11-01 Thread g . capizzi
Hi everyone! Over the last month I've been working on Moka, a mocking framework for Go [1]. I'm a huge fan of London school TDD and I wasn't satisfied with the current options, I was missing a lot of the features I liked in tools like RSpec-Mocks [2] or Mockito [3]. It would be great to get so

[go-nuts] dep: Updating timestamps?

2017-11-01 Thread Marc Abramowitz
If I run `dep ensure` and it doesn't actually pick up any new code, a `go install -v` will still take a while, presumably because `dep ensure` is updating the timestamps of stuff, even if it didn't change. ``` $ ls -ld vendor/github.com/behance/go-common/kvwrapper_etcd/ vendor/github.com/behanc

[go-nuts] Re: XML parsing and memory usage

2017-11-01 Thread Ain
On Wednesday, November 1, 2017 at 6:36:25 PM UTC+2, Felipe da Veiga Leprevost wrote: > > Hey; > > I'm developing a pipeline that takes as input XML files with a reasonable > complex structure and size, the nested structure might have several layers > and these files can go from 900 MB to 3 GB in

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

2017-11-01 Thread 'Axel Wagner' via golang-nuts
It seems a very bad idea, to require the common case to go through some package or else get lint-warned. Checking "x == nil" is the correct way to check whether a value contains a valid implementation of an interface - and a nil-pointer with the correct method set is, as far as you should be conce

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

2017-11-01 Thread Jack Christensen
On 11/01/2017 09:31 AM, Ian Lance Taylor wrote: On Wed, Nov 1, 2017 at 4:18 AM, wrote: Ayan, imagine I am part of a development team. In our program I have a pointer r: r *myType My variable r can be nil, because that is a valid situation. It is used in dozens of places, like this: if r !

[go-nuts] XML parsing and memory usage

2017-11-01 Thread Felipe da Veiga Leprevost
Hey; I'm developing a pipeline that takes as input XML files with a reasonable complex structure and size, the nested structure might have several layers and these files can go from 900 MB to 3 GB in size. I can't change that because it's not on my control how they are formed, I just need to re

Re: [go-nuts] SIGILL: illegal instruction when making cgo call

2017-11-01 Thread Ian Lance Taylor
On Wed, Nov 1, 2017 at 7:47 AM, wrote: > > Encountered this issue running a statically compiled binary that uses cgo > (Compiled using go1.8.3). It works OK on one CPU type but not on another. > The binary is built on a server which is neither of the two below. Is this a > Go issue or something t

[go-nuts] SIGILL: illegal instruction when making cgo call

2017-11-01 Thread martin . ostrovsky
Hello, Encountered this issue running a statically compiled binary that uses cgo (Compiled using go1.8.3). It works OK on one CPU type but not on another. The binary is built on a server which is neither of the two below. Is this a Go issue or something to do with how the C library is built (gc

Re: [go-nuts] Incorrect code snippet on golang.org/ref ??

2017-11-01 Thread Ian Lance Taylor
On Tue, Oct 31, 2017 at 11:13 PM, Tassadar Liu wrote: > > At bottom part of this article: https://golang.org/ref/mem > > Should(incorrect idiom): > > var a string > var done bool > > func setup() { > a = "hello, world" > done = true > } > > func main() { > go setup() > for !done { > } > print(a) >

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

2017-11-01 Thread Ian Lance Taylor
On Wed, Nov 1, 2017 at 4:18 AM, wrote: > > Ayan, imagine I am part of a development team. In our program I have a > pointer r: > > r *myType > > My variable r can be nil, because that is a valid situation. It is used in > dozens of places, like this: > > if r != nil { > r.doSomething() > } >

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

2017-11-01 Thread Ain
On Wednesday, November 1, 2017 at 3:37:54 PM UTC+2, Ayan George wrote: > > > > On 11/01/2017 07:18 AM, oju...@gmail.com wrote: > > Ayan, imagine I am part of a development team. In our program I have a > > pointer r: > > > > r *myType > > > > My variable r can be nil, because that is a vali

[go-nuts] Incorrect code snippet on golang.org/ref ??

2017-11-01 Thread Tassadar Liu
At bottom part of this article: https://golang.org/ref/mem Should(incorrect idiom): var a string var done bool func setup() { a = "hello, world" done = true } func main() { go setup() for !done { } print(a) } be: var a string var done bool fu

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

2017-11-01 Thread Ayan George
On 11/01/2017 07:18 AM, oju...@gmail.com wrote: > Ayan, imagine I am part of a development team. In our program I have a > pointer r: > > r *myType > > My variable r can be nil, because that is a valid situation. It is used > in dozens of places, like this: > > if r != nil { >     r.doSomethin

Re: [go-nuts] Boolean query string conversion into functional logic

2017-11-01 Thread Jose
Thanks, really useful! On Wed, Nov 1, 2017 at 2:18 AM, Hamish Ogilvy wrote: > Hey Jose, > > Yep, might be worth a look at: https://github.com/influxdata/influxql for a > pretty advanced and open source version. Also look at Rob Pike's calculator > talk: https://www.youtube.com/watch?v=PXoG0WX0r_E

[go-nuts] Re: Go vendoring question

2017-11-01 Thread Diego Medina
I have been using https://github.com/FiloSottile/gvt for years, it's great, simple, you vendor only what you want, so, in this case, that one lib you are talking about you can even leave the imports as they are, but point to your own fork of the repo by modifying the manifest file for example,

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

2017-11-01 Thread ojucie
Ayan, imagine I am part of a development team. In our program I have a pointer r: r *myType My variable r can be nil, because that is a valid situation. It is used in dozens of places, like this: if r != nil { r.doSomething() } That is a very usual idiom, no only in Go, but in many langua

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

2017-11-01 Thread Ayan George
On 10/31/2017 12:42 PM, oju...@gmail.com wrote: > Today you can't, Ayan. > Right -- I understand that. I'm asking how would you propose Go do that? What changes would you make to fix this? I'm asking: If you claim Go is fundamentally broken in this way, how would you fix it? -ayan -- You

[go-nuts] Appengine and main package

2017-11-01 Thread Tamás Gulácsi
Just move your main to a realmain pkg, and have a shim that just calls it. I used to create a "func Main() error" and a main which calls this, and log,Fatal on error. -- You received this message because you are subscribed to the Google Groups "golang-nuts" group. To unsubscribe from this group