Re: [go-nuts] C.malloc of Go type?

2018-05-19 Thread andrey mirtchovski
also useful if you're dealing with blobs of C memory: https://utcc.utoronto.ca/~cks/space/blog/programming/GoCGoCompatibleStructs On Sat, May 19, 2018 at 3:03 PM, Jan Mercl <0xj...@gmail.com> wrote: > > On Sat, May 19, 2018 at 10:42 PM Max > wrote: > > > The

[go-nuts] What is restapiserver.webcache

2018-05-19 Thread asaaveri
All: I have a very simple HelloWorld REST API server in go and a corresponding Go client. The objective is to see benchmark -- i.e. what is the most TPS a Go server can support. I used tcpdumo to see the exchanges. I was expecting to see just my restapiserver:8080 but I see some w/

Re: [go-nuts] C.malloc of Go type?

2018-05-19 Thread Jan Mercl
On Sat, May 19, 2018 at 10:42 PM Max wrote: > The question is: is it allowed to take the unsafe.Pointer returned by C.malloc() and convert it to a pointer to a Go struct type? See https://golang.org/pkg/unsafe/#Pointer -- -j -- You received this message

[go-nuts] Re: C.malloc of Go type?

2018-05-19 Thread Max
On Saturday, May 19, 2018 at 10:42:12 PM UTC+2, Max wrote: > > > func mallocList() *List { > const n = unsafe.Sizeof(List{}) > p := C.malloc(C.ulong(n)) > C.memset(p, C.int(n), 0) > return (*List)(p) > } > I swapped the arguments to C.memset(). The correct version is: func

[go-nuts] C.malloc of Go type?

2018-05-19 Thread Max
After reading https://golang.org/cmd/cgo/#hdr-Passing_pointers and https://blog.golang.org/c-go-cgo, I am trying to understand if there are valid ways to pass between Go and C complicated data structures with (potentially) lots of pointers. At the moment this is just a speculative question, but

Re: [go-nuts] cgo and time.After

2018-05-19 Thread Chris Burkert
Jakob, I think you’re right. I am going to test this as soon as I am back home. After all I am a beginner in this area and it seems this one fooled me. I’ll send an update tomorrow. thanks - Chris Jakob Borg schrieb am Sa. 19. Mai 2018 um 21:15: > On 19 May 2018, at 16:25,

Re: [go-nuts] Re: Validation checks in Go

2018-05-19 Thread matthewjuran
An example is nil map access or concurrent map access both cause panics in the runtime (https://github.com/golang/go/blob/release-branch.go1.10/src/runtime/hashmap.go#L357). A useful thing panic without recover does is print the stack trace. Matt On Saturday, May 19, 2018 at 11:57:33 AM

Re: [go-nuts] cgo and time.After

2018-05-19 Thread Jakob Borg
On 19 May 2018, at 16:25, Chris Burkert wrote: > > case <-time.After(5 * time.Second): > fmt.Printf("Progress: %d left from %d\n", remaining, amount) It's not super clear from your post if you're aware of this already, but this case will only fire after the

Re: [go-nuts] Re: Validation checks in Go

2018-05-19 Thread David Skinner
https://play.golang.org/p/d_fQWzXnlAm If you are going to use panic, then choose a place where you can recover gracefully and report the error. I do agree, that it is an mistake to return an error code if your assignment was to write a function that only has valid input. The software engineer

[go-nuts] [ANN] BIFF  (BIFurcation Framework) easy nesting tests

2018-05-19 Thread Gerardo Oscar JT
Here is BIFF , a small library for testing that takes advantage of scope of nested functions to write tests faster and

[go-nuts] Re: [ANN] Pion-TURN, a TURN server designed with ease of use and extensibility in mind

2018-05-19 Thread matthewjuran
Thanks for the kind reply. Should I change this name, but still keep things like the realm/socket as > members still? I think of turn.Server as the global singleton that handles > all traffic (UDP or TCP) An interface is used to allow varying types to have the same logic applied. In this

[go-nuts] cgo and time.After

2018-05-19 Thread Tamás Gulácsi
Show the code! This should not be cgo error, but user error! -- 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] cgo and time.After

2018-05-19 Thread Chris Burkert
Dear Gophers, I am working on a small database tool which checks a database for inconsistencies. It does that by calling a stored procedure via sql. Unfortunately the database client is available as C-library only but luckily there is a go driver for the database/sql package so at least it

[go-nuts] Processing test json data

2018-05-19 Thread vedujoshi
I see that in go1.10, we can have json formatted "go test" output (by using -json flag) I googled around, but couldn't find a simple way/tool to convert it to junitxml format Any suggestions? -- You received this message because you are subscribed to the Google Groups "golang-nuts" group. To

Re: [go-nuts] Load balancing with error feedback capabilities

2018-05-19 Thread Ankit Gupta
@Jakob Can you explain it further? Two different instances of ServiceQProperties should each get their own reference of underlying sync.Mutex. So, Lock() and Unlock() should be on different objects. Thanks, Ankit On Saturday, May 19, 2018 at 3:39:40 AM UTC+5:30, Jakob Borg wrote: > > That also

[go-nuts] Re: Load balancing with error feedback capabilities

2018-05-19 Thread Ankit Gupta
Hi Matt, Ok, if you meant the type embedding -- I usually prefer it for composition purpose, so that I can pass around the composed type (or pointer) to function calls. Did not find any such need. I haven’t gotten far enough into network services to have much to say about > the features

[go-nuts] Re: [ANN] Pion-TURN, a TURN server designed with ease of use and extensibility in mind

2018-05-19 Thread sean
This review is fantastic! I committed what I understood, I have a few questions though. > Instead of turn.Server a more idiomatic interface name could be something like turn.ClientAuthenticator Should I change this name, but still keep things like the realm/socket as members still? I think of

[go-nuts] Re: Cgo: using syscall.Select

2018-05-19 Thread Sergey Kamardin
There are methods which are using raw file descriptors (such that https://godoc.org/github.com/mailru/easygo/netpoll#NewDesc). суббота, 19 мая 2018 г., 2:52:27 UTC+3 пользователь Juliusz Chroboczek написал: > > > You could also take a look > > at