Re: [go-nuts] Why golang allocated memory space increases?

2020-03-25 Thread steve tang
Thanks, I used sync.Pool to allocate a byte.Buffer, and response.Body isn't constant size in program, I find golang will grow the byte.Buffer space against to initial space. I changed code as follows: type SyncPool struct{ Pool sync.Pool } func (s *SyncPool) Get(n int) []byte { //比n大,不需要s

[go-nuts] Golang and the mobile framework

2020-03-25 Thread husam alkdary
It's possible to use Golang with to design mobile app with react-native or Flutter ? -- 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...@goo

Re: [go-nuts] Why golang allocated memory space increases?

2020-03-25 Thread robert engels
If the pool is a sync.Pool: Any item stored in the Pool may be removed automatically at any time without 18 // notification. If the Pool holds the only reference when this happens, the 19 // item might be deallocated. So placing an object in the pool does not guarantee it won’t be collec

[go-nuts] Why golang allocated memory space increases?

2020-03-25 Thread steve tang
chunkCrc32Hash := crc32.NewIEEE() chunkBuf := bufferpool.GetInstance().Get() //回收buffer defer bufferpool.GetInstance().Put(chunkBuf) writer := io.MultiWriter(chunkBuf, chunkCrc32Hash) _, copyErr := io.Copy(writer, chunkResp.RawResponse.Body) if copyErr != nil && copyErr != io.EOF { logmgr.ErrorL

[go-nuts] Re: Print something while read message from server with websocket

2020-03-25 Thread 洪嘉鴻
I'm sorry. The followings are the complete codes of server and client: Server Client Thank you very much! Max Jake Montgomery於 2020年3月25日星期三 UTC+8下午9時28分37秒寫道: > > You do not provide enough information to give a

[go-nuts] json to golang struct definition lib

2020-03-25 Thread sanye
Hello gophers, I found an interesting project: https://github.com/mholt/json-to-go , which translate given json data into golang struct definition, it's very useful when dealing with complex json It's written in javascript, but maybe a golang version is useful when doing some works like code

Re: [go-nuts] Go course

2020-03-25 Thread David Riley
It’s just my opinion, and I’m willing to be wrong. :-) But having TAed a university introductory computer science course that was first in C and then in Python (and having had several students who failed when it was in C retake in Python and pass with flying colors), I will say that a lot of th

Re: [go-nuts] Go course

2020-03-25 Thread Dan Kortschak
I don't agree that Go is intrinsically harder than python as a beginner programming language. There are things that are subtle, but these can largely be avoided in the beginner setting. Note that there have been discussions here about using Go as a language for teaching beginners, notably this one

[go-nuts] Re: Does os.exec work ?

2020-03-25 Thread howardcshaw
What you are really wanting there is to run xsel --clipboard and pipe data into it. Talk to your cmd.Stdin! This is mostly straight from the StdinPipe example in the go docs: cmd := exec.Command ("xsel","--clipboard" ) stdin, err := cmd.StdinPipe() if err != nil { log.Fatal(err) } go func() { de

Re: [go-nuts] Does os.exec work ?

2020-03-25 Thread lgodio2
Than you.. I surely need to beef-up my comprehension of what os.exec does vs what it does not. On Wednesday, March 25, 2020 at 2:54:07 PM UTC-4, Kurtis Rader wrote: > > The exec.Command() function works fine. The problem lies in your > understanding of what happens when you use a shell to execut

Re: [go-nuts] Does os.exec work ?

2020-03-25 Thread Kurtis Rader
The exec.Command() function works fine. The problem lies in your understanding of what happens when you use a shell to execute that command versus what the Go function does. When you type that command at a shell prompt it parses the statement and creates a pipe and runs "echo" on the LHS and "xsel"

Re: [go-nuts] Does os.exec work ?

2020-03-25 Thread Jan Mercl
On Wed, Mar 25, 2020 at 7:30 PM wrote: > > This simple command works correctly when submitted via the terminal, but the > same command submitted to os.exec does not !! > .. and I can`t understand why... os.Exec does not pass commands to the shell, but it is the case in the terminal. Try somethin

[go-nuts] Does os.exec work ?

2020-03-25 Thread lgodio2
This simple command works correctly when submitted via the terminal, but the same command submitted to os.exec does not !! .. and I can`t understand why... import ( "fmt"; "os"; "os/exec"; ) func main() { cb := "ABCD" cmd := exec.Command ("echo", "echo "+ "'" +string(cb [0:len(cb)-1] ) +"'",

Re: [go-nuts] Go course

2020-03-25 Thread David Riley
If you are already a programmer in another language, the Tour of Go (tour.golang.org) is absolutely the best. If you are not already a programmer in another language, I personally don't recommend Go as a first language; it's an excellent language, but I feel that people will do better with it o

[go-nuts] Go course

2020-03-25 Thread Renato Marcandier
Hello guys, What's the best course to start with Go? Regards RG -- 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. To v

[go-nuts] Re: Print something while read message from server with websocket

2020-03-25 Thread Jake Montgomery
You do not provide enough information to give a really good answer. There are a number of ways to achieve this, but they depend on the details. A more complete example would help. What is the type of `ws`? If it is something on which you can set a read timeout, then one way would be to set a t

[go-nuts] Print something while read message from server with websocket

2020-03-25 Thread 洪嘉鴻
Hello everyone: The version of the golang which I am using is 1.12.9 with Win10. I want to print something while the client is waiting for server. The following are the partial code of server and client. Server: time.Sleep(time.Second * 100) ws.Write([]byte("Hel