Go, also known as Golang, is an open-source programming language developed by Google. It's known for its simplicity, strong static typing, and efficiency. Some of the main features of Go include:
- Concurrency: Go has built-in support for concurrent programming with goroutines and channels.
- Garbage Collection: Go manages memory automatically, freeing the developer from manual memory management.
- Fast Compilation: Go compiles quickly to machine code yet has the convenience of garbage collection and the power of run-time reflection.
In Go, a package is a collection of source files in the same directory that are compiled together. Functions, types, variables, or constants defined in one source file are visible to all other source files within the same package.
A module is a collection of related Go packages that are released together. A Go module is defined by a go.mod
file at the root of the module directory. This file defines the module path and its dependency requirements.
To initialize a new module, use the go mod init
command followed by the module path. For example:
go mod init github.com/Shikha-code36/golang-tutorial-practice
After running the command go mod init github.com/Shikha-code36/golang-tutorial-practice
, a go.mod
file will be created in the current directory. The module path will be set to github.com/Shikha-code36/golang-tutorial-practice
.
Once the module is initialized, you can build and run your Go program. This involves a few steps:
- Building the Program: This step compiles the Go source file
main.go
located in thetutorial1
directory.
go build tutorial1/main.go
.\main.exe
- Running the Program: After building, you can run the resulting executable. Alternatively, you can directly run the program without creating an executable.
go run tutorial1/main.go
- Basics
- Constants Variables and Basic Data Types
- Functions and Control Structures
- Arrays, Slices, Maps and Loops
- Strings, Runes, and UTF-8 Encoding
- Structs and Interfaces
- Pointers
- Concurrency(Goroutines)
- Channels
- Generics
This repository is for the references, anyone can feel free to use this.