[go-nuts] Re: Is there something wrong with performance of select in a for loop

2017-02-07 Thread fwang2002
my test in machine of 12core*2.0G before(use foo8.go): 1 2.305055967s 2 3.963565786s 3 3.909725761s 4 4.108974638s 5 4.209743812s 6 4.495325926s cpu: 38-45% after(use waitcond.go): 1 2.879277251s 2 2.804899636s 3 2.769632181s 4 2.884387569s 5 2.870019995s 6 2.822770813s 5 2.827548132s 4 2.877626

Re: [go-nuts] Why can't interface parameters auto-convert types that implement that interface?

2017-02-07 Thread Jesse McNelis
On Wed, Feb 8, 2017 at 5:41 PM, wrote: > satisfies the interface, but requires a type assertion. However, > > func (e E) Less(e2 Element) bool { > return e.value < e2.value > } > If this version of Less() satisfied the interface Node what happens when I pass something that isn't an Element b

[go-nuts] Why can't interface parameters auto-convert types that implement that interface?

2017-02-07 Thread aindurti
Say I have a type Node interface { Less(Node) bool } and type Element struct { value int } func callLess(n1, n2 Node) { n1.Less(n2) } I understand that type-assertions are generally required to get a different type from an interface. But in this specific case where a type is kn

Re: [go-nuts] Re: fmt: Why Golang doesn't have fmt.Printlnf?

2017-02-07 Thread Nathan Fisher
I would speculate it's a conscious tradeoff to keep the function count low given it's an equivalent number of characters. On Wed, 8 Feb 2017 at 03:32, 高橋誠二 wrote: > yes, I know but other languages support it as default, isn't it? > > 2017年2月8日水曜日 12時31分00秒 UTC+9 dja...@gmail.com: > > > > On Wedne

[go-nuts] Re: Can't parse Interface-typed variable, even after substituting a specific type.

2017-02-07 Thread mura_li
On Wednesday, February 8, 2017 at 1:20:22 PM UTC+8, mur...@castech.com.tw wrote: > > Interface imposes a set of restrictions on a object, which makes it useful > in the first place. > If it doesn't, then you won't be able to replace the type of the object > assigned to the interface. > Say, if

[go-nuts] Decode XML performance in golang

2017-02-07 Thread emartinez1847
Hello, I'm making a go code which is basically parsing a lot of small xml responses. I've noticed that right after I enable the parsing code, my R/S as per wrk, as well as response times drop to 15% for some reason. I'm testing with about 2000 concurrent clients and each one parses about 50 ve

[go-nuts] Re: Can't parse Interface-typed variable, even after substituting a specific type.

2017-02-07 Thread mura_li
Interface imposes a set of restrictions on a object, which makes it useful in the first place. If it doesn't, then you won't be able to replace the type of the object assigned to the interface. Say, if you change the type of fooModel to something with different fields, you would have to change a

Re: [go-nuts] Can't parse Interface-typed variable, even after substituting a specific type.

2017-02-07 Thread Ian Lance Taylor
On Tue, Feb 7, 2017 at 5:57 PM, 高橋誠二 wrote: > https://play.golang.org/p/KEGDmlLEZZ > > like this, can't use var model ModelObject as FooModel struct. > I'd like to use model as FooModel variable, after inserting &FooModel{Id: 1} > to model. > Why this happen? The only thing you can do with a valu

Re: [go-nuts] File transfer,but file size is zero

2017-02-07 Thread Robert Hsiung
Hi Konstantin Khomoutov: Thanks so much for your great support. It works. BR Robert 2017-02-07 18:24 GMT+08:00 Konstantin Khomoutov < flatw...@users.sourceforge.net>: > On Tue, 7 Feb 2017 02:01:51 -0800 (PST) > Robert Hsiung wrote: > > > I tried to upload file via SFTP,but the file size

[go-nuts] Re: storing transaction in context

2017-02-07 Thread Steve Roth
Fascinating. I didn't entertain the idea of putting the context in the transaction, for exactly the reason that Chetan cited. But it does seem like a good answer. (And yes, the transactions are short. Long-running transactions are an anti-pattern in their own right.) Many thanks for the inp

[go-nuts] Re: fmt: Why Golang doesn't have fmt.Printlnf?

2017-02-07 Thread 高橋誠二
yes, I know but other languages support it as default, isn't it? 2017年2月8日水曜日 12時31分00秒 UTC+9 dja...@gmail.com: > > > > On Wednesday, February 8, 2017 at 3:58:55 AM UTC+2, 高橋誠二 wrote: >> >> fmt package have no *lnf method, but in other langs, >> sometimes it implements Printlnf. >> Is there any re

