[go-nuts] TCP connection reuse when doing HTTP

2018-04-10 Thread Sun Frank
Hi guys: my question is how to reuse underlying TCP connection when doing a lot of frequent short HTTP requests using golang? I tried things from stackoverflow and other blogs including: https://stackoverflow.com/questions/17948827/reusing-http-connections-in-golang

Re: [go-nuts] TCP connection reuse when doing HTTP

2018-04-10 Thread Sun Frank
fros写道: > > Hi! > > On Tue, Apr 10, 2018 at 06:14:46AM -0700, Sun Frank wrote: > > my question is how to reuse underlying TCP connection when doing a lot > of > > frequent short HTTP requests using golang? > > This happens by default: https://play.golang.or

[go-nuts] While implement ssh client using golang, record keyboard input

2018-10-22 Thread Sun Frank
Hi Everyone: I came across a problem which puzzled me for couple of days. I am trying to write a* SSH client with a Interactive Shell *using golang, but i also need to record the command(or keystroke history) of the user typed, like the history feature, here's my working code: ce := func(err

[go-nuts] Append array to slice of slice behavior puzzles me

2018-11-21 Thread Sun Frank
Hi guys, I came across some code that surprised me, but I could not figured out why it behave like this, s := make([][]int, 0) a1 := [3]int{1, 2, 3} a2 := [3]int{4, 5, 6} s = append(s, a1[:]) s = append(s, a2[:]) fmt.Println(s) mp := make(map[[3]int]bool) mp[[3]int{1, 2, 3}] = true mp[[3]int{4,

Re: [go-nuts] Append array to slice of slice behavior puzzles me

2018-11-21 Thread Sun Frank
, 3} > a2 := [3]int{4, 5, 6} > a3 := [3]int{7, 8, 9} > > s := make([][]int, 0) > a := a1 > s = append(s, a[:]) > a = a2 > s = append(s, a[:]) > a = a3 > s = append(s, a[:]) > > fmt.Println(s) > On Wed, Nov 21, 2018 at 2:41 PM Sun Frank wrote: > > &

[go-nuts] What's the best practice to trace a request in log

2019-05-02 Thread Sun Frank
Hi Guys: Assume we are building a HTTP server, I think it's a pretty common requirement to give each request a requestId and add that requestId as a log field, so log generated by this request all have this unique requestId, so we can do a "grep" in central log system(Graylog, Splunk, ELK,