我想知道是否有一种方法可以像在Java中那样在Go中实现多个构造函数(具有相同的函数名称)。另一种选择可能是只有一个带有可选参数的构造函数,但我不确定该怎么做。ThisseemssimilartowhatIwastryingtodotypeQuerystruct{TagsQuerystringPageQuerystring}//FirstConstructorfuncNewQuery(TagsQuerystring)Query{returnQuery{TagsQuery:TagsQuery,PageQuery:"0",//defaulttofirstpage}}//SecondCons
我想知道是否有一种方法可以像在Java中那样在Go中实现多个构造函数(具有相同的函数名称)。另一种选择可能是只有一个带有可选参数的构造函数,但我不确定该怎么做。ThisseemssimilartowhatIwastryingtodotypeQuerystruct{TagsQuerystringPageQuerystring}//FirstConstructorfuncNewQuery(TagsQuerystring)Query{returnQuery{TagsQuery:TagsQuery,PageQuery:"0",//defaulttofirstpage}}//SecondCons