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 timeout, and loop. On Wednesday, March 25, 2020 at 4:10:19 AM UTC-4, 洪嘉鴻 wrote: > > 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("Hello!")) > > Client: > while(!ws.Read(msg)){ > fmt.Println("Please wait because server is busy.") > } > > Can anyone suggest how to fix the code? > > Any help is appreciated. > Thank you very much! > Max > -- 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 view this discussion on the web visit https://groups.google.com/d/msgid/golang-nuts/d267f032-09e3-4224-90d1-b4939ebca69a%40googlegroups.com.