Go in 2 minute read
Go is an open source statically type compiled programming language which designed at Google by Robert Griesemer, Rob Pike, and Ken Thompson in 2007 and launched in 2009. Its design prioritizes simplicity, efficiency, and learnability, which has resulted in its widespread use for developing scalable network services, web applications, and command-line utilities. Go is language that build popular tools like docker, kubernetes, cockroachDB etc.
Getting started
To get started, install go and create a go file then add package main
at the top of code to create standalone executable and you can write your code in the main
function. Go has a standard library from it’s core packages for handles common requirements such as math, strings, fmt and etc.
package main
import "fmt"
func main() {
fmt.Println("Hello World!")
}
Run go build hello.go
for compile the source code and dependencies into an executable binary file.
Go has a package and module system making it easy to import and export code between project. A module is a collection of packages that are released, versioned, and distributed together. Run go mod init go-project
and it will create a go.mod
file that enables dependency tracking. Use go get repository
to install necessary dependency from repository.
# Install gin package from github.com/gin-gonic/gin
go get github.com/gin-gonic/gin
Go has rich support of concurrency using goroutine. A goroutine is a lightweight thread managed by the Go runtime. Place a keyword go
followed by function invocation to create a goroutine.
package main
func main() {
go hello()
}
func hello() {
fmt.Println("Hello");
}
Thank you for read my post, please feel free to leave comments for any suggestions or questions. Share if you find this post useful. See ya
References
- https://go.dev/
- https://en.wikipedia.org/wiki/Go_(programming_language)
- https://www.geeksforgeeks.org/go-programming-language-introduction/
- https://www.golang-book.com/books/intro/10
- https://www.youtube.com/watch?v=446E-r0rXHI