Skip to content

Latest commit

 

History

History
58 lines (52 loc) · 3.27 KB

notes.md

File metadata and controls

58 lines (52 loc) · 3.27 KB

Golang difference with C language

  • Golang only has one looping construct for which serves all purpose
  • Golang switch case doesn't need break in each case, it executes only matching case. In C all cases after matching case gets executed if we don't break
  • Golang doesn't support pointer arithematic as supported in C
  • Using struct pointers, golang permits accessing members using dot p.x or (*p).x and in C arrow notation is used access members p->x
  • Methods with pointer receivers take either a value or a pointer as the receiver when they are called: https://tour.golang.org/methods/6
  • Methods with value receivers take either a value or a pointer as the receiver when they are called: https://tour.golang.org/methods/7

Go mod and sum file

https://golangbyexample.com/go-mod-sum-module/

  • go.mod: It defines both project's dependencies requirement and also locks them to their correct version.
  • go.sum: This file lists down the checksum of direct and indirect dependency required along with the version. The checksum present in go.sum file is used to validate the checksum of each of direct and indirect dependency to confirm that none of them has been modified.

Golang tour

https://tour.golang.org

Exercism golang track

https://exercism.org/tracks/go

How to write Go code

https://go.dev/doc/code

  • Go programs are organized into packages. A package is a collection of source files in the same directory that are compiled together.
  • A repository contains one or more modules. A module is a collection of related Go packages that are released together. A Go repository typically contains only one module, located at the root of the repository.
go install <module-path>
# This command builds the hello command, producing an executable binary. It then installs that binary as $HOME/go/bin/hello
# The install directory is controlled by the GOPATH and GOBIN environment variables.
  • The go mod tidy command adds missing module requirements for imported packages and removes requirements on modules that aren't used anymore.

Pending