Filenames, Keywords and Identifiers

I am a self-taught Fullstack Web and Mobile App developer with over 4 years of experience. I have built a few apps using React and React Native with a backend in Nest.JS and Express.JS
Search for a command to run...

I am a self-taught Fullstack Web and Mobile App developer with over 4 years of experience. I have built a few apps using React and React Native with a backend in Nest.JS and Express.JS
No comments yet. Be the first to comment.
In this series, I will write articles that help you understand go! I am learning go so I am writing this series as a note for myself and hope you also love this series and learn along with me!
In Go, packages are a key component of organizing and structuring code. Think of them like libraries, modules, or namespaces in other programming languages. Packages help you group related code together. When you build a Go program, it consists of on...
In this lesson, we’ll explore how pointers work in Go, which is different from languages like Java and .NET. Go gives programmers control over memory allocation and layout, though it doesn’t support pointer arithmetic (e.g., adding to or subtracting ...

The time package offers the Time datatype, which represents an instant in time. It also includes several functions for extracting and formatting different components of a timestamp. For example, you can get the current time using time.Now(), and then...

In this guide, we'll explore how to work with strings and the strconv package in Go, covering useful functions that help manipulate and convert strings. Common String Operations Go provides several built-in functions in the strings package that allow...

In this lesson, we'll dive deep into the string datatype in Go. Strings are a sequence of UTF-8 characters. Go efficiently handles string memory by reserving only 1 byte for ASCII characters when possible, and between 2-4 bytes for UTF-8 characters w...

In Go, operators are symbols used to perform operations, such as arithmetic, logical, or bitwise operations. This lesson will cover different types of operators and their behaviour, along with examples and ASCII diagrams where needed. Arithmetic Ope...

In Go, source code is stored in files with the .go extension. These filenames follow a simple convention—using only lowercase letters. For example, a file might be named educative.go. When you need to use multiple words in the name, the words are separated by underscores, like db_connection.go. It’s important to note that Go filenames can’t contain spaces or special characters beyond the underscore.
As for the code inside the file, there’s no strict limit on how long each line can be, though keeping lines readable is always a good practice.
A keyword in any programming language is a reserved word that has a special meaning and can’t be used for anything else, like naming variables or functions. Go has 25 keywords that you'll encounter regularly when writing code.
Here's a list of all Go keywords:

These words are the backbone of Go’s syntax, so you’ll want to familiarize yourself with them as you continue learning.
An identifier is a name you assign to different elements in your code, such as variables, functions, structs, and so on. Like many other programming languages, Go is case-sensitive, meaning that MyVariable and myvariable would be treated as two distinct identifiers.
Identifiers in Go must start with either a letter (from the Unicode set, so you can use more than just English letters) or an underscore (_). After the first character, you can include any combination of letters and digits.
Some examples of valid identifiers:
X56
group1
_x23
i
өԑ12
But not everything is valid. Here are some examples of invalid identifiers:
1ab (since it starts with a number)
case (because it's a Go keyword)
a+b (operators aren’t allowed in identifiers)
In addition to keywords, Go also has a set of 36 predeclared identifiers, which include the names of basic types and built-in functions. Here’s a list of them:

Go includes a special identifier: _, called the blank identifier. You can use it in variable declarations and assignments, but it discards the value assigned to it. It’s useful when you need to ignore certain return values or data in your code. For example, if a function returns two values but you only need one, you can assign the unwanted value to _.
Sometimes it is possible that even functions have no name because it is not really necessary at that point in the code and not having a name even enhances flexibility. Such functions are called anonymous.
Programs consist of keywords, constants, variables, operators, types and functions. It is also important to know the delimiter and punctuation characters that are a part of Golang.
The following delimiters are used in a Go program:
Parentheses ()
Braces {}
Brackets []
The following punctuation characters are used in a Go program:
.
,
;
:
...
The code is structured in statements. A statement doesn’t need to end with a ; (like it is imposed on the C-family of languages). The Go compiler automatically inserts semicolons at the end of statements. However, if multiple statements are written on one line (a practice which is not encouraged for readability reasons), they must be separated by ;.
That’s it about the basic structure and elements of Golang. In the next lesson, we’ll see a basic component of the Go program.