Directories ¶
Path | Synopsis |
---|---|
goplayground
|
|
application/JSONMarshal
Marshaling is the process of transforming the memory representation of an object to a data format suitable for storage or transmission, and it is typically used when data must be moved between different parts of a computer program or from one program to another.
|
Marshaling is the process of transforming the memory representation of an object to a data format suitable for storage or transmission, and it is typically used when data must be moved between different parts of a computer program or from one program to another. |
application/bcrypt
bcrypt is a password hashing function designed by Niels Provos and David Mazières, based on the Blowfish cipher.
|
bcrypt is a password hashing function designed by Niels Provos and David Mazières, based on the Blowfish cipher. |
application/sort/customSort
To illustrate how to sort on fields in a struct using Sort func by implementing the sort package interface "Interface"
|
To illustrate how to sort on fields in a struct using Sort func by implementing the sort package interface "Interface" |
application/sort/simpleSort
The sort package allows us to sort slices
|
The sort package allows us to sort slices |
array
Main thing to note about arrays in Go is size is part of the type as illustrated below
|
Main thing to note about arrays in Go is size is part of the type as illustrated below |
concurrency/atomic
Remember the Go Lang's Motto on Concurrency: "Share memory by communicating; Don't communicate by sharing memory."
|
Remember the Go Lang's Motto on Concurrency: "Share memory by communicating; Don't communicate by sharing memory." |
concurrency/mutex
A “mutex” is a mutual exclusion lock.
|
A “mutex” is a mutual exclusion lock. |
concurrency/raceCondition
Race condition occurs when two parallely executing entities try to access the same shared memory for read/write operation.
|
Race condition occurs when two parallely executing entities try to access the same shared memory for read/write operation. |
exercises/ninjaL5Ex4
Write a program to demonstrate anonymous struct
|
Write a program to demonstrate anonymous struct |
exercises/ninjaL6Ex1
create a func with the identifier foo that returns an int create a func with the identifier bar that returns an int and a string call both funcs print out their results
|
create a func with the identifier foo that returns an int create a func with the identifier bar that returns an int and a string call both funcs print out their results |
exercises/ninjaL6Ex5
create a type SQUARE create a type CIRCLE attach a method to each that calculates AREA and returns it create a type SHAPE that defines an interface as anything that has the AREA method create a func INFO which takes type shape and then prints the area create a value of type square create a value of type circle use func info to print the area of square use func info to print the area of circle
|
create a type SQUARE create a type CIRCLE attach a method to each that calculates AREA and returns it create a type SHAPE that defines an interface as anything that has the AREA method create a func INFO which takes type shape and then prints the area create a value of type square create a value of type circle use func info to print the area of square use func info to print the area of circle |
exercises/ninjaL6Ex8
Create a func which returns a func Assign the returned func to a variable Call the returned func
|
Create a func which returns a func Assign the returned func to a variable Call the returned func |
exercises/ninjaL7Ex2
create a person struct create a func called “changeMe” with a *person as a parameter change the value stored at the *person address create a value of type person & print out the value Call changeMe function
|
create a person struct create a func called “changeMe” with a *person as a parameter change the value stored at the *person address create a value of type person & print out the value Call changeMe function |
exercises/ninjaL9Ex1
In addition to the main goroutine, launch two additional goroutines
|
In addition to the main goroutine, launch two additional goroutines |
functions/anonymous
Anonymous self executing functions
|
Anonymous self executing functions |
functions/callback
Call function is a function that's passed into another function as an argument.
|
Call function is a function that's passed into another function as an argument. |
functions/closures
Go functions may be closures.
|
Go functions may be closures. |
functions/defer
A "defer" statement invokes a function whose execution is deferred to the moment the surrounding function returns, either because the surrounding function executed a return statement, reached the end of its function body, or because the corresponding goroutine is panicking.
|
A "defer" statement invokes a function whose execution is deferred to the moment the surrounding function returns, either because the surrounding function executed a return statement, reached the end of its function body, or because the corresponding goroutine is panicking. |
functions/funcExpressions
Functions are first class types in Go.
|
Functions are first class types in Go. |
functions/interfaceAndPolymorphism
In other words, what an interface tells a type is, "If you have methods that match my functions, then you are my type"
|
In other words, what an interface tells a type is, "If you have methods that match my functions, then you are my type" |
functions/recursion
Recursion happens when a function calls itself.
|
Recursion happens when a function calls itself. |
functions/returnFunc
Functions are first class types in Go and hence can be returned from a function just like any other type
|
Functions are first class types in Go and hence can be returned from a function just like any other type |
functions/unfurlingSlice
When we have a slice of some type, we can pass in the individual values in a slice by using the “...” operator.
|
When we have a slice of some type, we can pass in the individual values in a slice by using the “...” operator. |
functions/variadicFunction
We can create a function which takes an unlimited number of arguments Parameter that can accept unlimited number of arguments is known as a “variadic parameter.” We use the lexical element operator ...T to specify variadic parameter of type T
|
We can create a function which takes an unlimited number of arguments Parameter that can accept unlimited number of arguments is known as a “variadic parameter.” We use the lexical element operator ...T to specify variadic parameter of type T |
iota
Within a constant declaration, the predeclared identifier iota represents successive untyped integer constants.
|
Within a constant declaration, the predeclared identifier iota represents successive untyped integer constants. |
maps
Like slices, maps hold references to an underlying data structure.
|
Like slices, maps hold references to an underlying data structure. |
methodSet
IMPORTANT: “The method set of a type determines the INTERFACES
|
IMPORTANT: “The method set of a type determines the INTERFACES |
methods
Go function signature func (r receiver) identifier(parameters) (return(s)) { code }
|
Go function signature func (r receiver) identifier(parameters) (return(s)) { code } |
pointers
A pointer is a variable that holds the address of a memory location
|
A pointer is a variable that holds the address of a memory location |
slices/slice
A SLICE holds VALUES of the same TYPE.
|
A SLICE holds VALUES of the same TYPE. |
strings2
* As we saw, indexing a string yields its bytes, not its characters: * a string is just a bunch of bytes.
|
* As we saw, indexing a string yields its bytes, not its characters: * a string is just a bunch of bytes. |
struct
Structs allow us to compose together values of different types.
|
Structs allow us to compose together values of different types. |
switch
* In Go, we don't need to add break in every switch case as we do in C/C++ * That's the default behavior.
|
* In Go, we don't need to add break in every switch case as we do in C/C++ * That's the default behavior. |
Click to show internal directories.
Click to hide internal directories.