
I am a full-stack developer at BigBinary.
What is Go or Golang?
Go is an expressive, concise, clean, and efficient programming language. Go is a fast, statically typed, compiled language but feels like a dynamically typed, interpreted language. At times it resembles C in terms of Syntax.
Installing Go
We are not going to discuss specific steps of installation as it is already mentioned on https://golang.org/. In this series, we are going to use https://replit.com/ for writing our programs.
Write a program to print "Hello Gopher" on stdout
package main
import "fmt"
func main() {
fmt.Println("Hello Gopher")
}
//=> go run main.go
Hello Gopher
Save the above as main.go and run go run main.go to see the output.
Let's understand what each specific statement means.
package main
- usually, in computer science a package is a collection of shared functions/methods.
packagekeyword in Go is used to name a package.mainpackage in Go tells the Go compiler that the package should compile as an executable program instead of a shared library.- the
mainfunction in the packagemainis the entry point of every Go executable program.
import "fmt"
importkeyword with a<package name>tells the compiler that the program is going to use an external package for using the functions defined in that package.import "fmt"importsfmtpackage that contains methods to interact withstdin&stdout. Packagefmtimplements formatted I/O with functions analogous to C'sprintfandscanf.
func main() {...}
funckeyword is used to declare a function in Go. As already said, every program in Go starts withmainfunction. Function contains statements wrapped inside{}.
fmt.Println("Hello Gopher")
- we already know that
fmtis a package containing functions that can be used in any other package.fmt.Println("Hello Gopher")invokesPrintlnfunction with"Hello Gopher"as a parameter.Printlnstands forprint linewhich prints and adds a line break at the end.
- we already know that
How to run a Go program
go run main.gocompiles and runs a Go program.go build -o <output-filename>compiles a Go program and creates an executable output file with the name specified for-o.
That is it for this part, in the next part we will solve few simple mathematical problems in Go and get to know about DataTypes and Variables in Go.




