Go, gRPC, Microservices

1. Go


-  Workspaces( GOPATH )

- Run many files


- Go is static type



- Basic type of Go




- Variable declarations

  Long form:  var card string = "tuan and thu"
  Short form: card := "tuan yeu thu"



- Functions and return types





- Slices and for loops





  Declare: cards := []string{"tuan","thu"}
  
  Append: cards = append(cards,"cuoi")

  Loop:   for index,card := range cards{
              fmt.Println(index,card)
          }

- OO Approach vs Go Approach








- Custom type declarations

  type deck []string

- Receiver functions




- Slice range syntax( like python )

- Multiple return values

- Byte slices

- Joining a slice of strings, Split a string

- Write and read file on hard drive

  nil, os.Exit(1)

- Testing with go


- Struct

  + Declare, Update, Embed, Receiver
  + Pointer









+ To access the field X of a struct when we have the struct pointer p we could write (*p).X. However, that notation is cumbersome, so the language permits us instead to write just p.X, without the explicit dereference.

type Vertex struct {
X int
Y int
}

func main() {
v := Vertex{1, 2}
p := &v

fmt.Println((*p).X)
fmt.Println(p.X) 
}









- Reference vs Value Types








- Map

  + What is a map ?


   + Three ways to declare a map


   + Add and delete on map


   + Iterating over maps

   + Map vs Struct


- Interface

















- Go Routines





- Channel






- dep ( dependency management tool for the Go language )

  dep init                                                        set up a new project
  dep ensure                                                   install the project's dependencies
  dep ensure -update                                     update the locked versions of all dependencies
  dep ensure -add github.com/pkg/errors   add a dependency to the project


2. gRPC

- What is gRPC, RPC, Protocol buffer














- Scalability



- Security

- gRPC vs REST


- Install protocol buffer 

 + Install protocol compiler (used to compile .proto files)
 + Install protobuf runtime for your chosen programming language.


- Install gRPC 



- 4 types of API in gRPC





- Error codes


- Deadlines



- SSL Security


- gRPC Reflection & Evans CLI








NOTED
- Type interface{}
https://www.calhoun.io/how-do-interfaces-work-in-go/

- Package
  + Export members
  + Importing a package
  + Nested package
  + Package compilation
  + Package initialization
     - Package scope
     - Variable initialization
     - Init function
  + Package alias
  + Program execution order

https://medium.com/rungo/everything-you-need-to-know-about-packages-in-go-b8bac62b74cc

- Usage of interface:
https://www.callicoder.com/golang-interfaces/









Comments