Re: [go-nuts] Re: [Request] Official golang debugger

2017-11-06 Thread Dave Cheney
If you reported an issue today, Nov 6, you could be waiting nearly 9 months to see a fix in the next released version of Go. A project living outside the standard library has little going against it other than you have to compile it yourself. On Tuesday, 7 November 2017 18:28:09 UTC+11,

Re: [go-nuts] Re: [Request] Official golang debugger

2017-11-06 Thread Sotirios Mantziaris
I do not know if the times you mentioned are indeed that long. If it is true then you actually have a good argument. On Tuesday, November 7, 2017 at 9:20:08 AM UTC+2, Florin Pățan wrote: > > I hope not. Anything that ends up in the toolchain is slow to change and > adapt to user needs. If I have

Re: [go-nuts] network programming about go

2017-11-06 Thread Karan Chaudhary
Is the port 5000 on 192.168.153.239 open? If it is open, is your server running on that port? https://stackoverflow.com/questions/2972600/no-connection-could-be-made-because-the-target-machine-actively-refused-it On Monday, 6 November 2017 19:30:22 UTC+5:30, 28911...@gmail.com wrote: > > I

Re: [go-nuts] Re: [Request] Official golang debugger

2017-11-06 Thread Florin Pățan
I hope not. Anything that ends up in the toolchain is slow to change and adapt to user needs. If I have a problem with delve today, I can post an issue, fix it and get the next version of delve az quick as a few hours. If it would be in the toolchain it could take up to six months to get it

[go-nuts] Re: [Request] Official golang debugger

2017-11-06 Thread Sotirios Mantziaris
Yes i know that, but i wonder if it is time to fully integrate delve in the go toolchain and ship it with every release like dep, which exists in another repository, but will be fullly integrated into the toolchain and the releases in some future version. On Tuesday, November 7, 2017 at

[go-nuts] Re: A way to detect closed channel

2017-11-06 Thread Dave Cheney
This is not safe. https://play.golang.org/p/ax6fG_ZCE_ On Tuesday, 7 November 2017 11:59:51 UTC+11, Albert Tedja wrote: > > So, I just found out that closed channels always yield the zero value. > That means, a closed channel inside a select statement seems to always be > guaranteed to be

Re: [go-nuts] Re: A way to detect closed channel

