Re: [go-nuts] Re: A better way of events notification from cgo to go side

2017-09-17 Thread Ian Lance Taylor
On Sun, Sep 17, 2017 at 10:10 PM, Sokolov Yura wrote: > > Isn't there a way to pass Go callback to Cgo? In this callback you may do > anything. You can't pass a simple callback, but you can have your C code call a Go function whenever some event occurs. Start a new

Re: [go-nuts] cannot assign 1 values to 2 variables [simple error handling]

2017-09-17 Thread Ian Lance Taylor
You are trying to assign the result of loadPage to two variables, but loadPage only returns one result. In the "here is OK" section you are assigning the result of ioutil.ReadFile to two variables. That is OK because ioutil.ReadFile returns two results. You can see the definition of

[go-nuts] redirecting templates from revel

2017-09-17 Thread Vikram Rawat
I am not able to understand how can I redirect on the click of some text or button a user to a different page. I went to entire documentation but I was not able to understand it. Like revel page say. ---put this HTML in index page-- create this HTML as hello.html page

[go-nuts] Re: A better way of events notification from cgo to go side

2017-09-17 Thread Sokolov Yura
And I agree that socketpair and regular read from will also do the job. https://github.com/prep/socketpair/blob/master/socketpair.go -- 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

[go-nuts] Re: A better way of events notification from cgo to go side

2017-09-17 Thread Sokolov Yura
Isn't there a way to pass Go callback to Cgo? In this callback you may do anything. -- 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] cannot assign 1 values to 2 variables [simple error handling]

2017-09-17 Thread Ângelo Chida
Hi, I'm new in Golang but I'm PHP StackDev since 10 years ago I'm following this tutorial https://golang.org/doc/articles/wiki/ on how to build a web app, but I'm stuck on some error and can't find anywhere a solution. Please help Take a look at the image My go version is 1.9

[go-nuts] Re: how to sort http.Header by ourselves

2017-09-17 Thread Chengbin Du
thank you for your reply. I have to do this, so i forked the http package, and implemented header fields order feature. :) thanks a lot! 在 2017年9月15日星期五 UTC+8下午4:07:35,Dave Cheney写道: > > The author replied to their own post saying that header order was probably > not the issue, and give the

Re: [go-nuts] Do you check in vendor packages?

2017-09-17 Thread gurpartap
Create a separate repo for vendor directory. Set it to "auto check-in" in main repo's git push hook. Done. Moreover, with submodule hash info included in main repo commits, the vendor repo can map better on checkouts. You could this skip submodules mapping if you don't mind rewinding manually

Re: [go-nuts] Re: `ltrace` yields "Couldn't find .dynsym or .dynstr in "/proc/*/exe" with binaries generated by "go build *.go"

2017-09-17 Thread Dave Cheney
What is the problem you are trying to solve? Said another way. If you can confirm (or disprove, whichever suits) that Go uses __vdso_clock_gettime_sym with CLOCK_MONOTONIC, what would you do with that information? On Monday, 18 September 2017 09:08:41 UTC+10, Ronald wrote: > > In `go1.9 @

[go-nuts] Re: A better way of events notification from cgo to go side

2017-09-17 Thread Remus Clearwater
There maybe a 4th method is to use something like eventfd/socketpair between go and cgo sides, but it still has a long-blocking call in syscall.Read unless we could add supports of epoll-eventfd/socketpair to the go runtime. On Monday, September 18, 2017 at 6:43:03 AM UTC+8, Remus Clearwater

Re: [go-nuts] Re: `ltrace` yields "Couldn't find .dynsym or .dynstr in "/proc/*/exe" with binaries generated by "go build *.go"

2017-09-17 Thread Sen Han
Which in this case, the `strace` cannot trace a single syscall that involves the time. On Mon, Sep 18, 2017 at 7:08 AM, Sen Han wrote: > In `go1.9 @ linux 3.10.0-327.el7.x86_64`, the call __vdso_clock_gettime_sym > is > completely in userspace, and does not involve any

