Andanhm Golang
Andanhm Golang
Andanhm Golang
Go (also referred to as GoLang) is an open source and lower level Google for “dozens of systems”
programming language designed and created at Google in 2009 by Docker a set of tools for deploying linux containers
Robert Griesemer, Rob Pike and Ken Thompson, to enable users to
Openshift a cloud computing platform as a service by Red Hat
easily write simple, reliable, and highly efficient computer programs
Dropbox migrated few of their critical components from Python to Go
Besides its better-known aspects such as built-in concurrency and
garbage collection Netflix for two portions of their server architecture
Go is a statically typed language, it is anti functional programming and anti Soundcloud for “dozens of systems”
OOP, as far as the designers concerned. ThoughtWorks some tools and applications around continuous delivery
Language is very concise, simple and safe. customer, to adapt new business solution and (cloud solution)
distribution tools
Compilation time is very fast.
https://www.qwentic.com/blog/companies-using-golang
Patterns which adapt to the surrounding environment similar to dynamic
languages.
Install
Inbuilt concurrency such as lightweight processes channels and select
statements. OSX brew install go
Supports the interfaces and the embedded types. Run the command below to view your Go version:
go version
https://golang.org/doc/faq
https://golang.org/doc/install
Lack of essential features
Create a file named main.go in the directory src/hello inside your Go packages are folders that contain one more go files.
workspace/go path
Modules
go env Default go system environment
A modules (starting with vgo and go 1.11) is a versioned collection of
https://tour.golang.org packages.
go get github.com/andanhm/go-prettytimee
Running
go mod init github.com/andanhm/go-prettytime
$ cd $HOME/go/src/hello
$ go run main.go Variable & Function Declarations
Hello, World!!
const country = "india"
$ go build
// declaration without initialization
$ ./hello
var age int
Hello, World!!
// declaration with initialization
var age int = 23
Package
// declare and init multiple at once
Package declaration at top of every source file var age, pincode int = 23, 577002
Executables are should be in package main // type omitted, will be inferred
Upper case identifier: public (accessible from other packages) var age = 23
// simple function
Lower case identifier: private (not accessible from other packages)
func person() {
Maps
Struct
Structs are the way to create concrete user-defined types in Go. Struct
types are declared by composing a fixed set of unique fields.
Error() string Go has a built-in testing command called go test and a package testing
} which combine to give a minimal but complete testing experience.
Error
Concurrency
The error type is an interface type.
Goroutines
error variable represents description of the error string
Goroutines are lightweight threads managed by Go
errors.New('user not found')
Channels
fmt.Errorf("%s user not found", "foo")
https://blog.golang.org/error-handling-and-go Channels are a typed conduit through which you can send and receive
values with the channel operator ( <- )
HTTP Handler
A defer statement pushes a function call onto a Last In First Out order Name: "andan.h",
list. The list of saved calls is executed after the surrounding function Age: 27,
returns }
Encoding
https://golang.org/pkg/encoding/
Tool
https://godoc.org/golang.org/x/tools
https://dominik.honnef.co/posts/2014/12/an_incomplete_list_of_go_tools/
https://github.com/campoy/go-tooling-workshop