2017-11-06 Thread Dan Kortschak
This is not a good idea (and is wrong since it does not check the ok value of the receive operation). As was pointed out previously, this is only true in the instant that the select is occurring. On Mon, 2017-11-06 at 18:39 -0800, sheepbao wrote: > func isClose() bool { >     select { >     case

[go-nuts] Re: A way to detect closed channel

2017-11-06 Thread sheepbao
func isClose() bool { select { case <-closeChan: return true default: return false } } 在 2017年11月7日星期二 UTC+8上午8:59:51,Albert Tedja写道: > > So, I just found out that closed channels always yield the zero value. > That means, a closed channel inside a select

Re: [go-nuts] A way to detect closed channel

2017-11-06 Thread Albert Tedja
That makes sense. If multiple goroutines are calling that select block, one or more could be attempting to close it. Okay, nevermind then. -- You received this message because you are subscribed to the Google Groups "golang-nuts" group. To unsubscribe from this group and stop receiving

Re: [go-nuts] A way to detect closed channel

2017-11-06 Thread Daniel Skinner
meaning, don't call that select+code block from multiple goroutines. If on the other-hand that block is always called from the same goroutine, then it will do what you want, but that may be a slippery slope depending on what you're writing. On Mon, Nov 6, 2017 at 7:33 PM Dan Kortschak

Re: [go-nuts] A way to detect closed channel

2017-11-06 Thread Dan Kortschak
No. The complete select+code blocks is not atomic, so the select may see that closedchan is not closed, execute the default case, but in the mean time closedchan has been closed by someone else. Bang! On Mon, 2017-11-06 at 16:59 -0800, Albert Tedja wrote: > Since closing an already closed channel

[go-nuts] Re: A way to detect closed channel

2017-11-06 Thread Albert Tedja
Assuming of course, that the channel is only intended to send closed signal to other goroutines, rather than transporting meaningful data. On Monday, November 6, 2017 at 4:59:51 PM UTC-8, Albert Tedja wrote: > > So, I just found out that closed channels always yield the zero value. > That

[go-nuts] A way to detect closed channel

2017-11-06 Thread Albert Tedja
So, I just found out that closed channels always yield the zero value. That means, a closed channel inside a select statement seems to always be guaranteed to be executed. Since closing an already closed channel creates a panic, does this mean then I can do this to make sure that the channel

[go-nuts] [Request] Official golang debugger

2017-11-06 Thread Florin Pățan
Delve is the one towards which the community rally since gdb, still, doesn't play nice with goroutines. So, for all intents and purposes, delve is the official debugger and the Go Team and Delve Team do work together to give us a better debugging experience. But sometimes the problems that need

Re: [go-nuts] type returned by reflect.ArrayOf breaks the spec

2017-11-06 Thread Ian Lance Taylor
On Mon, Nov 6, 2017 at 2:50 PM, Josh Humphries wrote: > > I think I've found a bug regarding reflect.ArrayOf. The go doc is a bit > light, but suggests that the resulting type is a proper array type. However, > I've found that the resulting type has a few flaws: > > The

[go-nuts] type returned by reflect.ArrayOf breaks the spec

2017-11-06 Thread Josh Humphries
I think I've found a bug regarding reflect.ArrayOf. The go doc is a bit light, but suggests that the resulting type is a proper array type. However, I've found that the resulting type has a few flaws: 1. The resulting array type violates part of the language spec about arrays: it cannot be

Re: [go-nuts] Re: Passing a string

2017-11-06 Thread Ian Lance Taylor
On Mon, Nov 6, 2017 at 2:17 PM, Chun Zhang wrote: > > Can you please give some suggestion on how to properly handle this issue? > The C++ API cannot be modified. Use C.CString as described in the cgo docs at https://golang.org/cmd/cgo . Ian > On Monday, November 6, 2017

Re: [go-nuts] Re: Passing a string

2017-11-06 Thread Chun Zhang
Thanks Ian! Can you please give some suggestion on how to properly handle this issue? The C++ API cannot be modified. Sincerely, Chun On Monday, November 6, 2017 at 3:25:13 PM UTC-5, Ian Lance Taylor wrote: > > On Mon, Nov 6, 2017 at 10:59 AM, Chun Zhang > wrote: > >

Re: [go-nuts] Re: Passing a string

2017-11-06 Thread Ian Lance Taylor
On Mon, Nov 6, 2017 at 10:59 AM, Chun Zhang wrote: > > Sorry about the confusion! My gocode set the value of the device and then > pass it to C++ code. > > Code goes like this: > > device := "eth1" // hardcoding this value works or retrieving it from Flag > as below > >

Re: [go-nuts] Re: Passing a string

2017-11-06 Thread Chun Zhang
Hi, The configuration is the structure defined as type Configuration struct { IpToSend string PortToSend string Device string } The json file is { "IpToSend" :"", "PortToSend" :"2075", "Device" : "eth1" } The output of fmt.Sprintf("%T %#v", conf,

Re: [go-nuts] How to determine the correct method signature to override fopen

2017-11-06 Thread Ian Lance Taylor
On Mon, Nov 6, 2017 at 10:58 AM, wrote: > > In that case - do you know how I can inspect the comparison it's doing? > Since I'm already doing this for the open system call, I know that it's > possible to write a function with the same definition. It seems in this case >

Re: [go-nuts] goto from inner select

2017-11-06 Thread Michael Jones
this is what you are not seeing... https://play.golang.org/p/tx9vAOnOoL On Mon, Nov 6, 2017 at 10:22 AM, wrote: > > > On Monday, November 6, 2017 at 8:03:28 PM UTC+2, Ian Lance Taylor wrote: >> >> On Mon, Nov 6, 2017 at 8:55 AM, wrote: >> > >> > Can

[go-nuts] Unescape html in template/html

2017-11-06 Thread Chad Caglak
Hi All, I am building a twitter clone to learn golang and i need to unescape the hashtag url. full source in github github.com/ccaglak/twr thanks all in advance for i, v := range gPost { h := GetHashTags(v.Post) for _, ht := range h { gPost[i].Post =

Re: [go-nuts] Re: Passing a string

2017-11-06 Thread Tamás Gulácsi
Please, can you share the complete code? What is "Configuration"? What does `fmt.Sprintf("%T %#v", conf, conf)` print? I'm not sure about the swig-generated code, is your swig new enough? -- You received this message because you are subscribed to the Google Groups "golang-nuts" group. To

Re: [go-nuts] Re: Passing a string

2017-11-06 Thread Chun Zhang
Hi, Ian, Sorry about the confusion! My gocode set the value of the device and then pass it to C++ code. Code goes like this: device := "eth1" // hardcoding this value works or retrieving it from Flag as below flag.StringVar(, "Device", "eth1", "NIC to Listen") --- lines below do

Re: [go-nuts] How to determine the correct method signature to override fopen

2017-11-06 Thread tonywalker . uk
In that case - do you know how I can inspect the comparison it's doing? Since I'm already doing this for the open system call, I know that it's possible to write a function with the same definition. It seems in this case that I'm not matching the representation that cgo is expecting. I would

Re: [go-nuts] Re: Passing a string

2017-11-06 Thread Ian Lance Taylor
On Mon, Nov 6, 2017 at 10:29 AM, Chun Zhang wrote: > Thank you Ian!! That does make sense. > > Can you please elaborate why hardcoding device = "eth1" works? What is the > difference here? I'm sorry, I'm not sure I really understand the question. The pointer passing rules

Re: [go-nuts] Re: Passing a string

2017-11-06 Thread Chun Zhang
Thank you Ian!! That does make sense. Can you please elaborate why hardcoding device = "eth1" works? What is the difference here? Sincerely, Chun On Mon, Nov 6, 2017 at 1:19 PM, Ian Lance Taylor wrote: > On Mon, Nov 6, 2017 at 4:25 AM, Chun Zhang wrote:

Re: [go-nuts] goto from inner select

2017-11-06 Thread djadala
On Monday, November 6, 2017 at 8:03:28 PM UTC+2, Ian Lance Taylor wrote: > > On Mon, Nov 6, 2017 at 8:55 AM, wrote: > > > > Can someone explain, is this program is really incorrect: > > https://play.golang.org/p/0fp9Nt_99L > > > > trying to run it results in error: >

Re: [go-nuts] Re: Passing a string

2017-11-06 Thread Ian Lance Taylor
On Mon, Nov 6, 2017 at 4:25 AM, Chun Zhang wrote: > > Thank you for the reply! > > The C libi.PI_init_global_config has the interface of > PI_init_global_config(int argc, char *argv[]); > so Swig converts it to PI_init_global_config(arg1 int, arg2 *string) > > The code was

Re: [go-nuts] goto from inner select

2017-11-06 Thread Ian Lance Taylor
On Mon, Nov 6, 2017 at 8:55 AM, wrote: > > Can someone explain, is this program is really incorrect: > https://play.golang.org/p/0fp9Nt_99L > > trying to run it results in error: > tmp/sandbox536393528/main.go:16:9: goto C jumps into block starting at >

[go-nuts] goto from inner select

2017-11-06 Thread djadala
Hi all, Can someone explain, is this program is really incorrect: https://play.golang.org/p/0fp9Nt_99L trying to run it results in error: tmp/sandbox536393528/main.go:16:9: goto C jumps into block starting at tmp/sandbox536393528/main.go:10:2 but goto jumps in outside block. I trying to make

Re: [go-nuts] Urgent: race condition with ticker channels

2017-11-06 Thread Ian Davis
On Mon, 6 Nov 2017, at 12:14 PM, arunabh.ar...@gmail.com wrote: > Hi, > > I am fairly new to Golang, so please excuse if this is a silly > question. I could not find any answers on the web.> > Code portion A: > > rf.mu.Lock() > rf.electionTicker = time.NewTicker(rf.currentTimeout) >

[go-nuts] Urgent: race condition with ticker channels

2017-11-06 Thread arunabh . arnav
Hi, I am fairly new to Golang, so please excuse if this is a silly question. I could not find any answers on the web. Code portion A: rf.mu.Lock() rf.electionTicker = time.NewTicker(rf.currentTimeout)

Re: [go-nuts] network programming about go

2017-11-06 Thread 2891132love
I try to modify the program,but the result is: host:portfatal error: dial tcp 192.168.153.239:5000: connectex: No connection could be made because the target machine actively refused it.exit status 1.How to solve it?? 在 2017年11月6日星期一 UTC+8下午5:08:26,rog写道: > On 30 October 2017 at 06:55,

[go-nuts] Re: how could a new user konw which packge should be used?

2017-11-06 Thread Karan Chaudhary
Oh, didn't check that! On Monday, 6 November 2017 17:49:52 UTC+5:30, dja...@gmail.com wrote: > > > > On Monday, November 6, 2017 at 12:23:37 PM UTC+2, Karan Chaudhary wrote: >> >> Another one: http://go-search.org >> > > Go Search > 756881 golang packages in 171083

Re: [go-nuts] accept4: too many open files;

2017-11-06 Thread Karan Chaudhary
CMIIW, I doubt if it is explicitly needed to close the request's body in handler, as it seems, close of request's body is handled by stdlib upon completion of handler. Handler, in net/http, is called here: https://github.com/golang/go/blob/master/src/net/http/server.go#L1804 Finish

[go-nuts] Re: Passing a string

2017-11-06 Thread Chun Zhang
Hi, Thank you for the reply! The C libi.PI_init_global_config has the interface of PI_init_global_config(int argc, char *argv[]); so Swig converts it to PI_init_global_config(arg1 int, arg2 *string) The code was expecting to a *string. Viper.GetString returns a string as far as I can see,

[go-nuts] Re: how could a new user konw which packge should be used?

2017-11-06 Thread djadala
On Monday, November 6, 2017 at 12:23:37 PM UTC+2, Karan Chaudhary wrote: > > Another one: http://go-search.org > Go Search 756881 golang packages in 171083 projects indexed, last updated 265 days ago. 265 days ago. ??? No, thanks. -- You received this message

Re: [go-nuts] Go for Data science Blogs

2017-11-06 Thread Sebastien Binet
Hi, I would start with: - gonum.org - gopherdata.io I have also started a little series about how to apply Go and Gonum to stats (in high energy physics but that's just the setup) sbinet.github.io /shameless-plug off. hth, -s sent from my droid On Nov 6, 2017 10:46 AM, "Vikram Rawat"

[go-nuts] Re: how could a new user konw which packge should be used?

2017-11-06 Thread Karan Chaudhary
Another one: http://go-search.org On Friday, 3 November 2017 21:21:48 UTC+5:30, 517 March wrote: > > as a new Go programmer, > how could I know which package should be use? > > is there any search tool could be used? > > or does it just depend on your experience? > -- You received this

Re: [go-nuts] Bizarre Error Message (Go 1.9.2)

2017-11-06 Thread Karan Chaudhary
> > `go run` takes multiple files as arguments. > Interesting. Didn't know this was possible. Until now i used to fallback to using go build if code was distributed over multiple files. (When i'm testing some case which includes few files) -- You received this message because you are

Re: [go-nuts] Re: concurrency programing about go

2017-11-06 Thread Henrik Johansson
Indeed this is what I do but I learned the hard way and often it comes up as "safe" in the mailing list to not do so but while true from a memory model perspective it is, I would say, wrong to do so. mån 6 nov. 2017 kl 10:39 skrev Christoph Berger < christoph.g.ber...@gmail.com>: > Always call

Re: [go-nuts] Re: concurrency programing about go

2017-11-06 Thread Karan Chaudhary
Just a note that waitGroup should be passed as reference to functions/methods rather than as value. I have made mistakes where the program hung as Done was called on copy of waitgroup rather than on the original wg to which tasks were added. Here it is not a problem as waitgroup used within

[go-nuts] Go for Data science Blogs

2017-11-06 Thread Vikram Rawat
Is there any blog where we can start to learn Data analytics in GO. has anybody started a blog in GO. where we can learn basic data manupulation with go. -- 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] Re: concurrency programing about go

2017-11-06 Thread Christoph Berger
Always call Add() before spawning the corresponding goroutine(s). And always call Add() in the same goroutine that also calls Wait(). This way you have no race condition between Add(), Done(), and Wait(). On Saturday, November 4, 2017 at 10:46:21 AM UTC+1, Henrik Johansson wrote: > > I find

Re: [go-nuts] network programming about go

2017-11-06 Thread roger peppe
On 30 October 2017 at 06:55, <2891132l...@gmail.com> wrote: > 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 :=

[go-nuts] Re: input and output about go

2017-11-06 Thread Karan Chaudhary
You need to break the scanning by passing EOF to the program. Use ctrl-d if you're on Unix based system. go doc bufio.Scan func (s *Scanner) Scan() bool Scan advances the Scanner to the next token, which will then be available through the Bytes or Text method. It returns false when the

Re: [go-nuts] Rationale in docs on why you need to use the result of append()

2017-11-06 Thread Christoph Berger
This describes pretty clearly what happens behind the scenes. Still, someone could wonder why append then does not receive a pointer to the slice, to ensure that both the slice header and the slice data are treated in a consistent way. What is the generally accepted answer to this? For

[go-nuts] Re: append to a stem racy?

2017-11-06 Thread Egon
Yes, that is indeed a race: https://play.golang.org/p/JH6dx9UNxm But it only happens when there are multiple cases where: len(stem) + len(tail) < cap(stem) race-detector detects unsynchronized write-then-(write|read)-s to a memory location For example when there is only one case for

[go-nuts] input and output about go

2017-11-06 Thread 2891132love
I am a beginning learner.there is a simple question about go,the program is in the following: package main import ( "bufio" "fmt" "os" ) func main() { counts := make(map[string]int) input := bufio.NewScanner(os.Stdin) for input.Scan() { counts[input.Text()]++ } for line, n := range