Re: [go-nuts] Re: time.Parse with millisecond separated by colon

2017-10-30 Thread Diego Medina
Thanks, for our case, it will be easy enough to just change : for . and move on from there. Thanks On Monday, October 30, 2017 at 4:55:03 PM UTC-4, Rob 'Commander' Pike wrote: > > Or you could change the : to a . and use time.Parse. > > -rob > > > On Tue, Oct 31, 2017 at 4:47 AM, Jim Cote

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

2017-10-30 Thread Jesse McNelis
On Tue, Oct 31, 2017 at 2:25 AM, wrote: > I found this a little bit non sequitur - if I want to call interface > function I have a perfect business to check if underlying object is not nil > before call just to avoid panic on call. Besides underlying nil in interface > may be

Re: [go-nuts] Re: time.Parse with millisecond separated by colon

2017-10-30 Thread Rob Pike
Or you could change the : to a . and use time.Parse. -rob On Tue, Oct 31, 2017 at 4:47 AM, Jim Cote wrote: > See https://golang.org/src/time/format.go?s=23626:23672#L249. The > standard library is explicitly looking for the period. Your easiest > solution would be to

Re: [go-nuts] http server request queue

2017-10-30 Thread Jonathan Yu
chi includes a middleware for this, see: https://github.com/go-chi/chi/blob/master/middleware/throttle.go and some examples here: https://github.com/go-chi/chi/blob/master/_examples/limits/main.go I haven't used it myself, but it seems to support having a fixed backlog as well, which is important

[go-nuts] Re: Why cmd/compile/internal/syntax is not using go/ast ?

2017-10-30 Thread Dave Cheney
The short version is the former was written before the Go compiler was ported to Go. The longer story is laid out in this presentation from 2014. https://www.youtube.com/watch?v=QIE5nV5fDwA On Tuesday, 31 October 2017 04:30:06 UTC+11, Abyx wrote: > > Golang has two parsers. go/* for "go fmt",

Re: [go-nuts] mutual exclusion algorithm of Dijkstra - strange behaviour

2017-10-30 Thread Jan Mercl
On Mon, Oct 30, 2017 at 6:29 PM wrote: > I noticed a very strange effect by translating the > mutual exclusion algorithm of E. W. Dijkstra to Go. For every combination of lines A/B present/not present, the program has data races, so there's nothing to reason about. You

[go-nuts] Re: time.Parse with millisecond separated by colon

2017-10-30 Thread Jim Cote
See https://golang.org/src/time/format.go?s=23626:23672#L249. The standard library is explicitly looking for the period. Your easiest solution would be to just write your own parser. On Monday, October 30, 2017 at 11:20:51 AM UTC-4, Diego Medina wrote: > > Hi, > > I need to parse datetime

Re: [go-nuts] mutual exclusion algorithm of Dijkstra - strange behaviour

2017-10-30 Thread Henrik Johansson
I think it's the non-preemptive scheduler that hits you. Afaik it is a known behavior that I am not sure how to fix. I did not at all look at the solution itself. mån 30 okt. 2017 kl 18:29 skrev : > Dear Go-community, > > I noticed a very strange effect by translating the

[go-nuts] mutual exclusion algorithm of Dijkstra - strange behaviour

2017-10-30 Thread dr . ch . maurer
Dear Go-community, I noticed a very strange effect by translating the mutual exclusion algorithm of E. W. Dijkstra to Go. Reference: Cooperating Sequential Processes. Technical Report EWD-123, Technological University Eindhoven (1965) http://www.cs.utexas.edu/users/EWD/ewd01xx/EWD123.PDF)

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

2017-10-30 Thread tmpbox
I found this a little bit non sequitur - if I want to call interface function I have a perfect business to check if underlying object is not nil before call just to avoid panic on call. Besides underlying nil in interface may be used to signal condition for variety of types implementing this

[go-nuts] time.Parse with millisecond separated by colon

2017-10-30 Thread Diego Medina
Hi, I need to parse datetime data given in a csv file, the format I get (I get a lot of diff ones but the latest is): 20060102 15:04:05:000 but if I use that with time.Parse, it doesn't parse the millisecond part, tells me: parsing time "20170628 12:11:00:103" as "20060102 15:04:05:000":

