[go-nuts] Re: When should I use the connection pool?

2016-06-17 Thread Danilo Cicerone
Great, I found this page "https://www.vividcortex.com/blog/2015/01/19/gos-connection-pool-retries-and-timeouts/ and it's really useful!!! Hope to help someone else. Il giorno venerdì 17 giugno 2016 23:26:08 UTC+2, Danilo Cicerone ha scritto: > > Thanks ain, that's another brick in the wall. >

Re: [go-nuts] Re: [ANN] primegen.go: Sieve of Atkin prime number generator

2016-06-17 Thread gordonbgood
Here is a golang version of Daniel Bernstein's "eratspeed", which is a straight translation of his C code to golang without any changes other than as necessary to make it work: https://play.golang.org/p/Sd6qlMQcHF. It won't run on the golang playground because it takes too long unless one chan

[go-nuts] Re: Currying in Go

2016-06-17 Thread Tyler Compton
I would also like to hear from somebody about a real world use-case. I don't pretend to be proficient in this realm of functional programming, but I would be very surprised if this is valuable in a language like Go that can and does hold state. That said, this is very cool and I would love to b

[go-nuts] Re: go1.7beta2 prints "too many values in struct initializer" when I ran "go test" for gopkg.in/vmihailenco/msgpack.v2

2016-06-17 Thread Dave Cheney
This could be caused by setting GOROOT to a value that does not match the `go` binary in your path. If you have another version of Go installed, please remove it, unset GOROOT, and follow the installation instructions on the Go website. On Saturday, 18 June 2016 12:02:03 UTC+10, Hiroaki Nakamu

[go-nuts] Re: go1.7beta2 prints "too many values in struct initializer" when I ran "go test" for gopkg.in/vmihailenco/msgpack.v2

2016-06-17 Thread Dave Cheney
go test -work should do it. On Saturday, 18 June 2016 12:02:03 UTC+10, Hiroaki Nakamura wrote: > > Hi, > > Here are commands I used to set up gopkg.in/vmihailenco/msgpack.v2 > > go get -u gopkg.in/vmihailenco/msgpack.v2 > cd $GOPATH/src/gopkg.in/vmihailenco/msgpack.v2 > go get -u github.com/ug

[go-nuts] go1.7beta2 prints "too many values in struct initializer" when I ran "go test" for gopkg.in/vmihailenco/msgpack.v2

2016-06-17 Thread Hiroaki Nakamura
Hi, Here are commands I used to set up gopkg.in/vmihailenco/msgpack.v2 go get -u gopkg.in/vmihailenco/msgpack.v2 cd $GOPATH/src/gopkg.in/vmihailenco/msgpack.v2 go get -u github.com/ugorji/go-msgpack go get -u github.com/ugorji/go/codec go get -u gopkg.in/check.v1 And I tried to run tests and go

Re: [go-nuts] Simplest way to extend the functionality of other's package

2016-06-17 Thread Nigel Tao
On Thu, Jun 16, 2016 at 2:11 PM, Tong Sun wrote: > How to define my own function > > > func FindUrl() { return > goquery.Find(".thing").Find(".comments.may-blank").Attr("href"); } > > so that the above code can be simplified as: > > post_url, _ := doc.FindUrl() In your own package, you can only

Re: [go-nuts] GoMobile window size always 800x800

2016-06-17 Thread Andy Brewer
OK, so designers will want to quickly test their app at specific screen sizes. I think we just need to determine the best option because there doesn't seem to be a gomobile best practice. It sounds like we have the following options: 1. Run a script to resize the window ( http://www.labnol.org/sof

Re: [go-nuts] Re: encoding/json: any way to receive number literal "10.0" into integer field?

2016-06-17 Thread Matt Harden
https://play.golang.org/p/8R6QmYw_28 On Fri, Jun 17, 2016 at 3:08 PM Evan Digby wrote: > To further this, if you do need your internal model to be a concrete > struct rather than interface this approach still fits: > > https://play.golang.org/p/_wrgN1FltA > > > On Friday, 17 June 2016 15:02:43 U

Re: [go-nuts] Re: [ANN] primegen.go: Sieve of Atkin prime number generator

