Re: [go-nuts] golang maps; using slice as a key

2018-05-22 Thread Sankar P
> > Use an array instead of a slice. An array has a fixed size and can be used > as a key to a map > > https://play.golang.org/p/xxxmrwpx08A > This seem to not work. The arr is returning only duplicate elements in your playground url. For example: var arr [][]int for mem := range m { fmt.

[go-nuts] Re: I am confused.

2018-05-22 Thread John
Is the visual code studio an compiler or a what, I tried it myself but I isn't able to program. -- 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+unsu

[go-nuts] Re: how do i upgrade to latest version of go?

2018-05-22 Thread Tamás Gulácsi
rm -rf ~/go/src Then extract again. -- 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://grou

Re: [go-nuts] golang maps; using slice as a key

2018-05-22 Thread Bakul Shah
On Tue, 22 May 2018 10:59:24 -0700 Sankar wrote: > > Is there a way to use a slice as a key to a map ? If I try, I get a > compilation error: `invalid map key type`. > > I tried creating a custom type, which contains an array as the element. > However, I could not find out what method to impl

Re: [go-nuts] Why doesn't this select statement timeout?

2018-05-22 Thread ag
That clarifies it. Thanks! On Tuesday, May 22, 2018 at 5:29:43 PM UTC-7, alex@gmail.com wrote: > > https://golang.org/ref/spec#Select_statements > > Execution of a "select" statement proceeds in several steps: >> >>1. For all the cases in the statement, the channel operands of >>recei

Re: [go-nuts] Why doesn't this select statement timeout?

2018-05-22 Thread alex . rou . sg
https://golang.org/ref/spec#Select_statements Execution of a "select" statement proceeds in several steps: > >1. For all the cases in the statement, the channel operands of receive >operations and the channel and right-hand-side expressions of send >statements are evaluated exactly o

Re: [go-nuts] Why doesn't this select statement timeout?

2018-05-22 Thread ag
This is interesting and I still don't get why it's not working. I modified the code a bit and expected it to immediately break out of select but it still waits for http calls to finish https://play.golang.org/p/z1mmqpQtOre package main import ( "errors" "fmt" "net/http" "net/http/httptest" "ti

[go-nuts] Re: how do i upgrade to latest version of go?

2018-05-22 Thread Lucas Simon Rodrigues Magalhaes
Hi, I'm having trouble updating the version through source code. export GOROOT_BOOTSTRAP=/home/lucas/go1.4 export GOROOT=$HOME/go export GOPATH=$HOME/workspace-go export PATH=$PATH:$GOROOT/bin:$GOPATH/bin $ go version go version go1.8.3 linux/amd64 When i run ./all.bash $ ./all.bash Building

[go-nuts] add Printfln to log and fmt

2018-05-22 Thread ricky . nj
I have a rather simple request - I am not sure if this already exists but I'd like to avoid typing "\n" everytime I do Printf( ) even though I quite enjoy doing that. Is there an inbuilt library function that does this? Thanks Anirudh -- You received this message because you are subscribed to

[go-nuts] What is Spinning thread doing in go scheduler

2018-05-22 Thread Ming Hu
Hi I am reading the design of go scheduler, and don't quite understand this in "Scalable Go Scheduler Design Doc" https://docs.google.com/document/d/1TTj4T2JO42uD5ID9e89oa0sLKhJYD0Y_kqxDv3I3XMw/edit# Spinning is mostly passive (yield to OS, sched_yield()), but may include a > little bit of act

[go-nuts] Printfln on fmt and log

2018-05-22 Thread Anirudh Vyas
Hi - I want to have a Printfln on log and fmt - Currently I use fmt.Printf( " yada yada \n", some_yada_yada) to achieve same effect. Is there a plan to add this simple yet extremely useful function? Thanks Anirudh -- You received this message because you are subscribed to the Google Groups

[go-nuts] Re: From PHP to Go, here my first side project. What do you think?

