[go-nuts] Re: which approach to appending a slice to another slice by creating a new slice look best to you?

2016-07-10 Thread Egon
On Monday, 11 July 2016 07:06:03 UTC+3, Anmol Sethi wrote: > > https://gist.github.com/nhooyr/7b773ea98f0d08e698d4fe706b4f5b2a > It depends on what problem you are solving manually specifying *cap* may not give you the exact same behavior as specifying the *len*. In this case it looks like the

[go-nuts] Re: TCP Server

2016-07-10 Thread Egon
On Monday, 11 July 2016 07:53:00 UTC+3, EdgarAlejandro Vintimilla wrote: > > > hi > What is the best way to implement a TCP server, I found many examples, > including in this book > http://cdn.oreillystatic.com/oreilly/booksamplers/9781491941959_sampler.pdf > > but I would like some recommendation

[go-nuts] Re: Why should Golang stop appending certificate file after finding one

2016-07-10 Thread jra
I can't tell you why it is how it is, but you can always load the roots that *you* want to use into your own CertPool and then use that CertPool for verification. See https://golang.org/pkg/crypto/x509/#VerifyOptions -jeff -- You received this message because you are subscribed to the Google

[go-nuts] Re: Golang serial port get CTS and DSR values

2016-07-10 Thread jra
On Friday, July 8, 2016 at 6:32:45 PM UTC+6, hcha...@isa.ae wrote: > > I just want to know, how to get CTS and DSR values in windows environment. > i have tried below way, but it did not work for me; Can u please look into > this? > To do that, you'll be using the GetCommModemStatus Win32 API:

Re: [go-nuts] Re: Hi, someone may help me converting this python code to GO

2016-07-10 Thread EdgarAlejandro Vintimilla
you're right, thanks I still have to improve this code and keep learning GO On Sunday, July 10, 2016 at 11:38:33 PM UTC-5, kortschak wrote: > > It's worth returning the error from strconv.ParseUint in the general > case. > > On Sun, 2016-07-10 at 21:02 -0700, eav...@gmail.com wrote: > > Than

[go-nuts] TCP Server

2016-07-10 Thread EdgarAlejandro Vintimilla
hi What is the best way to implement a TCP server, I found many examples, including in this book http://cdn.oreillystatic.com/oreilly/booksamplers/9781491941959_sampler.pdf but I would like some recommendation of how to make a more robust TCP server thanks -- You received this message because

Re: [go-nuts] Re: Hi, someone may help me converting this python code to GO

2016-07-10 Thread Dan Kortschak
It's worth returning the error from strconv.ParseUint in the general case. On Sun, 2016-07-10 at 21:02 -0700, eavi...@gmail.com wrote: > Thanks every one > > finally did it > > https://play.golang.org/p/20KzDE_u2a > -- You received this message because you are subscribed to the Google Group

[go-nuts] which approach to appending a slice to another slice by creating a new slice look best to you?

2016-07-10 Thread Anmol Sethi
https://gist.github.com/nhooyr/7b773ea98f0d08e698d4fe706b4f5b2a -- 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] Re: Hi, someone may help me converting this python code to GO

2016-07-10 Thread eavinti
Thanks every one finally did it https://play.golang.org/p/20KzDE_u2a - On Saturday, July 9, 2016 at 11:04:01 PM UTC-5, eav...@gmail.com wrote: > > def GetCrc16(strHexData): > crc16tab = ( > 0x, 0x1189, 0x2312, 0x329B, 0x4624, 0x57AD, 0x6536, 0x74BF, > 0x8C48, 0x9DC1

Re: [go-nuts] Strange behaviour of Goroutine with time.Sleep on macOS 10.12

2016-07-10 Thread Huy Tr.
Thank you so much! I think I should update my Go. Huy On Sun, Jul 10, 2016 at 7:30 PM Ian Lance Taylor wrote: > On Sun, Jul 10, 2016 at 7:17 PM, Huy Tr. wrote: > > > > But when I run it on macOS 10.12 beta 2, the loop stop updating after > > running for a while. > > https://golang.org/issue/16

Re: [go-nuts] Strange behaviour of Goroutine with time.Sleep on macOS 10.12

2016-07-10 Thread Ian Lance Taylor
On Sun, Jul 10, 2016 at 7:17 PM, Huy Tr. wrote: > > But when I run it on macOS 10.12 beta 2, the loop stop updating after > running for a while. https://golang.org/issue/16272 It's fixed on tip and will be fixed in 1.7 but all earlier Go releases are broken on 10.12. Ian -- You received this

[go-nuts] Strange behaviour of Goroutine with time.Sleep on macOS 10.12

2016-07-10 Thread Huy Tr.
`Hi everybody, I'm playing around with Goroutine and got a strange issue. I tried to run the following code: package main import ( "fmt" "time" ) func loop(c chan int) { i := 0 for { time.Sleep(time.Second / 30) i = i + 1 c <- i } } func main() {

[go-nuts] Re: Make a multi part request from a stringified body payload

2016-07-10 Thread Aashish Karki
You can store the individual parts separately (along with their type and names) in the db. You can later use https://golang.org/pkg/mime/multipart/#NewWriter to create a multipart request out of the individual parts. On Sunday, July 10, 2016 at 6:13:47 PM UTC-4, Mayank Jha wrote: > > I wish to

Re: [go-nuts] Go can't alloc custom objects from byte slice's memory address?

2016-07-10 Thread Ian Lance Taylor
On Sun, Jul 10, 2016 at 9:17 AM, wrote: > It is safe to assume that GC scanner will never go into maped by user > regions? I.e. we can safely use mmapped pools for small objects that > references only other objects from that pool? The GC will not look at memory that you allocate yourself using m

Re: [go-nuts] Need critiques on the usage of runtime.Gosched

2016-07-10 Thread Ian Lance Taylor
On Sun, Jul 10, 2016 at 1:03 PM, wrote: > I came up with piece of code to use runtime.Gosched for batching multiple > requests "auto-magically" from the client side. > > https://play.golang.org/p/QK1wbtgVLf > > It works and it is actually very useful for many scenarios, but I wonder if > this is

Re: [go-nuts] Go can't alloc custom objects from byte slice's memory address?

2016-07-10 Thread sphilippov
It is safe to assume that GC scanner will never go into maped by user regions? I.e. we can safely use mmapped pools for small objects that references only other objects from that pool? воскресенье, 10 июля 2016 г., 5:07:19 UTC+3 пользователь Ian Lance Taylor написал: > > On Fri, Jul 8, 2016 at

[go-nuts] Need critiques on the usage of runtime.Gosched

2016-07-10 Thread bigdrum0
I came up with piece of code to use runtime.Gosched for batching multiple requests "auto-magically" from the client side. https://play.golang.org/p/QK1wbtgVLf It works and it is actually very useful for many scenarios, but I wonder if this is a good/bad way of doing stuff like this, or is the

Re: [go-nuts] Re: Hi, someone may help me converting this python code to GO

2016-07-10 Thread Dan Kortschak
On Sun, 2016-07-10 at 15:34 -0700, eavi...@gmail.com wrote: > 1) it not return exactly what return the code in python The code I have on the playground gives the same return as your python code. -- You received this message because you are subscribed to the Google Groups "golang-nuts" group. T

Re: [go-nuts] Re: Hi, someone may help me converting this python code to GO

2016-07-10 Thread Dan Kortschak
You are doing way too much work. Use the features of the language. When you say `fcs, _ := strconv.ParseUint("", base, size)`, why not just `fcs := uint16(0x)`. Make your integer types in Crc16 uint16 since that is what you are working with. On Sun, 2016-07-10 at 15:34 -0700, eavi...@gmai

Re: [go-nuts] Re: Hi, someone may help me converting this python code to GO

2016-07-10 Thread Michael Jones
Here is a direct solution for #2: strChecksum := fmt.Sprintf("0%0*xx", lengthOfHexCRC, GetCrc16(requestData))     fmt.Println(strChecksum) or     return strChecksum For #1, I am not sure what the problem is since I don’t know what you really want. I will say that

[go-nuts] Re: New Context method in http.Request, what can we do with it?

2016-07-10 Thread Matt Silverlock
Use it to pass connection/request-scoped values: that is, values that could only exist once you have a request. authentication tokens, user details, connection IDs: things that can't be known/generated before the connection has been received. e.g. gorilla/mux (https://github.com/gorilla/mux) us

[go-nuts] Re: Redis / Gin Framework Performance Issue

2016-07-10 Thread Matt Silverlock
- Are your wrk threads starving your Go program? (why 10 threads? Why not 4 for wrk, 4 for Go?) - How are you connecting to Redis? (TCP? Unix socket?) - What size pool have you set for Redis? - Show us your code. This is likely a classic example of where framework 'benchmarks'

[go-nuts] Re: Hi, someone may help me converting this python code to GO

2016-07-10 Thread eavinti
sorry, I should not ask for all the work this is the code in GO, and I have two problems 1) it not return exactly what return the code in python 2) I have problem converting this line << return format(intNum, "0" + str(lenOfHexString) + "x") >> package main import ( "fmt" "strcon

[go-nuts] Re: Make a multi part request from a stringified body payload

2016-07-10 Thread Mayank Jha
I wish to store this string payload in a DB, and then construct a multipart request from this, and make one. On Sunday, July 10, 2016 at 6:41:17 PM UTC+5:30, Egon wrote: > > Not quite sure what you mean by reconstructing the request. There is > https://golang.org/pkg/mime/multipart/ for parsing

[go-nuts] Missing .a files after installing module with go get

2016-07-10 Thread Dave Cheney
Can you please post the source of main.ho. -- 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 options, visit https

Re: [go-nuts] Hi, someone may help me converting this python code to GO

2016-07-10 Thread Michael Jones
Dan, i was guessing that the code was specifying a 16 bit integer for the running crc. That's why i am curious. On Jul 10, 2016 2:42 PM, "Jesper Louis Andersen" < jesper.louis.ander...@gmail.com> wrote: > > On Sun, Jul 10, 2016 at 5:07 AM, wrote: > >> def GetFormattedHex(intNum, lenOfHexString):

Re: [go-nuts] Hi, someone may help me converting this python code to GO

2016-07-10 Thread Jesper Louis Andersen
On Sun, Jul 10, 2016 at 5:07 AM, wrote: > def GetFormattedHex(intNum, lenOfHexString): > return format(intNum, "0" + str(lenOfHexString) + "x") > Where do you get stuck in the translation? It looks pretty straightforward. Build the table of constants, implement the loop in GetCrc16. Set up a tes

[go-nuts] Re: Make a multi part request from a stringified body payload

2016-07-10 Thread Egon
Not quite sure what you mean by reconstructing the request. There is https://golang.org/pkg/mime/multipart/ for parsing MIME multipart. On Sunday, 10 July 2016 15:39:00 UTC+3, Mayank Jha wrote: > > Any clues people ? > > On Thursday, July 7, 2016 at 5:05:13 PM UTC+5:30, Mayank Jha wrote: >> >> I

[go-nuts] Re: Make a multi part request from a stringified body payload

2016-07-10 Thread Mayank Jha
Any clues people ? On Thursday, July 7, 2016 at 5:05:13 PM UTC+5:30, Mayank Jha wrote: > > I have the payload, > "--3c1e04950334427b > Content-Disposition: form-data; name="certificate"; filename="new-cert.pem" > Content-Type: application/octet-stream > > -BEGIN RSA PRI

Re: [go-nuts] Re: Hi, someone may help me converting this python code to GO

2016-07-10 Thread Dan Kortschak
Not here. On Sun, 2016-07-10 at 10:04 +0100, Michael Jones wrote: > I get “030a1x” as the result of my Go port. Is that what you expected? -- You received this message because you are subscribed to the Google Groups "golang-nuts" group. To unsubscribe from this group and stop receiving emails

[go-nuts] Redis / Gin Framework Performance Issue

2016-07-10 Thread desaiabhijit
I am getting only - 29 k req/sec, can you please help me as Redis document says it support 80 k+ req/sec reads not sure if I am doing any wrong Machine - 8 core with 57 gb ram + ssd Go - 1.6.2 linux/amd64 Ubuntu - 15.10 DB - Redis Plugin - gopkg.in/redis.v3 Key - only "hello" value Webservice -

Re: [go-nuts] Re: Hi, someone may help me converting this python code to GO

2016-07-10 Thread Michael Jones
I get “030a1x” as the result of my Go port. Is that what you expected? —— Michael Jones michael.jo...@gmail.com On Sun, Jul 10, 2016 at 6:10 AM, Kevin Powick wrote: Glad to see you put some effort into it yourself. -- You received this message because you are subscribed to the Google Groups "go

[go-nuts] Re: Does http PATCH not read body data ?

2016-07-10 Thread Mayank Jha
Oops! I feel like banging my head in a stone wall. How silly of me! :P. Btw thanks! :) On Sunday, July 10, 2016 at 3:54:36 AM UTC+5:30, C Banning wrote: > > try: https://play.golang.org/p/2RDK8JVO_2 > > On Saturday, July 9, 2016 at 12:12:42 PM UTC-6, Mayank Jha wrote: >> >> I am using, https://p