Re: [go-nuts] simplifying freeing CString

2016-10-17 Thread andrew . smith
Thanks very much for your replies. I guess the killer argument is that finalizers are not guaranteed to run! I didnt know that. Just to be clear, Im not intending exposing WrappedString to my clients only standard go strings, everything *should* be freed up when my outer wrapper function exits

Re: [go-nuts] Re: Proposal: add "future" internal type (similar to channel)

2016-10-17 Thread roger peppe
On 17 October 2016 at 17:18, Sokolov Yura wrote: > > понедельник, 17 октября 2016 г., 18:12:59 UTC+3 пользователь Roberto Zanotto > написал: >> >> I missed the chance to comment on github... >> >> This also works for implementing futures and it's simple, type-safe and >> can be used with select: >

Re: [go-nuts] Excessive garbage collection

2016-10-17 Thread Jiří Šimša
go version go1.7.1 darwin/amd64 -- Jiří Šimša On Mon, Oct 17, 2016 at 8:02 PM, Ian Lance Taylor wrote: > On Mon, Oct 17, 2016 at 6:20 PM, wrote: > > > > The backend of my web server (written in Go) have recently started > consuming > > large amounts of CPU. AFAICT, the CPU seems to be consume

Re: [go-nuts] Excessive garbage collection

2016-10-17 Thread Ian Lance Taylor
On Mon, Oct 17, 2016 at 6:20 PM, wrote: > > The backend of my web server (written in Go) have recently started consuming > large amounts of CPU. AFAICT, the CPU seems to be consumed by the garbage > collector and I would appreciate any information that would help me track > down the root cause.

[go-nuts] Excessive garbage collection

2016-10-17 Thread jiri . simsa
Hello, The backend of my web server (written in Go) have recently started consuming large amounts of CPU. AFAICT, the CPU seems to be consumed by the garbage collector and I would appreciate any information that would help me track down the root cause. When I run the web server with gctrace=1,

Re: [go-nuts] simplifying freeing CString

2016-10-17 Thread Pietro Gagliardi
> On Oct 17, 2016, at 5:03 PM, andrew.sm...@miracl.com wrote: > > Hi, > > When using cgo its my understanding that strings created with C.CString must > be freed with C.free, but yet numeric types do not need to be explicitly > freed. Yes. This is because strings in C are not first class obje

[go-nuts] simplifying freeing CString

2016-10-17 Thread andrew . smith
Hi, When using cgo its my understanding that strings created with C.CString must be freed with C.free, but yet numeric types do not need to be explicitly freed. Firstly, is CString a special case here, or are there other types that need to be explicitly freed as well? Secondly, Im writing a l

Re: [go-nuts] output files from build of swig file

2016-10-17 Thread andrew . smith
Thanks for confirming, I realised this by digging into the go build code. // Run SWIG on one SWIG input file. 3553 func (b *builder) swigOne(p *Package, file, obj string, pcCFLAGS []string, cxx bool, intgosize string) (outGo, outC string, err error) { 3554 cgoCPPFLAGS, cgoCFLAGS, c

Re: [go-nuts] Re: Serialization internal data to disk

2016-10-17 Thread Gulácsi Tamás
No, method 1 preserves "err" if it is not nil. Tong Sun ezt írta (időpont: 2016. okt. 17., H 20:11): > > On Mon, Oct 17, 2016 at 1:20 AM, Tamás Gulácsi wrote: > > > > The reason that I didn't do it, is because I don't know how to do it. In > essence, that "f.Close()" that you worried about is wr

[go-nuts] Currently Hiring for GoLang/XML Developer in Denver

2016-10-17 Thread Andrea Biegalski
I'm currently looking for a developer to join one my largest clients in Downtown Denver, CO. This team handles strategic short projects Specific targeted gap - video distribution team They are building a product for video stream infrastructure *Looking for a * Golang developer - automatio

[go-nuts] High CPU usage for process using mdns (Flame graph attached) - time spent in runtime.goexit and runtime.mstart

2016-10-17 Thread Abhay Bothra
We are using Hashicorp's mdns library (https://github.com/hashicorp/mdns) for node discovery, with a frequency of 1 mdns query / minute. The CPU consumption by the process increases very gradually over a couple of days, going from 2-3% to 20-30% over 3-4 days. From the runtime instrumentation w

Re: [go-nuts] Why no bytes.InsertByte(s []byte, p int, b byte) []byte ?

2016-10-17 Thread Liam Breck
On Oct 16, 2016 6:03 PM, "Liam Breck" wrote: > > > > On Sun, Oct 16, 2016 at 5:32 PM, Ian Lance Taylor wrote: >> >> On Sun, Oct 16, 2016 at 5:25 PM, Liam wrote: >> > >> > On Sunday, October 16, 2016 at 5:13:36 PM UTC-7, Ian Lance Taylor wrote: >> >> >> >> On Sun, Oct 16, 2016 at 3:34 PM, Liam w

