Basics of Go


Maximiliano Firtman

Maximiliano Firtman

Independent Consultant
Basics of Go

Check out a free preview of the full Basics of Go course

The "Visibility" Lesson is part of the full, Basics of Go course featured in this preview video. Here's what you'd learn in this lesson:

Maximiliano gives a concise overview of visibility in Go, explaining the concepts of defining public or private elements and discussing the various scoping options for variables and lambda functions.


Transcript from the "Visibility" Lesson

>> So, to summarize the Visibility part. So, what we write in a module in a package, if it's camelCase, camelCase, it starts with lowercase. So lower case c, it means it's private to the package for example. If it's TitleCase, it's public and exported, right? So, variables and lambda functions, lambda functions, what's that?

Gimmie a sec. They can be module scoped, function scoped, or block scoped. Something that we already mentioned. So, lambda functions are just functions. Sometimes we name the functions as we did so far, such as the main functions, and also we have a way to treat functions as a special kind of variable.

So maybe we can create a function that has no name, but we can attach a link to the function that's a variable, that's kind of a function anyway. So for example, here, notExported, it's private to the package. It can only be used in the package. Remember, that means it can be used from other go files in the same package, but not from other packages.

And if it's TitleCase, it's public and exported to other packages. That's the only thing you need to remember. Simple, right?

Learn Straight from the Experts Who Shape the Modern Web

  • In-depth Courses
  • Industry Leading Experts
  • Learning Paths
  • Live Interactive Workshops
Get Unlimited Access Now