Re: [go-nuts] File transfer,but file size is zero

2017-02-07 Thread Robert Hsiung
HI Jesse McNelis: It works. Thanks so much for your great support. BR Robert 2017-02-07 18:12 GMT+08:00 Jesse McNelis : > On Tue, Feb 7, 2017 at 9:01 PM, Robert Hsiung wrote: > > Hi all: > > I tried to upload file via SFTP,but the file size is zero when it is > > done.Any suggestions? T

[go-nuts] Re: fmt: Why Golang doesn't have fmt.Printlnf?

2017-02-07 Thread djadala
On Wednesday, February 8, 2017 at 3:58:55 AM UTC+2, 高橋誠二 wrote: > > fmt package have no *lnf method, but in other langs, > sometimes it implements Printlnf. > Is there any reason? > fmt.Printlnf(f,...) = fmt.Printf(f+"\n", ...) Djadala -- You received this message because you are subscribed t

Re: [go-nuts] Re: troubleshooting 100% cpu peg - runtime._ExternalCode ?

2017-02-07 Thread Jason E. Aten
> ... reproducible with 1.7.x. it might be worth sticking to that version Good suggestion! Oddly enough, go1.7.4 shows the same thing... [jaten@biggie no.cgo]$ ldd ./vhaline.174.nocgo not a dynamic executable [jaten@biggie no.cgo]$ go tool pprof ./vhaline.174.nocgo cpu-profile.120387 Enterin

Re: [go-nuts] ssh login failed

2017-02-07 Thread Robert Hsiung
hi all: Thanks for your information. Good job. BR Robert 2017-02-07 18:17 GMT+08:00 Han-Wen Nienhuys : > The message > > ssh: handshake failed: ssh: unexpected message type 3 (expected one of > [6]) > > is from the spate of problems/fixes due to the recent rekeying rewrite. > > For the orig

[go-nuts] Re: Creating struct through a dynamic var

2017-02-07 Thread emartinez1847
Thanks! El martes, 7 de febrero de 2017, 22:55:06 (UTC-3), emarti...@gmail.com escribió: > > Hello, > > I am having several structures with the same interface and I need to > declare them based on an sql value. On some languages it is possible to do > something like: > > variable struct_name="M

Re: [go-nuts] Creating struct through a dynamic var

2017-02-07 Thread Justin Israel
On Wed, Feb 8, 2017 at 2:55 PM wrote: > Hello, > > I am having several structures with the same interface and I need to > declare them based on an sql value. On some languages it is possible to do > something like: > > variable struct_name="MyStruct" > object:= new struct_name{} > > I was wonderi

[go-nuts] fmt: Why Golang doesn't have fmt.Printlnf?

2017-02-07 Thread 高橋誠二
fmt package have no *lnf method, but in other langs, sometimes it implements Printlnf. Is there any reason? -- 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

Re: [go-nuts] Re: troubleshooting 100% cpu peg - runtime._ExternalCode ?

2017-02-07 Thread Dave Cheney
You mentioned that this was reproducible with 1.7.x. it might be worth sticking to that version to avoid having to concurrently debug this external code issue. -- You received this message because you are subscribed to the Google Groups "golang-nuts" group. To unsubscribe from this group and s

[go-nuts] Can't parse Interface-typed variable, even after substituting a specific type.

2017-02-07 Thread 高橋誠二
https://play.golang.org/p/KEGDmlLEZZ like this, can't use var model ModelObject as FooModel struct. I'd like to use model as FooModel variable, after inserting &FooModel{Id: 1} to model. Why this happen? -- You received this message because you are subscribed to the Google Groups "golang-nuts"

[go-nuts] Creating struct through a dynamic var

2017-02-07 Thread emartinez1847
Hello, I am having several structures with the same interface and I need to declare them based on an sql value. On some languages it is possible to do something like: variable struct_name="MyStruct" object:= new struct_name{} I was wondering if its possible to do something similar in Go? Other

Re: [go-nuts] Re: troubleshooting 100% cpu peg - runtime._ExternalCode ?

2017-02-07 Thread Jason E. Aten
Yes, ldd is how I confirmed I didn't have cgo: [jaten@biggie no.cgo]$ ldd ./vhaline-5min not a dynamic executable [jaten@biggie no.cgo]$ On Tue, Feb 7, 2017 at 5:48 PM, Ian Lance Taylor wrote: > On Tue, Feb 7, 2017 at 3:08 PM, Jason E. Aten wrote: > > On Tue, Feb 7, 2017 at 11:54 AM, Ian L