Re: [go-nuts] Re: Serialization internal data to disk

2016-10-17 Thread Tong Sun
On Mon, Oct 17, 2016 at 1:20 AM, Tamás Gulácsi wrote: > > >> The reason that I didn't do it, is because I don't know how to do it. In >> essence, that "f.Close()" that you worried about is wrapped in "defer >> f.Close()" in SaveState, which in turn wrapped in "defer SaveState" in a >> function. I.

[go-nuts] Re: Proposal: add "future" internal type (similar to channel)

2016-10-17 Thread 'Alan Donovan' via golang-nuts
On 17 October 2016 at 12:31, Sokolov Yura wrote: > > понедельник, 17 октября 2016 г., 18:08:43 UTC+3 пользователь > adon...@google.com написал: >> >> Go does not take a strong Erlang-like stance against concurrency with >> shared variables, so mutexes really are critical to Go's concurrency. >> >

Re: [go-nuts] output files from build of swig file

2016-10-17 Thread Ian Lance Taylor
On Mon, Oct 17, 2016 at 4:11 AM, wrote: > > I have a follow-up question, how can I instrument my go code so that I can > set the include path that is used to resolve '%include' statements in my > swig code. Currently I have relative paths in my swig file, and I would like > to put '/usr/include'

Re: [go-nuts] Centos - golang 1.6/1.7 - dial tcp i/o timeout

2016-10-17 Thread Ian Lance Taylor
On Mon, Oct 17, 2016 at 8:26 AM, wrote: > Is there a way in Golang to cache the response from the DNS server? Java > apps by default cache the DNS info until the app gets restarted. You can do DNS lookups yourself using `net.LookupHost` and friends. Ian > On Sunday, October 16, 2016 at 5:01:44

[go-nuts] Re: Proposal: add "future" internal type (similar to channel)

2016-10-17 Thread Sokolov Yura
понедельник, 17 октября 2016 г., 18:08:43 UTC+3 пользователь adon...@google.com написал: > > > Go does not take a strong Erlang-like stance against concurrency with > shared variables, so mutexes really are critical to Go's concurrency. > Am I mistaken? Golang authors said mutexes are second c

Re: [go-nuts] Centos - golang 1.6/1.7 - dial tcp i/o timeout

2016-10-17 Thread roberto . devet
Is there a way in Golang to cache the response from the DNS server? Java apps by default cache the DNS info until the app gets restarted. On Sunday, October 16, 2016 at 5:01:44 PM UTC-5, Ian Lance Taylor wrote: > > On Sun, Oct 16, 2016 at 9:10 AM, > > wrote: > > > > Getting dail tcp error whi

[go-nuts] Re: Proposal: add "future" internal type (similar to channel)

2016-10-17 Thread Sokolov Yura
понедельник, 17 октября 2016 г., 18:12:59 UTC+3 пользователь Roberto Zanotto написал: > > I missed the chance to comment on github... > > This also works for implementing futures and it's simple, type-safe and > can be used with select: > https://play.golang.org/p/VDT36rC5A- > Of course the synt

[go-nuts] Re: Proposal: add "future" internal type (similar to channel)

2016-10-17 Thread Viktor Kojouharov
A future is just a special case of an observable. Honestly I'd prefer if an observable was built-in the language like a channel. You could use it like a channel in selects and the like, but with the possibility of receiver observables to be closable. When the list receiver observable is closed

[go-nuts] Re: Proposal: add "future" internal type (similar to channel)

2016-10-17 Thread Roberto Zanotto
I missed the chance to comment on github... This also works for implementing futures and it's simple, type-safe and can be used with select: https://play.golang.org/p/VDT36rC5A- Of course the syntax is not as nice as built-in futures. On Sunday, October 16, 2016 at 2:40:32 PM UTC+2, Sokolov Yura

[go-nuts] Re: Proposal: add "future" internal type (similar to channel)

2016-10-17 Thread adonovan via golang-nuts
On Monday, 17 October 2016 10:10:47 UTC-4, Sokolov Yura wrote: > > Mutex needs not to be type-safe. > And Mutex is not part of concept of "language tailored towards > concurrency". > Go does not take a strong Erlang-like stance against concurrency with shared variables, so mutexes really are cr

Re: [go-nuts] Proposal: add "future" internal type (similar to channel)

2016-10-17 Thread Konstantin Khomoutov
On Sun, 16 Oct 2016 05:40:32 -0700 (PDT) Sokolov Yura wrote: > "future" is commonly used synchronization abstraction. > > It could be implemented in a library, using mutex, channel and > interface. Example: > https://github.com/Workiva/go-datastructures/blob/master/futures/selectable.go > > But

