{"id":783,"date":"2019-12-01T07:33:05","date_gmt":"2019-12-01T07:33:05","guid":{"rendered":"https:\/\/golangbyexamples.com\/?p=783"},"modified":"2019-12-01T07:35:58","modified_gmt":"2019-12-01T07:35:58","slug":"function-method-overloading-golang","status":"publish","type":"post","link":"https:\/\/golangbyexamples.com\/function-method-overloading-golang\/","title":{"rendered":"Function\/Method Overloading in Golang (Alternatives\/Workaround)"},"content":{"rendered":"\n

Function\/Method Overloading means that that the same function\/method name can be used with a different number and types of parameters<\/p>\n\n\n\n

See this post for difference between function and method in Go – https:\/\/golangbyexamples.com\/difference-between-method-function-go<\/a><\/p>\n\n\n\n

Eg. <\/p>\n\n\n\n

func X()\nfunc X(name string)\nfunc X(name, address string)\nfunc X(name string, age int)<\/code><\/pre>\n\n\n\n

Go doesn’t support method\/function overloading. See this faq for the reason https:\/\/golang.org\/doc\/faq#overloading<\/a><\/p>\n\n\n\n

According to the above faq things are simpler without it.<\/p>\n\n\n\n

We can workaround Method\/Function overloading in GO using<\/p>\n\n\n\n