我正在将客户端从 python 移植到 API。原始实现使用可选参数作为
def createIntAttribute(attr_name, default_value=None, is_array=False)
Run Code Online (Sandbox Code Playgroud)
它在数据库上创建一个带有或不带有默认值的整数属性,如下所示:
createIntAttribute("numUsers") # No default attribute
createIntAttribute("numUsers", 0) # Default attribute of 0
Run Code Online (Sandbox Code Playgroud)
这在 Go 中如何实现?
我考虑过的一些方法是:
defaultValue *int&并且不支持文字mypackage.NewOptionalStringArray([]string{"hello", "world"})func createIntAttribute(name string, optionals ...interface{})实现这一点的最佳方法是什么?
go ×1