2018-05-22 Thread matthewjuran
Hello, here’s a code review. Thanks for sharing here. These are my unfiltered opinions that may be wrong, and I hope they are useful for you. Have you considered including an open source license like BSD? There’s a base GitHub license applied now. func CreateRelative( path string, conf

Re: [go-nuts] golang maps; using slice as a key

2018-05-22 Thread Justin Israel
On Wed, May 23, 2018, 5:59 AM Sankar wrote: > Is there a way to use a slice as a key to a map ? If I try, I get a > compilation error: `invalid map key type`. > > I tried creating a custom type, which contains an array as the element. > However, I could not find out what method to implement for m

[go-nuts] Re: golang maps; using slice as a key

2018-05-22 Thread Volker Dobler
No, sorry, slices cannot be used as map keys. Also note that equality is not dependent on methods and not user changeable but solely determined by the language spec. If you can derive e.g. a string from the slice and use that string as the map key you would be fine. V. On Tuesday, 22 May 2018 19

Re: [go-nuts] vgo and vanity imports

2018-05-22 Thread Paul Jolly
Tangentially related (I think): https://github.com/golang/go/issues/24751 On Tue, 22 May 2018 at 19:10, Nate Finch wrote: > Forgive me if this has been answered somewhere. I tried to divine it from > Russ' documents, but I couldn't really tell. > > Do vanity imports change dramatically with vgo

[go-nuts] vgo and vanity imports

2018-05-22 Thread Nate Finch
Forgive me if this has been answered somewhere. I tried to divine it from Russ' documents, but I couldn't really tell. Do vanity imports change dramatically with vgo? Currently, all I have to do to support a vanity import is to return a page at https://gnorm.org/gnorm that has a meta element

[go-nuts] golang maps; using slice as a key

2018-05-22 Thread Sankar
Is there a way to use a slice as a key to a map ? If I try, I get a compilation error: `invalid map key type`. I tried creating a custom type, which contains an array as the element. However, I could not find out what method to implement for my custom type(such as: func (i *myType) Equal(j *my

Re: [go-nuts] Performance hit when using goroutine

2018-05-22 Thread Dave Cheney
The execution tracer will show this as it tracks resources that goroutines block on. Seriously I’m just going to keep suggesting the execution tracer until you try it :) -- You received this message because you are subscribed to the Google Groups "golang-nuts" group. To unsubscribe from this

Re: [go-nuts] Performance hit when using goroutine

2018-05-22 Thread Burak Serdar
On Tue, May 22, 2018 at 12:21 AM, Hawari Rahman wrote: > Hi Burak, > > Thank you for your reply, > Inside the HydrateCollection function there are database queries (at least > three), run using the same *sql.DB throughout the application. > >> Is it possible that >> whatever connection HydrateColl

[go-nuts] Re: Chasing high coverage with os level packages

2018-05-22 Thread ekocjan
I've found a solution, but it's not as nice as interfaces: Injectable function type: func(l *eventlog.Log, eid uint32, msg string) error Struct methods convert directly to this type without wrappers: (* eventlog.Log).Info and (*eventlog.Log).Error On Tuesday, May 22, 2018 at 12:46:28 PM UTC+2, e

[go-nuts] Chasing high coverage with os level packages

2018-05-22 Thread ekocjan
Let's say I want to unit test code that is using eventlog.Open: https://godoc.org/golang.org/x/sys/windows/svc/eventlog#Open First I define an interface that matches eventlog.Log: type WindowsEventLogger interface { Info(eid uint32, msg string) error Error(eid uint32, msg string) error }

[go-nuts] Re: Processing test json data

2018-05-22 Thread Karan Chaudhary
Will this help? https://github.com/aaronbriel/jsonjunit I haven't tried it but piping the json output to jsonjunit can help. On Saturday, 19 May 2018 19:55:24 UTC+5:30, Vedu Joshi wrote: > > I see that in go1.10, we can have json formatted "go test" output (by > using -json flag) > I googled aro

[go-nuts] Re: Performance hit when using goroutine

2018-05-22 Thread Hawari Rahman
Hi Dave, Yeah, I guess that's the way I'm going to go now. By the way, about the usage of the channels in my snippet, is there any catch from that? On Tuesday, May 22, 2018 at 3:46:13 PM UTC+7, Dave Cheney wrote: > > The best tool to investigate this problem is the execution tracer. It will > s

Re: [go-nuts] Performance hit when using goroutine

2018-05-22 Thread Hawari Rahman
Hi Justin, Yes, it is using index scan, which makes me even more puzzled. On Tuesday, May 22, 2018 at 3:45:29 PM UTC+7, Justin Israel wrote: > > > > On Tue, May 22, 2018, 6:35 PM Hawari Rahman > wrote: > >> After some more detailed investigation, it seems the most time consuming >> process is a

[go-nuts] Performance hit when using goroutine

2018-05-22 Thread Dave Cheney
The best tool to investigate this problem is the execution tracer. It will show you the activity of goroutines over time making is easy to spot contention. -- You received this message because you are subscribed to the Google Groups "golang-nuts" group. To unsubscribe from this group and stop

Re: [go-nuts] Performance hit when using goroutine

2018-05-22 Thread Justin Israel
On Tue, May 22, 2018, 6:35 PM Hawari Rahman wrote: > After some more detailed investigation, it seems the most time consuming > process is a "Select by IDs" query. So to hydrate a Collection object, I > need to retrieve another objects through a SELECT WHERE id = ANY(?)" query > in postgres. I'm