[go-nuts] golang.org/x/net/websocket, getting hot CPU while reading

2017-10-30 Thread Val
Hello Vladimir, first you must check errors returned by all calls of Receive and Send. Better break the loop if error is not nil. -- 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,

Re: [go-nuts] An efficient algorithm to write binary data

2017-10-30 Thread roger peppe
Something like this is a bit simpler, avoids the need for unsafe, and may be a little faster too: https://play.golang.org/p/4jayHwLroR It may be quicker to use a type switch: https://play.golang.org/p/4uu2XeVM9m It's a pity that about the need for a dynamic type conversion on every field, but the

[go-nuts] Re: Notify The Completion And Provide Result - And The Extra Notification Of Closing a Channel

2017-10-30 Thread dc0d
Thanks! Seems to be the best solution. I just wanted to check what should be done; in such situations which that extra signaling about closing channel is undesirable. Actually since there is a timeout element too, here a method is used (func (p *Payload) WaitResult(timeout ...time.Duration)

[go-nuts] Re: go version 1.9 - not able to build

2017-10-30 Thread desaiabhijit
Go it working.. MAC installed "go 1.9" executable in /usr/local/bin which was overriding the /usr/local/go/bin "go" executable Removed it and things works fine now Thanks On Monday, October 30, 2017 at 4:24:22 PM UTC+5:30, Abhijit Desai wrote: > > Thanks for the help Dave > > Let me check

[go-nuts] Re: go version 1.9 - not able to build

2017-10-30 Thread desaiabhijit
still no luck... not sure where this coming from go version go version go1.9.2 darwin/amd64 On Monday, October 30, 2017 at 4:14:27 PM UTC+5:30, Dave Cheney wrote: > > Please unset GOROOT, that is the root of the problems with your > installation. Then follow the instructions above. -- You

[go-nuts] Re: go version 1.9 - not able to build

2017-10-30 Thread desaiabhijit
Thanks for the help Dave Let me check Rgds Abhi On Monday, October 30, 2017 at 4:14:27 PM UTC+5:30, Dave Cheney wrote: > > Please unset GOROOT, that is the root of the problems with your > installation. Then follow the instructions above. -- You received this message because you are

[go-nuts] Re: go version 1.9 - not able to build

2017-10-30 Thread Lucio
That's not true. I frequently build, as below, a single executable from a choice of a few in the same directory. Works a treat. Lucio. On Monday, 30 October 2017 11:13:52 UTC+2, Volker Dobler wrote: > > $ go build a.go >> > > go build works on packages (or paths, not on files). > > V. > > > --

[go-nuts] Re: go version 1.9 - not able to build

2017-10-30 Thread Dave Cheney
Please unset GOROOT, that is the root of the problems with your installation. Then follow the instructions above. -- 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

[go-nuts] Re: go version 1.9 - not able to build

2017-10-30 Thread desaiabhijit
$ which go /usr/local/bin/go $ sudo vi $HOME/.profile export GOPATH=$HOME/work export PATH=$PATH:/usr/local/go/bin export GOROOT=/usr/local/go export PATH="$HOME/.cargo/bin:$PATH" On Monday, October 30, 2017 at 3:51:30 PM UTC+5:30, Dave Cheney wrote: > > Do you have GOROOT set? I set

[go-nuts] Re: go version 1.9 - not able to build

2017-10-30 Thread Dave Cheney
Do you have GOROOT set? I set it What does ‘which go’ return? -- 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

[go-nuts] Re: go version 1.9 - not able to build

2017-10-30 Thread desaiabhijit
Deleted usr/local/go and copied/extracted go1.7.4.darwin-amd64.tar.gz usr/local/go/VERSION file shows go1.7.4 but go version still showing version 1.9.2 Don't know where it's coming from Any idea? go version go version go1.9.2 darwin/amd64 $ go env GOARCH="amd64" GOBIN="" GOEXE=""

[go-nuts] Re: go version 1.9 - not able to build

2017-10-30 Thread Dave Cheney
It looks like your using OS X, which doesn’t ship with any version of Go that I know of. Nevertheless the uninstall operation is simple, just delete /usr/local/go and follow the installation instructions on the website. -- You received this message because you are subscribed to the Google

[go-nuts] Re: go version 1.9 - not able to build

2017-10-30 Thread desaiabhijit
Updated OS os... so I think it's auto installed 1.9 version over 1.7 How to remove it? or any solution? Please help Thanks, Abhi On Monday, October 30, 2017 at 2:37:45 PM UTC+5:30, Dave Cheney wrote: > > Errors like these are usually caused by either having multiple versions of > Go

[go-nuts] Re: go version 1.9 - not able to build

2017-10-30 Thread Volker Dobler
> > $ go build a.go > go build works on packages (or paths, not on files). V. -- 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-nuts] Notify The Completion And Provide Result - And The Extra Notification Of Closing a Channel

