Variables in Golang

Naming Conventions + Different Ways of Declaring Variables

Gyulnara Grigoryan
1 min readMay 29, 2020

Golang Naming Conventions

  • camelCase — camelCase is a naming convention in which the first letter of each word in a compound word is capitalized EXCEPT for the first letter
  • PascalCase — PascalCase is a naming convention in which the first letter of each word in a compound word is capitalized
  • Capitalize acronyms — ex. HTTP, DNS, URL

Variable names are always important when programming, but especially so when programming in Golang.

  • Variables declared at the package level will not be exported to other packages if the variable starts with a lowercase letter
  • In contrast if a variable declared at the package level starts with an uppercase letter it will be exported to other packages
  • Variables in Go always have to be used. If there are any unused variables the compiler will throw an error.

Different Ways of Declaring Variables

Sign up to discover human stories that deepen your understanding of the world.

Free

Distraction-free reading. No ads.

Organize your knowledge with lists and highlights.

Tell your story. Find your audience.

Membership

Read member-only stories

Support writers you read most

Earn money for your writing

Listen to audio narrations

Read offline with the Medium app

--

--

Gyulnara Grigoryan
Gyulnara Grigoryan

Written by Gyulnara Grigoryan

Software Engineer | Always Learning | interests: coding, photography, piano, writing, reading, and dancing

No responses yet

Write a response