Keywords in Go

Golang is a programming language that has gained significant popularity in recent years due to its simplicity and readability of syntax, supported by the use of keywords.

Keyword - Keywords or reserved words are words in the language that are used for some internal processes or represent some predefined actions. Therefore, these words are not allowed to be used as identifiers. Doing so will result in compilation errors. Here is what you need to know about keywords in Golang .

Keywords in Go

For example:

// Minh họa chương trình Go sử dụng từ khóa
package main 
import "fmt"

// Từ khóa ở đây là package, import, func, var 
func main() { 

// Đây là một biến hợp lệ
var a = "Quantrimang"

fmt.Println(a) 

// Ở đây, mặc định là một
// định danh không hợp lệ và
// trình biên dịch sẽ đưa ra lỗi
// var default = "GFG" 
} 

Result:

Quantrimang

Go programming currently has a total of 25 keywords:

Keywords in Go

  • break − Used to exit a loop or switch statement.
  • case − Used in a switch statement to specify a possible match for the input value.
  • chan − Used to create communication channels between goroutines.
  • const − Used to define a constant value that cannot be changed.
  • continue − Used to skip the current iteration of a loop and move to the next iteration.
  • defer − Used to schedule a function call to be executed after the current function returns.
  • else − Used to specify an alternative block of code to execute if the if condition is false.
  • fallthrough − Used in a switch statement to specify that control will pass to the next case.
  • for − Used to create a loop that repeats a block of code a specified number of times.
  • func − Used to define a function that can be called from other parts of the program.
  • go − Used to start a new goroutine.
  • goto − Used to jump to a specific label within the current function.
  • if − Used to execute a block of code only if a certain condition is true.
  • import − Used to import a package into the program.
  • interface − Used to define a set of methods that a type must implement.
  • map − Used to define a set of key-value pairs.
  • package − Used to define a package containing one or more Go source files.
  • range − Used to iterate over an array, slice, sequence, map, or channel.
  • return − Used to exit a function and return a value to the caller.
  • select − Used to wait for a value to be sent to one of multiple channels.
  • struct − Used to define a set of fields representing a complex data type.
  • switch − Used to execute a block of code based on the value of an expression.
  • type − Used to define a new data type.
  • var − Used to declare a variable.

For example:

// Minh họa chương trình Go sử dụng từ khóa

// Từ khóa package được dùng để bao gồm main package trong chương trình
package main 

// Từ khóa import được dùng để nhập "fmt" vào trong package 
import "fmt"

// func được dùng để tạo hàm
func main() { 

	// Từ khóa var được dùng để tạo biến
	// Pname, Lname, and Cname là các biến hợp lệ
	var Pname = "Quantrimang"
	var Lname = "Go Language"
	var Cname = "Keywords"
	
	fmt.Printf("Portal name: %s", Pname) 
	fmt.Printf("\nLanguage name: %s", Lname) 
	fmt.Printf("\nChapter name: %s", Cname) 

} 

Result:

Portal name: GeeksforGeeks
Language name: Go Language
Chapter name: Keywords

Whether you are a beginner or an experienced developer, mastering Golang keywords is an important step towards becoming a proficient Go programmer.

Leave a Comment

Side Hustles That Actually Pay in 2026: 7 Realistic Options and the Tradeoffs to Know

Side Hustles That Actually Pay in 2026: 7 Realistic Options and the Tradeoffs to Know

Compare realistic side hustles for 2026 by startup cost, fees, flexibility, and income control, with current tax and scam guidance from official sources.

Remote Work Ergonomics in 2026: Upgrade Your Home Office Without Overbuying

Remote Work Ergonomics in 2026: Upgrade Your Home Office Without Overbuying

Upgrade your home office ergonomics with current OSHA and NIOSH guidance on chair fit, monitor height, laptop setup, lighting, and movement.

Why Emotional Intelligence Matters in Leadership—and How to Build It

Why Emotional Intelligence Matters in Leadership—and How to Build It

Learn why emotional intelligence matters in leadership, where it helps most, how to strengthen it, and how to tell whether your approach is working.

How to Transition to a Tech Career Without a Degree: A Results-First Roadmap for 2026

How to Transition to a Tech Career Without a Degree: A Results-First Roadmap for 2026

A practical roadmap for moving into tech without a degree: choose an accessible role, build job-ready skills, prove them with projects, and use hiring feedback to improve.

Building a Personal Brand on LinkedIn in 2026: What Still Works, What Changed, and What to Ignore

Building a Personal Brand on LinkedIn in 2026: What Still Works, What Changed, and What to Ignore

Build a credible LinkedIn personal brand in 2026 with current profile, content, newsletter, analytics, verification, and visibility guidance from LinkedIn.

Quiet Quitting vs. Quiet Firing in 2026: What’s Really Changing at Work

Quiet Quitting vs. Quiet Firing in 2026: What’s Really Changing at Work

Quiet quitting and quiet firing are catchy labels, not diagnoses. Learn what is verified, what depends on context, and what employees and managers can do next.

The Rise of the Fractional Executive: When Part-Time C-Suite Leadership Makes Sense

The Rise of the Fractional Executive: When Part-Time C-Suite Leadership Makes Sense

Fractional executives offer senior leadership without a full-time hire. Learn when the model works, what to ask, and the risks to manage.

How to Negotiate a Raise During Q4 Performance Reviews: A Practical 2026 Decision Guide

How to Negotiate a Raise During Q4 Performance Reviews: A Practical 2026 Decision Guide

Prepare a stronger Q4 raise request with current wage data, timing options, compensation tradeoffs, and scripts for yes, partial, or no outcomes.

6 High-Income Skills You Can Start Learning Before 2026 Ends

6 High-Income Skills You Can Start Learning Before 2026 Ends

Choose a high-income skill you can realistically start before 2026 ends, with current pay data, learning priorities, and a practical self-check.

Mastering the Hybrid Work Schedule: A Practical Framework That Actually Holds Up

Mastering the Hybrid Work Schedule: A Practical Framework That Actually Holds Up

Build a hybrid work schedule around tasks, team overlap, and measurable outcomes. See sample patterns, warning signs, and when to adjust your plan.