Getting Started with Go on the Fly
You can check the complete code for the sample program here Introduction to Go and Why It's Interesting Go is an interesting open-source programming language with a medium learning curve. What intrigued me about Go is that Docker and Kubernetes are written in it. Go is popular for server-side projects and writing tools because its binaries are statically linked. If you don't have Go installed, you can download it here. Understanding Go Packages and Modules Go programs are organized into packages. Packages contain a collection of code files within the same directory. Go releases a collection of packages as a module. A Go repository includes one or more modules. Let's consider building a simple two-number calculator. Go init mod example.com/calculator Go init mod command creates a Go module with go.mod file in the current directory Create a file named main.go in the directory containing your go.mod file. The program's execution begins in the package main. package main import ( "fmt" "log" "os" ) A package is identified by the word that follows the package statement in the code file. You can group imports into parenthesized, “factored” import statements. I made a mistake of using curly braces and a comma; it did not build
You can check the complete code for the sample program here
Introduction to Go and Why It's Interesting
Go is an interesting open-source programming language with a medium learning curve. What intrigued me about Go is that Docker and Kubernetes are written in it.
Go is popular for server-side projects and writing tools because its binaries are statically linked.
If you don't have Go installed, you can download it here.
Understanding Go Packages and Modules
Go programs are organized into packages. Packages contain a collection of code files within the same directory. Go releases a collection of packages as a module. A Go repository includes one or more modules.
Let's consider building a simple two-number calculator.
Go init mod example.com/calculator
Go init mod command creates a Go module with go.mod file in the current directory
Create a file named main.go in the directory containing your go.mod file. The program's execution begins in the package main.
package main
import (
"fmt"
"log"
"os"
)
A package is identified by the word that follows the package statement in the code file.
You can group imports into parenthesized, “factored” import statements. I made a mistake of using curly braces and a comma; it did not build