Re: [go-nuts] "for range" directly to "range" as a type of "for" ?

2017-02-07 Thread Ian Lance Taylor
On Tue, Feb 7, 2017 at 3:55 PM, wrote: > for range array { > ... > } > > > ---> > > range array { > ... > } Why? Every change to the language has benefits and drawbacks. The drawback in this case is the need to learn a new syntax that duplicates an existing syntax. What is the

[go-nuts] "for range" directly to "range" as a type of "for" ?

2017-02-07 Thread abyz . cx . 0
for range array { ... } ---> range array { ... } -- 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. F

Re: [go-nuts] Re: troubleshooting 100% cpu peg - runtime._ExternalCode ?

2017-02-07 Thread Ian Lance Taylor
On Tue, Feb 7, 2017 at 3:08 PM, Jason E. Aten wrote: > On Tue, Feb 7, 2017 at 11:54 AM, Ian Lance Taylor wrote >> >> > >> > Ok. Any idea was runtime._ExternalCode means? >> >> It means that a profiling signal was received while executing code >> that was not written in Go. It should only happen

[go-nuts] Should a program always exit in main()?

2017-02-07 Thread Francis Chuang
I am working on a client library that starts a Kafka consumer to listen for messages from a kafka stream and run some user defined handlers.* I want the design to be "crash-only" as much as possible*, so will be avoiding cleanups during unexpected shutdowns. For example, here's a simple sketch:

Re: [go-nuts] Re: troubleshooting 100% cpu peg - runtime._ExternalCode ?

2017-02-07 Thread Jason E. Aten
On Tue, Feb 7, 2017 at 11:54 AM, Ian Lance Taylor wrote > > > > Ok. Any idea was runtime._ExternalCode means? > > It means that a profiling signal was received while executing code > that was not written in Go. It should only happen in a program that > uses cgo. Suprisingly, that does not seem

[go-nuts] Re: how to get a pprof cpu profile written to disk?

2017-02-07 Thread Dave Cheney
net/http/pprof is your best option If you can't make that fly, then you can use my profile package; just keep a reference to the value returned from profile.Start() and call its Stop method to write out the profile On Wednesday, 8 February 2017 09:03:30 UTC+11, Jason E. Aten wrote: > > addendum

[go-nuts] Re: how to get a pprof cpu profile written to disk?

2017-02-07 Thread Jason E. Aten
addendum: the real program I'm trying to profile never exits on its own. It acts as a server. So I'd like to be able to profile it without shutting it down (ideally), or by sending it a signal. I tried the web interface instead of the file, but I always get "empty profile" back. -- You receiv

Re: [go-nuts] how to get a pprof cpu profile written to disk?

2017-02-07 Thread andrey mirtchovski
your program never completes, pprof.StopCPUProfile() has no chance of being called. On Tue, Feb 7, 2017 at 2:55 PM, Jason E. Aten wrote: > How does one reliably obtain a cpu profile written to file? I tried > following the instructions in runtime/pprof.go, but the profile file is most > always e

[go-nuts] Re: how to get a pprof cpu profile written to disk?

2017-02-07 Thread Dave Cheney
^C will exit the program before the defer in your main can run. I recommend using my profiling package, github.com/pkg/profile https://dave.cheney.net/2014/10/22/simple-profiling-package-moved-updated On Wednesday, 8 February 2017 08:55:33 UTC+11, Jason E. Aten wrote: > > How does one reliably o

[go-nuts] how to get a pprof cpu profile written to disk?

2017-02-07 Thread Jason E. Aten
How does one reliably obtain a cpu profile written to file? I tried following the instructions in runtime/pprof.go, but the profile file is most always empty... only on some magical moments can I discover a profile file being written to disk. I also tried calling f.Sync() on the file hanlde f,

[go-nuts] Re: A Tour of Go: 45

2017-02-07 Thread Tomi Häsä
Oops. Math error 101. It's not the last number i that is printed... On Tuesday, February 7, 2017 at 5:36:47 PM UTC+2, Tomi Häsä wrote: > > Is it normal to get 45 in the Flow Control example? > > https://tour.golang.org/flowcontrol/1 > > package main > > import "fmt" > > func main() { > sum := 0 >

[go-nuts] Re: storing transaction in context

