【发布时间】:2021-07-08 18:56:58
【问题描述】:
我需要在 GO 中解析不同的参数(多个重复和逗号分隔)。这个例子我该怎么做:
go run ./test.go -param "one, two" -param "tree" -param "four"
This example 很好,但不适用于上述示例:
[one, two tree four]
即它适用于多个重复参数,但不适用于逗号分隔。
如何改进上述脚本以解析多个参数,包括逗号分隔以在结果中获取此(无逗号):
[one two tree four]
?
【问题讨论】: