Skip to content

nitinkumar-na/learn-go

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

73 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Go

CLI Commands

go run <file_name1>, <file_name1>

go run .

go build 

Section 1: Variables

Variables in Go
  • Normal variable
    var a int = 10
  • Shorthand
    a := 10

Section 2: Loops

For Loop Variants
  • Normal For Loop
    for i := 0; i < 10; i++ {
        // do something
    }
  • While Loop Style - For Loop
    i := 0
    for  i < 10 {
        // do something
        i++
    }
  • Infinite Loop
    for  {
        // do something
    }
    // OR 
    for true  {
        // do something
    }

Section 3: Multiple Return

Return Multiple values from a Method
  • Code example
    func go() (int error) {
        return 0, nil
    }
    
    func main() {
        i, err := foo()
        if err !=nil {
            panic(err)
        } 
    	println(i)
    }

Section 4: Defer keyword

Section 5: new vs make

Make is only used with a slice, map and channel(chan)
Make initializes the underlying datastuctures for above mentioned DS
```
    func main() {
        type TypeStruct struct {
            Name string
        }

        t := new(TestStruct) // type *TestStruct - Create an Object with Zero values of the variables
        var v TestStruct // type TestStruct
    }
```

Section 6: Interfaces ?

Section 7: Pointers ?

Section 8: Modules ?

Section 9: Generics ?

Type function: https://www.youtube.com/watch?v=pR5nQ6N6-YA

Section 9: Context Package // Part of Concurrency ?

https://www.youtube.com/watch?v=uiUCIz-3CWM https://www.youtube.com/watch?v=kaZOXRqFPCw https://www.youtube.com/watch?v=LSzR0VEraWw https://go.dev/tour/list

Section 8: concurrency/waitGroups(making the main thread wait)/mutex(remove race condition)/channels(passing data to routines) ?

Misc:

Returning a function or array of functions from a function New vs Make

Functional style programming is possible ?

About

No description, website, or topics provided.

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published