[問題] kwargs in Golang
因為沒有 Golang 版,所以在這邊發問。
最近開始學習 Golang,才覺得 Python 寫起來真的很爽快。
想要問一下 python 的 kwargs 功能,在 Golang 怎麼達成?
例如我的function只要定義成以下:
def my_func(v, **kwargs):
之後 call 的時候,我可以這樣做
my_func(1, k1=1, k2=2, k3=3)
或是
my_func(1, k1=1, k2=2, k3=3, k4=4)
這樣我的 function interface 都不用動,請問在 Golang 怎麼做到這樣呢?
--
※ 發信站: 批踢踢實業坊(ptt.cc), 來自: 211.22.61.74
※ 文章網址: https://www.ptt.cc/bbs/Python/M.1515640379.A.AC9.html
→
01/11 11:33,
8年前
, 1F
01/11 11:33, 1F
→
01/11 11:41,
8年前
, 2F
01/11 11:41, 2F
→
01/11 12:05,
8年前
, 3F
01/11 12:05, 3F