[go-nuts] Create non-variadic functions without existingType using reflection

2021-12-20 Thread 'Ankit Gupta' via golang-nuts
Hey Folks, If I have argument type for a function: is it possible to create a function with those? *Note:* - we don't have reflect type for the function to be created so makeFunc can not be simply used. - function inputTypes can differ so variadic can not be leveraged here. - number of inputs

Re: [go-nuts] Unsupported File Format error while building for linux-amd64 on mac os

2018-10-01 Thread Ankit Gupta
Tamas, I installed docker on mac and cross compiled using xgo like you suggested. Worked perfectly. Thanks a lot! On Saturday, September 29, 2018 at 1:58:20 AM UTC+5:30, Tamás Gulácsi wrote: > > 2018. szeptember 28., péntek 15:59:14 UTC+2 időpontban Ankit Gupta a > követk

Re: [go-nuts] Unsupported File Format error while building for linux-amd64 on mac os

2018-09-28 Thread Ankit Gupta
Thanks Ian for responding. Can you point me as to how to get the cross compiler. I am farely new to Mac. On Fri, 28 Sep 2018, 19:23 Ian Lance Taylor, wrote: > On Fri, Sep 28, 2018 at 2:08 AM, Ankit Gupta > wrote: > > > > I am working with confluent-kafka-go library >

[go-nuts] Unsupported File Format error while building for linux-amd64 on mac os

2018-09-28 Thread Ankit Gupta
I am working with confluent-kafka-go library (https://github.com/confluentinc/confluent-kafka-go) which builds fine on the mac machine (mac OS 10.13.6) along with the code files I wrote. In order to deploy it on Linux server (Ubuntu 64 bit), I try this - $> CGO_ENABLED=1 GOOS=linux GOARCH=amd6

[go-nuts] Correct way of sending HEADERS and DATA frames in http2?

2018-05-23 Thread Ankit Gupta
I am using *golang.org/x/net/http2* and *golang.org/x/net/http2/**hpack* packages to do low level http2 framing. For requests with only HEADERS frame sent, I want to send a empy json '{}', so I send 1 HEADERS frame and 1 DATA frame as below headersframe, ok := frame.(*http2.Hea

[go-nuts] Re: http.ReadRequest doesn't recognize http2?

2018-05-21 Thread Ankit Gupta
This issue is now opened https://go-review.googlesource.com/c/113817/ I am still looking for an alternative though - to know if a certain sequence of bytes contains http2 data with method/headers/body. On Monday, May 21, 2018 at 5:24:09 PM UTC+5:30, Ankit Gupta wrote: > > Hello gophers,

[go-nuts] http.ReadRequest doesn't recognize http2?

2018-05-21 Thread Ankit Gupta
Hello gophers, I am trying to read http2 request on a tcp connection, which is set up like this - cert, err := tls.LoadX509KeyPair(certfile, certkeyfile) if err != nil { return nil, err } tlsConfig := &tls.C

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
equests are forwarded in FIFO order when the service is >> available next. > > > wouldn’t you want to do these concurrently if possible? > > Matt > > On Friday, May 18, 2018 at 11:50:56 AM UTC-5, Ankit Gupta wrote: >> >> Hi Matt, >> >> F

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

2018-05-18 Thread Ankit Gupta
seServiceIndex: > > if retry != 0 { > return … > } > // longer behavior > > The else after “if sumErr == 0” is unnecessary. > > The mutex could be embedded in model.ServiceQProperties. > > How did you validate this program? > > Thanks, > Matt > > On Friday, Ma

[go-nuts] Load balancing with error feedback capabilities

2018-05-18 Thread Ankit Gupta
Hello gophers, I recently built a small HTTP load balancer with capabilities built around error feedback - https://github.com/gptankit/serviceq Provides two primary functionalities - deferred request queue and probabilitically reducing errored nodes selection. I am using channel as a in-memory

Re: [go-nuts] Re: go 1 on Ubuntu 18.04

2018-05-07 Thread Ankit Gupta
, 2018 at 3:32 PM, Ankit Gupta > wrote: > >> >> Updating Go is simply a matter of removing old Go installation directory >> and replace it with new one. For your particular use case - >> >> > A better solution (in my opinion) is to decompress the new Go tar

[go-nuts] Re: go 1 on Ubuntu 18.04

2018-05-07 Thread Ankit Gupta
Updating Go is simply a matter of removing old Go installation directory and replace it with new one. For your particular use case - Remove the go folder under /usr/lib (the /usr/bin/go just holds the binary). Install the new go version to /usr/local as mentioned on golang installation manua

Re: [go-nuts] bufio usage hurting performance

2018-05-04 Thread Ankit Gupta
I am talking in terms of parsing http request by using http.ReadRequest method which only accept bufio.Reader (https://golang.org/pkg/net/http/#ReadRequest) On Friday, May 4, 2018 at 8:04:22 PM UTC+5:30, Ian Lance Taylor wrote: > > On Fri, May 4, 2018 at 5:20 AM, Ankit Gupta &

[go-nuts] Re: beginner question about chanels

2018-05-04 Thread Ankit Gupta
ch := make(chan bool) means you want to have an unbufferred channel. Send and Receive are block operations. In other words, send will block unless there is a receive operation, which is the case in your code. All calls to increment are blocked at ch <- true. When you change it to ch := make(cha

[go-nuts] bufio usage hurting performance

2018-05-04 Thread Ankit Gupta
I recently wrote a reverse proxy in Go - https://github.com/gptankit/serviceq which does load balancing and queues failed requests (to dipatch later). When I compared perf with nginx, I noticed 15-20 ms higher response times. So, I timed each function, and got to know that the code spends most

[go-nuts] Question regarding runtime.ReadMemStats

2018-04-22 Thread Ankit Gupta
I ran a goroutine 3 times, at the end of each, I run runtime.GC() and print mem stats. Just before exiting program, I do it once more. This is what I get in each runs - HeapSys = 720896 Alloc = 48408 TotalAlloc = 62464 StackSys = 327680 Sys = 2461696 GCSys = 63488 NumGC = 1 PauseTotalNs = 1680

[go-nuts] Re: Accessing Slices Made From Same Array Concurrently

2018-04-21 Thread Ankit Gupta
@Kaveh Slices are values but they refer to the same back array location. You have created localized v which is appended inside goroutine which refer to a location containing its own byte array of len=10. So, you are not really referencing the same memory location as other v slice in the gorouti

[go-nuts] Re: parallel array processing question

2018-04-20 Thread Ankit Gupta
There could have been a data race in your code with the usage of allMax variable which is updated and checked by multiple goroutines. But you are saved by the use of mutex. All shared variables, in general, are subject to data races when there is a write involved. The local variables you create

Re: [go-nuts] Extension for type assertion of interface array

2018-04-19 Thread ankit . gupta
Though the above is not allowed, you can restructure your code to wrap your struct as array in another struct and have area() paas a index to the underlying struct. Something like this (landSpaceArr wraps landSpace struct) - type landSpace struct{ side int } type landSpaceArr struct {