DEV Community

Assis Zang
Assis Zang

Posted on

Public C# methods VS public Go functions 🤺

In C# to create a public method you must use this:

public void CreateBook(Book book){
   //do something
}
Enter fullscreen mode Exit fullscreen mode

In Go to create a public function you must use this:

func CreateBook(product *structs.Product) error {
   //do something
}
Enter fullscreen mode Exit fullscreen mode

Note that in C# it is necessary to use the reserved word public and to create a private method, private is used.

In C# they are called Access Modifiers, there are others, you can check the complete list here: C# Access Modifiers - Reference.

In Go to differentiate public from private functions, the initial of the function name is used.

For public functions, capital letter is used. Example: CreateBook().

For private functions use lowercase initials. Example: createBook().

Top comments (0)

Image of Docusign

🛠️ Bring your solution into Docusign. Reach over 1.6M customers.

Docusign is now extensible. Overcome challenges with disconnected products and inaccessible data by bringing your solutions into Docusign and publishing to 1.6M customers in the App Center.

Learn more