我的问题很简单.
我应该将GoRoutines用于一个非常简单的REST API吗?
我基本上只对数据库进行简单查询,验证会话或进行登录.这些操作是否值得设置GoRoutine? GoRoutines何时有用,我该如何设置它们?
net / Http包已经为您解决了这个问题.一旦你调用Serve(或更可能是ListenAndServe),就会发生以下情况:
Serve accepts incoming HTTP connections on the listener l,creating a new service goroutine for each. The service goroutines read requests and then call handler to reply to them. Handler is typically nil,in which case the DefaultServeMux is used.
有关更多信息,请参见http://golang.org/pkg/net/http/