Re: [go-nuts] Re: `ltrace` yields "Couldn't find .dynsym or .dynstr in "/proc/*/exe" with binaries generated by "go build *.go"

2017-09-17 Thread Sen Han
In `go1.9 @ linux 3.10.0-327.el7.x86_64`, the call __vdso_clock_gettime_sym is completely in userspace, and does not involve any syscall in the kernel, and that is the reason __vdso_clock_gettime_sym with CLOCK_MONOTONIC is so fast. ( In C, the perf of __vdso_clock_gettime_sym is about 14,000,000

[go-nuts] Re: A better way of events notification from cgo to go side

2017-09-17 Thread Remus Clearwater
In the 3rd method `long wait`, if the cgo could emit some dummy "heartbeat" events notification periodically (e.g., 10ms), that would be nearly the same as `C.sema_timedwait` although there will be a little overhead. On Monday, September 18, 2017 at 6:28:11 AM UTC+8, Remus Clearwater wrote: >

[go-nuts] Re: A better way of events notification from cgo to go side

2017-09-17 Thread Remus Clearwater
But according to the man sem_timedwait(3), the abs_timeout is subjected to the `discontinuous jumps in the system time (e.g., if the system administrator manually changes the clock)`, and `adjtime(3) & NTP`. Imaging the system administrator manually put the clock say 10 seconds behind, thus

[go-nuts] Re: `ltrace` yields "Couldn't find .dynsym or .dynstr in "/proc/*/exe" with binaries generated by "go build *.go"

2017-09-17 Thread David Collier-Brown
You may need to look and see what __vdso_clock_gettime_sym calls at the system-call level, and compare that with the system calls reported by strace from your executable. I assume you want some particular thing that __vdso_clock_gettime_sym does: try asking the folks about *that*, as they may

[go-nuts] Create a file and control whether to overwrite or not

2017-09-17 Thread Tamás Gulácsi
Why the double open? mode:=os.O_RDWR... if overwrite { mode |= os.O_TRUNC} os.OpenFile(name, mode) -- 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] A better way of events notification from cgo to go side

2017-09-17 Thread Tamás Gulácsi
C.sema_timedwait ? No latency, and with a few seconds for timeout, not too long. -- 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] Create a file and control whether to overwrite or not

2017-09-17 Thread DrGo
Hello, The default behaviour of os.Create is to truncate the file if already exists. I wrote the code below to control whether the file should be overwritten or not (possibly based on user wishes). Seems to work on MacOS. Do you think this code will work on Windows and Linux? Do you see any

[go-nuts] A better way of events notification from cgo to go side

2017-09-17 Thread Remus Clearwater
Hi, I wonder if there has a small cost, little latency and high efficient solution of event notification from cgo to go side. Here is 3 ways as far as I know: 1. Poll go func() { for { // fast ret from cgo ret := C.sema_try_wait()

Re: [go-nuts] Re: context cancellation flake

2017-09-17 Thread Jesper Louis Andersen
On Sun, Sep 17, 2017 at 12:46 PM Steven Lee wrote: > Thank you Silviu, that seems to work. > > Do you know exactly why it flakes? what is racing? just for me to have an > understanding of why this happens > > It is somewhat common to use the TCP window as a feedback mechanism

Re: [go-nuts] Latency profiling

2017-09-17 Thread Sen Han
(Sorry for the noise.) Hi Juliusz, this tool go-tool-trace-greediest-goroutines would be helpful.( may also refer the issue 20792 ) All best -- Sen On Sun, Sep 17, 2017 at 9:12 PM, Juliusz

[go-nuts] Re: context cancellation flake

2017-09-17 Thread silviucapota
Steven, no problem. For more details have a look at a) This talk by Sameer Ajmani: https://vimeo.com/115309491 b) Francesc Campoy's series of videos: https://github.com/campoy/justforfunc In the Readme, you'll find likes to episodes 9 and 10, which deal with explaning and implementing the

[go-nuts] Latency profiling

2017-09-17 Thread Juliusz Chroboczek
Hi, I've got a CPU-bound function that is not called very frequently, and hence doesn't appear prominently in the CPU profile, but I'm guessing that it takes a significant time to run (on the order of tens of milliseconds), and hence increases the latency of the calling goroutine. I don't see

[go-nuts] Re: context cancellation flake

2017-09-17 Thread Steven Lee
Thank you Silviu, that seems to work. Do you know exactly why it flakes? what is racing? just for me to have an understanding of why this happens On Sunday, 17 September 2017 01:19:35 UTC+1, Silviu Capota Mera wrote: > > Hi Steven, > > In case it's still unclear, you need to wrap both the "do

[go-nuts] [ANN] Learn Go by Writing REST APIs - Free Workshop (Tel Aviv)

2017-09-17 Thread Miki Tebeka
Hi, We'll be doing an introductory "hands on" workshop for people who are interested in learning Go. We'll learn go by writing a REST API server. Limited availability, register at https://www.eventbrite.com/e/learn-go-by-writing-rest-apis-tickets-37870497678 Happy hacking, -- Miki -- You