2017-02-07 Thread Dave Cheney
I guess it depends on how long your transaction lasts for; it doesn't sound like it lives for that long. IMO the advice about storing contexts in other objects is more about "don't put this into a long lived object", like your server's main loop or something. On Wednesday, 8 February 2017 05:12

[go-nuts] storing transaction in context

2017-02-07 Thread Chetan Gowda
@Dave, isn't storing context in some struct considered anti-pattern? From the package doc: " Programs that use Contexts should follow these rules to keep interfaces consistent across packages and enable static analysis tools to check context propagation: Do not store Contexts inside a struct ty

Re: [go-nuts] Re: troubleshooting 100% cpu peg - runtime._ExternalCode ?

2017-02-07 Thread Ian Lance Taylor
On Mon, Feb 6, 2017 at 9:53 PM, Jason E. Aten wrote: > > On Monday, February 6, 2017 at 11:49:42 PM UTC-6, Dave Cheney wrote: >> >> The give away is the frequency of the gc lines. gc 15 (the 15th gc event) >> happened at 1314 seconds into your programs execution this tells me that gc >> is likely

Re: [go-nuts] A Tour of Go: 45

2017-02-07 Thread Michael Jones
Me too. What else could it be? On Tue, Feb 7, 2017 at 7:41 AM, Ian Davis wrote: > On Tue, 7 Feb 2017, at 03:36 PM, Tomi Häsä wrote: > > Is it normal to get 45 in the Flow Control example? > > https://tour.golang.org/flowcontrol/1 > > package main > > import "fmt" > > func main() { > sum := 0 > f

Re: [go-nuts] Re: troubleshooting 100% cpu peg - runtime._ExternalCode ?

2017-02-07 Thread Jason E. Aten
On Tue, Feb 7, 2017 at 10:58 AM, Kale B wrote: > Go to http://localhost:6067/debug/pprof/profile with a browser/curl/etc, > it should display a more useful error message. > Thanks Kale. I got the much more useful: Could not enable CPU profiling: cpu profiling already in use So the web didn't w

Re: [go-nuts] A Tour of Go: 45

2017-02-07 Thread Michael Jones
...and there is a nice story on this one. http://mathcentral.uregina.ca/qq/database/qq.02.06/jo1.html On Tue, Feb 7, 2017 at 9:21 AM, Michael Jones wrote: > Me too. What else could it be? > > On Tue, Feb 7, 2017 at 7:41 AM, Ian Davis wrote: > >> On Tue, 7 Feb 2017, at 03:36 PM, Tomi Häsä wrote

[go-nuts] Re: Using React with Golang? and does it make sense?

2017-02-07 Thread so . query
Thanks for going into detail for me! On Monday, February 6, 2017 at 8:57:23 PM UTC-8, Kevin Powick wrote: > > > On Monday, 6 February 2017 23:37:15 UTC-5, so.q...@gmail.com wrote: >> >> >> You said that Node is not required. But I thought react components are >> actually JavaScript objects. >>

Re: [go-nuts] Re: troubleshooting 100% cpu peg - runtime._ExternalCode ?

2017-02-07 Thread Kale B
Go to http://localhost:6067/debug/pprof/profile with a browser/curl/etc, it should display a more useful error message. On Tuesday, February 7, 2017 at 8:51:47 AM UTC-8, Jason E. Aten wrote: > > > > On Tue, Feb 7, 2017 at 10:38 AM, Jason E. Aten <> wrote: > >> On Tue, Feb 7, 2017 at 10:12 AM, Jas

Re: [go-nuts] Re: troubleshooting 100% cpu peg - runtime._ExternalCode ?

2017-02-07 Thread Jason E. Aten
On Tue, Feb 7, 2017 at 10:38 AM, Jason E. Aten <> wrote: > On Tue, Feb 7, 2017 at 10:12 AM, Jason E. Aten <> wrote: > >> If anyone can supply information on the mystery runtime._ExternalCode >> that would be super helpful. >> >> I'm not linking in any cgo libraries. (beyond what the runtime does >

Re: [go-nuts] Re: troubleshooting 100% cpu peg - runtime._ExternalCode ?

2017-02-07 Thread Jason E. Aten
On Tue, Feb 7, 2017 at 10:12 AM, Jason E. Aten wrote: > If anyone can supply information on the mystery runtime._ExternalCode that > would be super helpful. > > I'm not linking in any cgo libraries. (beyond what the runtime does > automatically for dns). Err... so actually there are some C libs..

Re: [go-nuts] Re: troubleshooting 100% cpu peg - runtime._ExternalCode ?