Re: [go-nuts] Proposal: add "future" internal type (similar to channel)

2016-10-17 Thread Sokolov Yura
Konstantin No, no sync.Cond. Please, read links before writing answers. Please. понедельник, 17 октября 2016 г., 17:12:42 UTC+3 пользователь Konstantin Khomoutov написал: > > On Sun, 16 Oct 2016 05:40:32 -0700 (PDT) > Sokolov Yura > wrote: > > > "future" is commonly used synchronization abstra

[go-nuts] Hosting Vanity imports on your Hugo static HTML blog

2016-10-17 Thread Nate Finch
Have a hugo blog? Want to give your go packages a custom import url (e.g. import "npf.io/gorram/run")? You can do it with just a few lines of templates / frontmatter. It took some figuring out to get this working, but once you know how to do it, it's pretty easy. https://npf.io/2016/10/vani

[go-nuts] Re: Proposal: add "future" internal type (similar to channel)

2016-10-17 Thread Sokolov Yura
Mutex needs not to be type-safe. And Mutex is not part of concept of "language tailored towards concurrency". But "future" is well known, widely adopted (though, in different ways) concurrency primitive. It definitely has right to be part of "language for concurrency". (ohhh, three lines of text w

Re: [go-nuts] Re: Proposal: add "future" internal type (similar to channel)

2016-10-17 Thread Юрий Соколов
Mutex needs not to be type-safe. And Mutex is not part of concept of "language tailored towards concurrency". But "future" is well known, widely adopted (though, in different ways) concurrency primitive. It definitely has right to be part of "language for concurrency". (ohhh, three lines of text w

Re: [go-nuts] Why is ioutil.Discard implemented using an int and not an empty struct?

2016-10-17 Thread adonovan via golang-nuts
On Monday, 17 October 2016 09:15:33 UTC-4, Axel Wagner wrote: > > However, the compiler might be clever enough to optimize that out with > inlining and escape analysis. And indeed, I'm failing to trigger the > behavior with any simple testcase. So I might be wrong here. Would be > interested in

[go-nuts] Re: Proposal: add "future" internal type (similar to channel)

2016-10-17 Thread adonovan via golang-nuts
On Sunday, 16 October 2016 08:40:32 UTC-4, Sokolov Yura wrote: > > "future" is commonly used synchronization abstraction. > > It could be implemented in a library, using mutex, channel and interface. > Example: > https://github.com/Workiva/go-datastructures/blob/master/futures/selectable.go > >

Re: [go-nuts] Why is ioutil.Discard implemented using an int and not an empty struct?

2016-10-17 Thread 'Axel Wagner' via golang-nuts
There is no semantic difference. Disclaimer: On everything that follows, I'm not an expert (and it seems I'm wrong. Not sure exactly how, though). Though there *might* be a (*very*) slight advantage to using a struct{}. All struct{}'s have the same address in gc, so if you put a struct{} into an

Re: [go-nuts] Re: Serialization internal data to disk

2016-10-17 Thread Kiki Sugiaman
On 17/10/16 23:09, Kiki Sugiaman wrote: If N out of 4 error is not nil, N > 0, expect some performance hit from reflection. If N == 0 (which should be most of the time), the code will not touch reflection. Sorry, I was referring to an earlier version that's still stuck in my head. There's

Re: [go-nuts] Re: Serialization internal data to disk

2016-10-17 Thread Kiki Sugiaman
On 16/10/16 23:48, antoniosun...@gmail.com wrote: [snip] The reason that I didn't do it, is because I don't know how to do it. In essence, that "f.Close()" that you worried about is wrapped in "defer f.Close()" in SaveState, which in turn wrapped in "defer SaveState" in a function. I.e., all i

Re: [go-nuts] output files from build of swig file

2016-10-17 Thread andrew . smith
Thanks for confirming my suspicions. I have a follow-up question, how can I instrument my go code so that I can set the include path that is used to resolve '%include' statements in my swig code. Currently I have relative paths in my swig file, and I would like to put '/usr/include' on the sea

[go-nuts] Using xml.Encoder.Encode over xml.Encoder.EncodeElement

2016-10-17 Thread Uwe Dauernheim
Is there a downside in using `xml.Encode` instead of `xml.EncodeElement` when implementing the `xml.Marshaler` interface? I see in the documentation: Using start as the element tag is not required, but doing so will enable Unmarshal to match the XML elements to the correct struct field. Bu

[go-nuts] Why is ioutil.Discard implemented using an int and not an empty struct?

2016-10-17 Thread Rodolfo Carvalho
Hi, I noticed that when io.Discard was introduced in https://codereview.appspot.com/4426066/, it replaced code like: type devNull struct{} With: type devNull int Both had the very same implementation of the Write method: func (devNull) Write(p []byte) (int, os.Error) { return len(