2017-10-30 Thread Dave Cheney
I think you should use a channel. If the communication is between two parities then there is no need to close the channel after sending the result as the are not other parties to inform that they missed the message. -- You received this message because you are subscribed to the Google Groups

[go-nuts] go version 1.9 - not able to build

2017-10-30 Thread Dave Cheney
Errors like these are usually caused by either having multiple versions of Go installed on your system, or overwriting one version of Go with another. how did you upgrade Go on this machine? How was the previous version installed? -- You received this message because you are subscribed to the

[go-nuts] go version 1.9 - not able to build

2017-10-30 Thread desaiabhijit
Mac is upgraded to 1.9.2 version and suddenly not able to build the simple program package main import ( "fmt" ) func main() { fmt.Printf("TEST") } Please help $ go build a.go # command-line-arguments flag provided but not defined: -goversion usage: compile

[go-nuts] Re: concurrency programing about go

2017-10-30 Thread snmed
Hi There are several ways to solve it, here are two of them: https://play.golang.org/p/wJwkI7HQwv https://play.golang.org/p/nasUcgBeG4 I prefer the first one, because so I can decide if i want to wait for the end of twoprint or not. Cheers Am Montag, 30. Oktober 2017 06:43:45 UTC+1 schrieb

[go-nuts] Re: Notify The Completion And Provide Result - And The Extra Notification Of Closing a Channel

2017-10-30 Thread dc0d
BTW currently a private channel with length of 1 is being used and the other side must call a function to get the result (with a timeout). This way the second signal about closing the channel is not a problem. And we see this inside the standard library too, like in the time channel of a

[go-nuts] Notify The Completion And Provide Result - And The Extra Notification Of Closing a Channel

2017-10-30 Thread dc0d
Problem: After the completion of some task, the task issuer should be informed about the completion/failure of the task - like by using some struct { Result Result, Err error }. Question: Which mechanism is preferred: using channels or callbacks? Why the question: IMHO channels are the answer

Re: [go-nuts] Re: select is still a little unfair if there are more than 4 cases?

2017-10-30 Thread Sokolov Yura
> it would be great to move to pcg. Why? PCG isn't faster, isn't simpler and isn't better (though not worse either). -- 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

Re: [go-nuts] Re: select is still a little unfair if there are more than 4 cases?

2017-10-30 Thread Jérôme LAFORGE
Thx Giovanni, it is clear now. -- 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

[go-nuts] network programming about go

2017-10-30 Thread 2891132love
I write this code in the follwings: package main import ( "fmt" "net" "os" ) func main() { service := ":5000" tcpAddr, err := net.ResolveTCPAddr("tcp", service) checkError(err) listener, err := net.ListenTCP("tcp", tcpAddr) checkError(err) for i := 0; i < 10; i++ { conn, err := listener.Accept()

[go-nuts] Is there a way or lib to read a binary into a sturct{len int32;data [len]int32}

2017-10-30 Thread hui zhang
type variastrt struct { len int32 data []int32 // data length = len [len]int32 } Is there a way or lib to read a binary into a this structure in one line code? how about more complicate struct ? type complicatestrt struct { len int32 strData []variastrt } -- You received this

Re: [go-nuts] Re: select is still a little unfair if there are more than 4 cases?

2017-10-30 Thread Michael Jones
it would be great to move to pcg. careful implementation here: https://github.com/MichaelTJones/pcg extensive use for quite a while On Sun, Oct 29, 2017 at 10:11 AM, wrote: > Il giorno domenica 29 ottobre 2017 17:49:39 UTC+1, T L ha scritto: >> >> >> >> On Sunday, October