2017-02-07 Thread Jason E. Aten
Nice, stress.bash is indeed super simple, but finds issues that -race alone does not. Thanks for that. I'm still having the 100% cpu peg problem. I was able to observe it under go1.7.4 as well, so it's not specifically a go1.8rc3 issue. If anyone can supply information on the mystery runtime._Ext

Re: [go-nuts] Hidden vendoring trap

2017-02-07 Thread Peter Waller
This problem has come up on the list before [1]. The only way out I found was to remove the offending vendor directory from the project being vendored (or find a way that doesn't involve vendoring the equivalent of camlistore). On 6 February 2017 at 19:30, Tamás Gulácsi wrote: > Shall we reorgan

Re: [go-nuts] A Tour of Go: 45

2017-02-07 Thread Ian Davis
On Tue, 7 Feb 2017, at 03:36 PM, Tomi Häsä wrote: > Is it normal to get 45 in the Flow Control example? > > https://tour.golang.org/flowcontrol/1 > > package main > > import "fmt" > > func main() { > sum := 0 > for i := 0; i < 10; i++ { > sum += i > fmt.Println(i) > } > fmt.Print

[go-nuts] A Tour of Go: 45

2017-02-07 Thread Tomi Häsä
Is it normal to get 45 in the Flow Control example? https://tour.golang.org/flowcontrol/1 package main import "fmt" func main() { sum := 0 for i := 0; i < 10; i++ { sum += i fmt.Println(i) } fmt.Println(sum) } -- You received this message because you are subscribed to the Google Groups "gola

[go-nuts] Re: Using React with Golang? and does it make sense?

2017-02-07 Thread Сергей Камардин
My opinion is that server side rendering is just temporary thing for search engine optimizations. But, if you really need it, you could use Node.js as client to your go api. Then, nginx as a front proxy, could serve static assets with and without backend data from go api. For example, if Node.

[go-nuts] Re: Handshake failed when using builtin TLS package: no cipher suite supported by both client and server

2017-02-07 Thread Alexandr Emelin
Copied wrong line from Heroku proxy report, here is the correct one: Chrome 49 / XP SP3 RSA 2048 (SHA256)

[go-nuts] Re: Handshake failed when using builtin TLS package: no cipher suite supported by both client and server

2017-02-07 Thread Alexandr Emelin
James, thanks for response. I am using go1.7.5 linux/amd64 I have no that client available too - it was originally seen in production logs, and now I rely only on SSLLabs handshake emulation feature that has that Chrome 49 SP3 client in list. Here is what SSLLabs shows for that client when appl

[go-nuts] Ignore tags in struct type conversions recursively

2017-02-07 Thread Richard Lincoln
Dear golang-nuts, The language change mentioned in Francesc Campoy's "The State of Go" 2017 talk caught my eye. Converting struct types while ignoring tags struck me as being very useful. However, it turns out that tags are not ignored recursively: https://github.com/golang/go/issues/16085 Al

Re: [go-nuts] File transfer,but file size is zero

2017-02-07 Thread Konstantin Khomoutov
On Tue, 7 Feb 2017 02:01:51 -0800 (PST) Robert Hsiung wrote: > I tried to upload file via SFTP,but the file size is zero when it > is done.Any suggestions? Thanks so much. [...] > srcFile, err := os.Open("F:/NCA/20161027-1.csv") [...] > dstFile, err := server.Create("/root/20161027-

Re: [go-nuts] ssh login failed

2017-02-07 Thread 'Han-Wen Nienhuys' via golang-nuts
The message ssh: handshake failed: ssh: unexpected message type 3 (expected one of [6]) is from the spate of problems/fixes due to the recent rekeying rewrite. For the original message, it looks like the server hasn't enabled keyboard-interactive, but it's hard to tell. Easiest is to set debug

Re: [go-nuts] File transfer,but file size is zero

2017-02-07 Thread Jesse McNelis
On Tue, Feb 7, 2017 at 9:01 PM, Robert Hsiung wrote: > Hi all: > I tried to upload file via SFTP,but the file size is zero when it is > done.Any suggestions? Thanks so much. > // Copy the file > > dstFile.WriteTo(srcFile) > > } > You're writing the empty destination file to the srcFil

[go-nuts] File transfer,but file size is zero

2017-02-07 Thread Robert Hsiung
Hi all: I tried to upload file via SFTP,but the file size is zero when it is done.Any suggestions? Thanks so much. //sftp upload package main import ( "fmt" "os" "github.com/pkg/sftp" "golang.org/x/crypto/ssh" ) func main() { c := &ssh.ClientConfig{ U