2016-06-17 Thread gordonbgood
On Friday, June 17, 2016 at 4:48:06 PM UTC+2, gordo...@gmail.com wrote: > > I don't see the point to the exercise as far as optimizing golang is > > concerned. > It is a general rule that using more registers results in faster code. Yes, except when they're wasted as in using the extra register

[go-nuts] Re: encoding/json: any way to receive number literal "10.0" into integer field?

2016-06-17 Thread Evan Digby
To further this, if you do need your internal model to be a concrete struct rather than interface this approach still fits: https://play.golang.org/p/_wrgN1FltA On Friday, 17 June 2016 15:02:43 UTC-7, Evan Digby wrote: > > One approach to deal with this would be to abstract your internal model a

Re: [go-nuts] encoding/json: any way to receive number literal "10.0" into integer field?

2016-06-17 Thread jonathan
Thanks -- I should have clarified that we've ruled that option out (it was our first approach), since we want to stick to the built in types that won't require explicit exchange with the primitive types. jonathan On Fri, Jun 17, 2016 at 02:56:49PM -0700, Edward Muller wrote: > AFAIK (and someone

[go-nuts] Re: encoding/json: any way to receive number literal "10.0" into integer field?

2016-06-17 Thread Evan Digby
One approach to deal with this would be to abstract your internal model as an interface from the model you receive and mutate them to match. This also gives you the power to truncate/round/mutate a float however best suites your needs rather than hoping the library truncates/rounds/mutates in a

Re: [go-nuts] export struct method to C-code as callback (cgo-related)

2016-06-17 Thread andrey mirtchovski
If the library made no provision for the caller to give a unique token which would help to identify it in the callback then that library does not expect to have more than one caller-and-callback in play at any one time, or, even worse, expects you to arrange some thread-local storage in the caller

Re: [go-nuts] encoding/json: any way to receive number literal "10.0" into integer field?

2016-06-17 Thread Edward Muller
AFAIK (and someone will probably provide something better) you need to do something like this: https://play.golang.org/p/riq-m6cgZu > On Jun 17, 2016, at 2:37 PM, jg...@bitgirder.com wrote: > > We have an upstream provider of JSON data which sends integer data > types as floating point literal

[go-nuts] encoding/json: any way to receive number literal "10.0" into integer field?

2016-06-17 Thread jgold
We have an upstream provider of JSON data which sends integer data types as floating point literals with a "0" decimal part. By default json.Decoder doesn't allow this and fails: https://play.golang.org/p/MEJlg1n3vs Unfortunately this provider is almost certain not to change this, and so we j

[go-nuts] Re: When should I use the connection pool?

2016-06-17 Thread Danilo Cicerone
Thanks ain, that's another brick in the wall. -- 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 ht

Re: [go-nuts] Re: importer.Default not able to find packages in $GOPATH

2016-06-17 Thread Joshua Liebow-Feeser
'go install' worked; thanks a ton! I'll also take a look at the other stuff you mentioned because I'm curious about the details. On Fri, Jun 17, 2016 at 5:15 PM, adonovan via golang-nuts < golang-nuts@googlegroups.com> wrote: > On Friday, 17 June 2016 15:21:55 UTC-4, Joshua Liebow-Feeser wrote: >

[go-nuts] Re: importer.Default not able to find packages in $GOPATH

2016-06-17 Thread adonovan via golang-nuts
On Friday, 17 June 2016 15:21:55 UTC-4, Joshua Liebow-Feeser wrote: > > Hi All, > > I'm trying to use the go/* packages to parse and type check Go source > code. I've downloaded github.com/coreos/etcd to test this on, and I'm > currently trying it out in the etcdserver subdirectory. When I run 'g

Re: [go-nuts] export struct method to C-code as callback (cgo-related)

2016-06-17 Thread Ian Lance Taylor
On Fri, Jun 17, 2016 at 12:18 PM, Andrey Salnikov wrote: > > But actually I don't understand how to receive context inside callback from > C-code. May be I'm wrong here but as I understand you mean that I have to > identify instance of *A using callback parameters received from C-side. But > what

Re: [go-nuts] Re: Go 1.7 Beta 2 is released

2016-06-17 Thread Ian Lance Taylor
On Fri, Jun 17, 2016 at 6:34 AM, wrote: > > Thanks, is there a way to know what to expect in later versions ( > 1.8,1.9,1.10 and so forth ... ) ? We do not have a general roadmap, no. We expect the new SSA based compiler to replace the old compiler on all targets. We expect to continue to impr

Re: [go-nuts] CPU fairness in goroutine scheuding

2016-06-17 Thread Sam Whited
On Fri, Jun 17, 2016 at 2:23 PM, Dmitry Orlov wrote: > If I understand it correctly, go scheduler instruments code with additional > yield points not related to I/O. That can help fairness too. It will sometimes pre-empt on function calls, but this can get a bit hairy since you can't always be su

Re: [go-nuts] CPU fairness in goroutine scheuding

2016-06-17 Thread Dmitry Orlov
Thanks Ian, On Thu, Jun 16, 2016 at 12:13 PM, Ian Lance Taylor wrote: > On Thu, Jun 16, 2016 at 11:27 AM, Dmitry Orlov > wrote: > > > > I am curious how does goroutine scheduler picks what goroutine to run, > among > > several runnable. Does it optimize for fairness in any way? > > The current

[go-nuts] importer.Default not able to find packages in $GOPATH

2016-06-17 Thread Joshua Liebow-Feeser
Hi All, I'm trying to use the go/* packages to parse and type check Go source code. I've downloaded github.com/coreos/etcd to test this on, and I'm currently trying it out in the etcdserver subdirectory. When I run 'go build' everything works fine, but when I try to type check, none of the impo

Re: [go-nuts] export struct method to C-code as callback (cgo-related)

2016-06-17 Thread Andrey Salnikov
Hi Andrey! thanks for answer! But actually I don't understand how to receive context inside callback from C-code. May be I'm wrong here but as I understand you mean that I have to identify instance of *A using callback parameters received from C-side. But what about if I'll receive only sum of

Re: [go-nuts] Re: Currying in Go

2016-06-17 Thread Ian Lance Taylor
Note that Go's reflect package is powerful enough to implement currying directly, though you do have to convert back to the expected type in order to call the function. https://play.golang.org/p/2ukRfHGnlT Ian -- You received this message because you are subscribed to the Google Groups "golang

Re: [go-nuts] Re: Golang Error - When marshelling data

2016-06-17 Thread Konstantin Khomoutov
On Fri, 17 Jun 2016 00:50:20 -0700 (PDT) User123 wrote: [...] > When i return http response from a function should i use > *func makeCalls() (string, error, *http.Response, error) * > or > *func makeCalls() (string, error, http.Response, error) * > > For the struct i created above what should b

Re: [go-nuts] GoMobile window size always 800x800

2016-06-17 Thread Daniel Skinner
> but I still want to test my app at explicit screen sizes testing on actual hardware is still going to be the best, but I'd imagine there's something out there for OSX that'd let you specify the exact window size (of any window open). > Also, Android best practices does recommend as an option cr

Re: [go-nuts] GoMobile window size always 800x800

2016-06-17 Thread Andy Brewer
Thanks. I'm wondering how I can test my UI efficiently with gomobile. So, I will create a responsive design as you recommend, but I still want to test my app at explicit screen sizes to mimic the actual user experience, rather than approximate it. The use case is someone who wants to support iPho

[go-nuts] Re: Is this deterministic ?

2016-06-17 Thread Egon
On Friday, 17 June 2016 18:50:59 UTC+3, Olivier Gagnon wrote: > > https://play.golang.org/p/yE7UVXcXm3 > > The key point here is that all the RHS of the `Cross` function must be > evaluated before the LHS is assigned. But I need to have a guarantee that > we won't assign before having evaluated t

[go-nuts] Is this deterministic ?

2016-06-17 Thread Olivier Gagnon
https://play.golang.org/p/yE7UVXcXm3 The key point here is that all the RHS of the `Cross` function must be evaluated before the LHS is assigned. But I need to have a guarantee that we won't assign before having evaluated the LHS. -- You received this message because you are subscribed to the

Re: [go-nuts] export struct method to C-code as callback (cgo-related)

2016-06-17 Thread andrey mirtchovski
I doubt that the cgo_callback method has the type the C library desires. from https://golang.org/ref/spec#Method_declarations: The type of a method is the type of a function with the receiver as first argument. I.e., the type of cgo_callback is func(a *A, ...). The solution is to have

Re: [go-nuts] Re: [ANN] primegen.go: Sieve of Atkin prime number generator

2016-06-17 Thread
On Friday, June 17, 2016 at 4:48:06 PM UTC+2, gordo...@gmail.com wrote: > > I don't see the point to the exercise as far as optimizing golang is > concerned. It is a general rule that using more registers results in faster code. > Your experiment just shows that Your compiler (GCC?) My post

[go-nuts] Re: When should I use the connection pool?

2016-06-17 Thread Ain
On Friday, June 17, 2016 at 5:32:25 PM UTC+3, Danilo Cicerone wrote: > > Hi to all, > I'm new here and using golang too. I've read some articles and post on > Connection Pooling" but I'm still confused. What I'm looking for is a rule > of thumb that make me easy to decide when use connection po

Re: [go-nuts] Re: [ANN] primegen.go: Sieve of Atkin prime number generator

2016-06-17 Thread gordonbgood
I don't see the point to the exercise as far as optimizing golang is concerned. Your experiment just shows that Your compiler (GCC?) missed an optimization as far as reducing backend latency goes. You may also find that swapping the order of some of the instructions such as the second and the

Re: [go-nuts] Re: [ANN] primegen.go: Sieve of Atkin prime number generator

2016-06-17 Thread gordonbgood
I don't see the point to the exercise as far as optimizing golang is concerned. Your experiment just shows that Your compiler (GCC?) missed an optimization as far as reducing backend latency goes. You may also find that swapping the order of some of the instructions such as the second and the

[go-nuts] Re: Currying in Go

2016-06-17 Thread Evan Digby
Currying is translating the evaluation of a function with multiple arguments into evaluating a sequence of functions with one argument. Not sure how this doesn't qualify, even if a closure was used to accomplish this. As for the value, at the very least there is the same value as using closures

[go-nuts] export struct method to C-code as callback (cgo-related)

2016-06-17 Thread andrey
Hello, Could you guys please help me. I can't find how to export method function which belongs to some go-struct to C-code (cgo part) as callback. I know how to export simple function which not belongs to any type and use it as callback for C-function, but is it possibly to export method of c

[go-nuts] When should I use the connection pool?

2016-06-17 Thread cydside
Hi to all, I'm new here and using golang too. I've read some articles and post on Connection Pooling" but I'm still confused. What I'm looking for is a rule of thumb that make me easy to decide when use connection pool. My scenario isn't so complicated: - a web application that makes CRUD ope

[go-nuts] Gomobile: Large .so/aar file sizes on Android

2016-06-17 Thread rajiivkanchan
Hi All I am using Go version 1.6.2 and Gomobile (sha +6b7a416 from the tip) and to build an Android library. Our code is mostly networking "encoding/json" "fmt" "log" "math/rand" "net" "sort" "time" -- You received this message because you are subscribed to the Google Groups "golang-nuts"

Re: [go-nuts] Detecting address family of net.IP

2016-06-17 Thread 'Paul Borman' via golang-nuts
Yes, To16 gives you a 16 byte version of an IP address, which can be IPv4 or IPv6. Normally it is sufficient to just call To4 to determine if it is an IPv4 address or not and assume if it is not it must be an IPv6 address: func IsIPv4(ip net.IP) bool { return ip.To4() != nil } func IsIPv6(ip net.

Re: [go-nuts] Re: [ANN] primegen.go: Sieve of Atkin prime number generator

2016-06-17 Thread
On Friday, June 17, 2016 at 3:52:27 PM UTC+2, gordo...@gmail.com wrote: > > I don't see the point of the exercise other than it proves that not > putting the result of an operation back into the same register reduces the > latency slightly for your processor (whatever it is?); I suspect that if

Re: [go-nuts] Re: [ANN] primegen.go: Sieve of Atkin prime number generator

2016-06-17 Thread gordonbgood
I don't see the point of the exercise other than it proves that not putting the result of an operation back into the same register reduces the latency slightly for your processor (whatever it is?); I suspect that if you used any other register such as the unused AX register rather then the R11 r

Re: [go-nuts] Re: [ANN] primegen.go: Sieve of Atkin prime number generator

2016-06-17 Thread
On Friday, June 17, 2016 at 2:30:12 AM UTC+2, gordo...@gmail.com wrote: > > > Modern x86 CPUs don't work like that. > > > In general, optimally scheduled assembly code which uses more registers > has higher performance than optimally scheduled assembly code which uses > smaller number of registe

[go-nuts] Re: Go 1.7 Beta 2 is released

2016-06-17 Thread paraiso . marc
Thanks, is there a way to know what to expect in later versions ( 1.8,1.9,1.10 and so forth ... ) ? Le vendredi 17 juin 2016 01:15:18 UTC+2, Chris Broadfoot a écrit : > > Hello gophers, > > We have just released go1.7beta2, a beta version of Go 1.7. > It is cut from the master branch at the revi

[go-nuts] Re: How to manage a web portal with multiple services without stopping and restarting everything at each release/fix?

2016-06-17 Thread Romano
Hi Tamás, thanks, I will have a look. I guess and hope that this is what I need. @Simon: thanks for the response with so many details. I have been working for years for projects with load balancers, HA, disaster recovery sites, and so on so your detailed answer can be really helpful to understan

[go-nuts] Re: Testing best practice: passing and failing test

2016-06-17 Thread paraiso . marc
By the way, Go 1.7 support subtests : https://tip.golang.org/pkg/testing/#hdr-Subtests_and_Sub_benchmarks Which is one of the nicest additions to Go 1.7 Le jeudi 16 juin 2016 16:04:11 UTC+2, Rayland a écrit : > > Let's say I have some piece of code like this: > > type Foo struct { > } > > func

[go-nuts] Re: Currying in Go

2016-06-17 Thread paraiso . marc
What is the point of doing that in a language that doesn't support auto currying ? There is none. You are not currying anything by the way, you just wrote 3 closures. Le vendredi 17 juin 2016 00:00:43 UTC+2, Zauberkraut a écrit : > > Hello, > > Go enables the evaluation of functions using curry

[go-nuts] Re: polymorphism (for Go 2.0), new fast playground is live

2016-06-17 Thread charraster
On Thursday, June 16, 2016 at 3:20:10 PM UTC+2, Sean Russell wrote: > > I'm sorry -- the "share" button doesn't seem to be working, or doesn't > work in Firefox or Chrome. And I have a window hung on "waiting for remote > server," so I might have broken your playground. > TL:DR type conver

[go-nuts] Re: How to manage a web portal with multiple services without stopping and restarting everything at each release/fix?

2016-06-17 Thread Simon Ritchie
This is not a question about Go, but basic web infrastructure. However, it's one of those "best practice" questions which "everybody knows the answer to" and so you may be hard put to find out more without knowing where to start. First of all, I should point out that when you tweak your PHP pa

Re: [go-nuts] Re: [ANN] primegen.go: Sieve of Atkin prime number generator

2016-06-17 Thread gordonbgood
> Looks like something is wrong with immediate loading for the 1 << ... > operation. Could you open a bug with repro instructions? I can look at it > when 1.8 opens. I have opened a golang issue #16092 as follows: https://github.com/golang/go/issues/16092 I may have over-complicated it, but

[go-nuts] Re: map memory usage question

2016-06-17 Thread Egon
On Friday, 17 June 2016 02:59:49 UTC+3, kortschak wrote: > > I'm running a terabyte-scale (minor compiler changes are necessary to get > this to run) genome resequencing simulation at the moment and an > interesting question has arisen. > The simulation involved hashing over ~all positions of a g

[go-nuts] Re: Golang Error - When marshelling data

2016-06-17 Thread User123
Have found the cause of the issue The message that I was trying to marshall had *0x10a3c2d0 (when fmt.Println) *which was http response. >From https://github.com/revel/revel/issues/1037 i found that *Since Go 1.6 http.Request struct contains `Cancel <-chan struct{}` which* *results in `json: