[go-nuts] Re: remove last index of character from string and also want use strings.LastIndex(s, sep string)

2017-05-26 Thread long . asyn
I find the method like: package main import ( "fmt" "strings" "unicode/utf8" ) func main() { var str = "a/b/汉字/d/汉字" var _, size = utf8.DecodeLastRuneInString(str) // Does `str[0:len(str)-size]` have memory copy? var i = strings.LastIndex(str[0:len(str)-size], "/汉字") fmt.Println(i) }

Re: [go-nuts] remove last index of character from string and also want use strings.LastIndex(s, sep string)

2017-05-26 Thread long . asyn
Thanks for your reply. the `str[0:len(str)-1]` not work for NO ascii chracters. https://play.golang.org/p/7i6-3Zcy36 On Friday, May 26, 2017 at 11:06:10 PM UTC+8, messju mohr wrote: > > Hi, > > On Fri, May 26, 2017 at 07:10:43AM -0700, long...@gmail.com > wrote: > >var str

[go-nuts] How do you pass around an HTTP response?

2017-05-26 Thread ask dev
If I delegate the handling of a request, but still want information about the response (status code, compressed, content length). How should that information be returned without risk of leaving the connection open? Close the response body and return the response? Close the response, transfer

[go-nuts] Re: Go Socket vs C Socket for single-threaded/single CPU socket programming

2017-05-26 Thread Egon
On Friday, 26 May 2017 21:32:43 UTC+3, David Streckert wrote: > > This might be a silly question, but I’m going to ask anyway. I'm working > on a High-Frequency Trading program for educational purposes. I don’t > expect it to make money; it’s a fun project to learn about socket > programming.

[go-nuts] Re: How fast can gopacket handles?

2017-05-26 Thread Egon
On Friday, 26 May 2017 20:51:55 UTC+3, Chun Zhang wrote: > > Good point. > as a comparison: tcpdump -w /dev/null can handle up to 750Mbps, where > sending machine's speed limit reached. I think it should be able to handle > line rate. > > Are those two packages lighter/faster than gopacket? >

Re: [go-nuts] Re: Tooling experience feedback

2017-05-26 Thread Ian Lance Taylor
On Fri, May 26, 2017 at 1:32 PM, E Leong wrote: > > I'm trying to pass arguments to go test using > > go test -args -flag1 val1 -flag2 val2 > > Documentation doesn't explain how one can extract flag1 and flag2 or their > values from within the test. > I am using os.Args to

[go-nuts] Re: Tooling experience feedback

2017-05-26 Thread E Leong
I'm trying to pass arguments to go test using go test -args -flag1 val1 -flag2 val2 Documentation doesn't explain how one can extract flag1 and flag2 or their values from within the test. I am using os.Args to get to them, but that feels like a hack. The only documentation I see right now in

Re: [go-nuts] Go Socket vs C Socket for single-threaded/single CPU socket programming

2017-05-26 Thread Justin Israel
On Sat, May 27, 2017, 7:46 AM wrote: > The brokerage firm's servers are in NYC. In order to get server > co-location I’m considering renting our a virtual server in NYC from a > company called Linode. Their servers start at $5 a month at this price > point you get one

Re: [go-nuts] Go Socket vs C Socket for single-threaded/single CPU socket programming

2017-05-26 Thread streckertdavid
The brokerage firm's servers are in NYC. In order to get server co-location I’m considering renting our a virtual server in NYC from a company called Linode. Their servers start at $5 a month at this price point you get one CPU for your virtual server. I did not know multiple threads can be

Re: [go-nuts] Go Socket vs C Socket for single-threaded/single CPU socket programming

2017-05-26 Thread Steven Hartland
Why do you say it will be single threaded? I ask as even with a single core multiple threads can be beneficial. Even with GOMAXPROCS=1 the go runtime will multiplex multiple requests efficiently without you thinking about it. On Fri, 26 May 2017 at 19:32, wrote: >

[go-nuts] Go Socket vs C Socket for single-threaded/single CPU socket programming

2017-05-26 Thread streckertdavid
This might be a silly question, but I’m going to ask anyway. I'm working on a High-Frequency Trading program for educational purposes. I don’t expect it to make money; it’s a fun project to learn about socket programming. It will be a single-threaded program running on one CPU that will

[go-nuts] Re: How fast can gopacket handles?

2017-05-26 Thread Chun Zhang
Good point. as a comparison: tcpdump -w /dev/null can handle up to 750Mbps, where sending machine's speed limit reached. I think it should be able to handle line rate. Are those two packages lighter/faster than gopacket? Thanks, Chun On Friday, May 26, 2017 at 12:37:55 PM UTC-4, Egon

[go-nuts] Re: How fast can gopacket handles?

2017-05-26 Thread Egon
As a baseline measurement I suggest writing the same code in C; this shows how much your VM / config / machine can handle. With gopacket -- use src.NextPacket instead of Packets. There are also: https://github.com/akrennmair/gopcap and https://github.com/miekg/pcap + Egon On Friday, 26 May

[go-nuts] How fast can gopacket handles?

2017-05-26 Thread Chun Zhang
Hi, All, I am trying to write a small program to handle packets coming from a GigE wire. The testing code snip is as below. The problem I am facing is that this is extremely slow, can only handle up to 250Mbps-ish traffic with normal ipv4 sized packets, anything above that resulting

Re: [go-nuts] remove last index of character from string and also want use strings.LastIndex(s, sep string)

2017-05-26 Thread messju mohr
Hi, On Fri, May 26, 2017 at 07:10:43AM -0700, long.a...@gmail.com wrote: >var str = "a/b/c/d/c" >// I want remove last chracter from str >var strRunes = []rune(str) >var newStrRunes = strRunes[0 : len(strRunes)-1] >//

[go-nuts] remove last index of character from string and also want use strings.LastIndex(s, sep string)

2017-05-26 Thread long . asyn
var str = "a/b/c/d/c" // I want remove last chracter from str var strRunes = []rune(str) var newStrRunes = strRunes[0 : len(strRunes)-1] // then I want get last index of chracters `/c`, I need convert to string back!???

[go-nuts] Re: idea: generic methods on slices with some generic type support []string.Map(string) []string => [].Map() []

2017-05-26 Thread mhhcbon
oops... mistake in it. printS, err := conv(func(s string, err error), fmt.Println) or panic(err) _, err := []string{"hello}.Map(strings. ToUpper).MustEach(printS) or panic(err) count, err := conv(func(s string) n int, fmt.Println) or panic(err) n :=

[go-nuts] Re: idea: generic methods on slices with some generic type support []string.Map(string) []string => [].Map() []

2017-05-26 Thread mhhcbon
or this, printS, err := conv(func(s string, err error), fmt.Println) or panic(err) _, err := []string{"hello}.Map(strings.ToUpper).MustEach(printS) or panic(err) count, err := conv(func(n int), fmt.Println) or panic(err) n := []string{"hello}.Map(strings.ToUpper).Sum(count) count, err :=

[go-nuts] Re: idea: generic methods on slices with some generic type support []string.Map(string) []string => [].Map() []

2017-05-26 Thread mhhcbon
for the fun, I want to write []string{"hello}.Map(strings.ToUpper).Each(fmt.Println) would not work, func param are incompatible. let s apply static rules to convert it, printS, err := conv(func(s string), fmt.Println) or panic(err) []string{"hello}.Map(strings.ToUpper).Each(printS) Now it s

[go-nuts] Re: idea: generic methods on slices with some generic type support []string.Map(string) []string => [].Map() []

2017-05-26 Thread mhhcbon
as i m on it, please consider, what below code might be with little imagination, // Create a new Tomate func (t Controller) Create(postColor *string) (jsonResBody *Tomate, err error) { mustNot(postColor, nil) or return ... {errors.New("Missing color parameter")} color, _ :=

[go-nuts] Re: idea: generic methods on slices with some generic type support []string.Map(string) []string => [].Map() []

2017-05-26 Thread mhhcbon
would not it be nice to write []string{"hello}.Map(strings.ToUpper) ? And so for userland types the language accept, []*MyType.Filter(func(*MyType)*MyType).Map(...).First()//etc. IRL, because the total lack of such struct in the language might let you think the idea is superfluous with the

Re: [go-nuts] Problem with HINDI NAMES

2017-05-26 Thread Bakul Shah
On May 25, 2017, at 6:25 PM, Vikram Rawat wrote: > > Hello Bakul, > > I am just an R programmer(by which i mean i don't understand programming > much). I was looking for an alternative way to python. I really don't > understand what you said but i want to let you all

Re: [go-nuts] Problem with HINDI NAMES

2017-05-26 Thread Nathan Kerr
The Go team knows this a problem (see the issues listed by Rob Pike). The difficultly in fixing it is that the ecosystem surrounding Go relies on the current definition for identifiers. There is no way to add the characters you need without breaking other tools like syntax highlighters. It is