Re: [go-nuts] Re: [ANN] ws-cli - WebSocket Command Line Client

2016-09-24 Thread KwangYul Seo
Hi! Thanks for your feedback. I think it is not hard to make this program data-race free if you give up readline library. The problem lies on the fact that readline's Instance.Readline function is not go routine friendly. It is a blocking call which won't return until a line is entered or an inte

[go-nuts] Re: Sharing similar Interfaces across packages

2016-09-24 Thread question . developer
Wouldn't then the argument being passed into Less(Item) and Swap(Item) be for two different interfaces? One.Item for Less() and Two.Item for Swap(). On Saturday, September 24, 2016 at 10:31:56 PM UTC-7, Tamás Gulácsi wrote: > > You can embed the interface in two.Item: > type Item interface { >

[go-nuts] Re: Sharing similar Interfaces across packages

2016-09-24 Thread question . developer
Wouldn't then the argument being passed into Less(Item) and Swap(Item) be for two different Items? One.Item for Less() and Two.Item for Swap(). On Saturday, September 24, 2016 at 10:31:56 PM UTC-7, Tamás Gulácsi wrote: > > You can embed the interface in two.Item: > type Item interface { >

[go-nuts] Sharing similar Interfaces across packages

2016-09-24 Thread Tamás Gulácsi
You can embed the interface in two.Item: type Item interface { one.Item Len() int Swap(item Item) } -- 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 go

[go-nuts] Run a single Golang httptest server for all tests on different packages?

2016-09-24 Thread francescoaferraro
Can anyone explain me why I should attempt to do this? The below works for a single package only. func TestMain(m *testing.M) { setup() exitVal := m.Run() teardown() os.Exit(exitVal)} func setup() { flag.StringVar(&util.ServerFlag, "server", "s", "server to set request for")

[go-nuts] Sharing similar Interfaces across packages

2016-09-24 Thread question . developer
The sort.Interface is designed to operate on an indexed collection. Certain data structures may not be indexed (ex. linked list) nor do some algorithms need to expose that they are. Lets say I have one package with the following interface. package One type Item interface { Less(item Item)

[go-nuts] Re: [ANN] ws-cli - WebSocket Command Line Client

2016-09-24 Thread mhhcbon
Hi, nice exercise! I found out your version was having data races. try your program like this go run -race kseo.go -url ws://echo.websocket.org This program does not need any goroutine, imho, package main import ( "flag" "fmt" "bufio" "os" "net/http" ws "github.com/go

RE: [go-nuts] Re: Just because we can add multiple logical processors for the scheduler to use doesn’t mean we should

2016-09-24 Thread John Souvestre
Ø But A GOMAXPROCS value larger than NumberAvaliableCpuCores will always decrease the performance, IMO. Although unusual, I did have a case where it was handy to use double the value of CPUs. It was a situation where there were a number of low-priority, compute-bound processes and a bunch o

[go-nuts] Re: How to pass arbitrary typed (int, string, etc) slices to a golang function?

2016-09-24 Thread Roberto Zanotto
If you don't care about preserving the order of the elements in the slice, you can do something like this: https://play.golang.org/p/6QWxWH-Oj7 The functions I used are documented here: https://golang.org/pkg/reflect/ You may want to read this blog post about reflection: https://blog.golang.org/

Re: [go-nuts] How to generate a positive int64 from byte slice

2016-09-24 Thread JohnGB
The 32 bytes were just a product of the hash function that we were using, but I've simplified it by changing the hash function to one that only generates 8 bytes. My current solution is: func EmailToID(email, salt string) int64 { d := sha3.NewShake256() d.Write([]byte(email)) d.Write([]byte(sa

[go-nuts] Re: How to pass arbitrary typed (int, string, etc) slices to a golang function?

2016-09-24 Thread Roberto Zanotto
https://play.golang.org/p/XjcT8wFXVV On Friday, September 23, 2016 at 6:13:04 AM UTC+2, Lax Clarke wrote: > > How would someone create a function like len ? > > func Len(s []interface{}) would not work because compiler complains of > type mismatch if you call it with an integer slice (for examp

[go-nuts] Re: How to pass arbitrary typed (int, string, etc) slices to a golang function?

2016-09-24 Thread Lax Clarke
On Friday, September 23, 2016 at 12:30:36 AM UTC-4, Dave Cheney wrote: > > There are two ways, one is to use reflection, the other would be to use > unsafe to convert the slice value into another structure then extract the > length field. > > Assuming that you could write a Len function as you

[go-nuts] [ANN] ws-cli - WebSocket Command Line Client

2016-09-24 Thread KwangYul Seo
Hello, I am happy to announce the release of the ws-cli, a simple WebSocket command line client written in Go. https://github.com/kseo/ws-cli # Installation go get github.com/kseo/ws-cli # Usage $ we-cli -url ws://echo.websocket.org connected (press CTRL+C to quit) > hi there < hi there > ar

[go-nuts] x/tools/cmd/gotype: invalid encoding format in export data: got 'v'; want 'c' or 'd'

2016-09-24 Thread Albert Nigmatzianov
When I use gotype, it says: version.go:8:2: could not import github.com/bogem/nehm/ui (reading export data: /Users/albert/go/pkg/darwin_amd64/github.com/bogem/nehm/ui.a: invalid encoding format in export data: got 'v'; want 'c' or 'd') version.go:9:2: could not import github.com/spf13/cobra (read

[go-nuts] Re: Trying to understand GOPATH

2016-09-24 Thread Simon Ritchie
This could be a bit better explained on the golang website. First, note that there are potentially three environment variables involved: PATH; GOROOT and GOPATH. The Getting Started guide (https://golang.org/doc/install#install) gives quite a lot of help, and you should read that thoroughly.

[go-nuts] Re: Just because we can add multiple logical processors for the scheduler to use doesn’t mean we should

2016-09-24 Thread T L
Usually, GOMAXPROCS==NumberAvaliableCpuCores (the default value since go1.5) will get the best performance. For some special cases, a smaller GOMAXPROCS value will perform better. But A GOMAXPROCS value larger than NumberAvaliableCpuCores will always decrease the performance, IMO. On Friday, Se

[go-nuts] Just because we can add multiple logical processors for the scheduler to use doesn’t mean we should

2016-09-24 Thread 'Ingo Oeser' via golang-nuts
The default of using only one thread to run goroutines default changed with Go 1.5 to using all available cores reported by the OS. Tuning GOMAXPROCS has now less relevance in practice, rendering the article as outdated in that regard. Just leave the GOMAXPROCS settings alone until a strong use

Re: [go-nuts] Re: Adding YAML to the stdlib

2016-09-24 Thread 'Axel Wagner' via golang-nuts
a) A package doesn't need to be in the stdlib to have more than one maintainer. If you believe go-yaml needs more maintenance, you can either ask Gustavo to give more people push-access, or create a better-maintained fork. There are tons of go projects out there that are well-maintained by a vibran

[go-nuts] Refer a different package from the godoc of a package

2016-09-24 Thread Debraj Manna
Can someone let me if it is possible to refer a different package from godoc of a package? For example let's say I have a package src/logger/. In src/logger/doc.go I need to refer src/config/. Something like @see in javadoc. Is there a recommended way? I am on Go 1.7. -- You received this messa

[go-nuts] Re: Adding YAML to the stdlib

2016-09-24 Thread paraiso . marc
Anybody can write a spec and deem it a standard. YAML is certainly not a common data serialization format. Adding a YAML parser is in my opinion the least of of Go's priorities when one can see all the packages pilling up @ /x/ namespace that should have been in the stdlib already. More tools s