Public C# methods VS public Go functions 🤺
Assis Zang

Assis Zang @zangassis

About: Software Developer 👨🏻‍💻 | Technical Writer ✍️ | Passionate about Japanese culture 🍙. I love colorful things 🧁, action figures, and manga

Location:
Carazinho, Rio Grande do Sul - Brazil
Joined:
Mar 21, 2021

Public C# methods VS public Go functions 🤺

Publish Date: Jun 3 '23
0 0

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().

Comments 0 total

    Add comment