转了Go没多久,web编程的问题

fengyuedada · · 1706 次点击
5楼 <a href="/user/fengyuedada" title="@fengyuedada">@fengyuedada</a> 用 ... 这样只需要两头改,中间传参不用改 ``` package main import &#34;fmt&#34; func main() { var uid int uid = 100 name := &#34;xxx&#34; ip := &#34;127.0.0.1&#34; args := []string{name, ip} multiParam(uid, name) multiParam(uid, name, ip) multiParam(uid, args...) } func multiParam(uid int, args ...string) { fmt.Print(uid, args) nextcall(uid, args...) } func nextcall(uid int, args ...string) { fmt.Print(uid, args) nextnextcall(uid, args...) } func nextnextcall(uid int, args ...string) { fmt.Print(uid, args) } ``` 如果这样觉得代码不清晰,可以把参数封装成struct 象bean那样传来传去
#8
更多评论
用go就不要分层了,func一把梭全搞定
#1
<a href="/user/tablecell" title="@tablecell">@tablecell</a> 好家伙,公共方法也不抽吗
#2