Search⌘ K
AI Features

Public and Private Declarations

Explore how Go manages visibility of constants, variables, functions, and methods through public and private declarations. Understand how naming conventions determine accessibility within and outside packages to help you design clear and maintainable code structures.

We'll cover the following...

Introduction

Many modern languages provide a set of options when declaring constants/variables/functions/methods that detail when a method can be called. Go simplifies these visibility choices down to two types:

  • Public (exported)

  • Private (not exported)

Public types are types ...