thread | goroutine |
---|---|
OS threads are managed by kernal and has hardware dependencies. | goroutines are managed by go runtime and has no hardware dependencies. |
OS threads generally have fixed stack size of 1-2MB | goroutines typically have 8KB (2KB since Go 1.4) of stack size in newer versions of go |
Stack size is determined during compile time and can not grow | Stack size of go is managed in run-time and can grow up to 1GB which is possible by allocating and freeing heap storage |
There is no easy communication medium between threads. There is huge latency between inter-thread communication. | goroutine use channels to communicate with other goroutines with low latency (read more). |
Threads have identity. There is TID which identifies each thread in a process. | goroutine do not have any identity. go implemented this because go does not have TLS([Thread Local Storage](https://msdn.microsoft.com/en-us/library/win |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
{ | |
"appId": "com.thatisuday.fileio", | |
"productName": "Electron File IO", | |
"copyright": "THATISUDAY TECH PVT. LTD.", | |
"directories": { | |
"app": ".", | |
"output": "out", | |
"buildResources": "build-res" | |
}, | |
"files": [ |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// A `Fruit` object contains `name` and `color` | |
class Fruit { | |
final String name; | |
final String color; | |
Fruit( this.name, this.color ); | |
} | |
// A `Fruits` collection contains the List of `Fruit` object | |
// `iterator` getter returns an instance of `FruitsIterator` instance |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
package main | |
import ( | |
"fmt" | |
"sync" | |
) | |
// return channel for input numbers | |
func getInputChan() <-chan int { | |
// make return channel | |
input := make(chan int, 100) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# parent image | |
FROM golang:1.15.6-alpine3.12 | |
# workspace directory | |
WORKDIR /app | |
# copy `go.mod` and `go.sum` | |
ADD go.mod go.sum ./ | |
# install dependencies |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Pattern | Description | Example Pattern | Matches | |
---|---|---|---|---|
xyz | Match exactly xyz and nothing more | photo.db | photo.db | |
* | Match any 0 or more characters | *s.db | photos.db users.db ... (files with s.db suffix) | |
? | Matches any single character | ?ing.db | king.db ping.db ring.db | |
[...] | Matches one character listed inside the brackets | [pr]ing.txt | ping.txt ring.txt | |
[start-end] | Matches any character from the start till the end of a set. Supported patterns are a-z; A-Z and 0-9 | [m-z]ing.* | ping.db ping.txt ring.db ring.txt | |
[!...] | Matches one character not included in the brackets | [!pr]ing.txt | king.txt | |
[!start-end] | Matches any character not included from the till the end of a set | [!m-z]ing.* | king.db king.txt |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import React from 'react'; | |
import ReactDOM from 'react-dom'; | |
import { BrowserRouter, Switch, NavLink as Link, Route } from 'react-router-dom'; | |
import './styles.scss'; | |
// home route component | |
const HomeComponent = ( props ) => { | |
return ( | |
<h1>Home Component!</h1> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Show hidden characters
{ | |
"compilerOptions": { | |
/* Visit https://aka.ms/tsconfig.json to read more about this file */ | |
/* Basic Options */ | |
// "incremental": true, /* Enable incremental compilation */ | |
"target": "es5", /* Specify ECMAScript target version: 'ES3' (default), 'ES5', 'ES2015', 'ES2016', 'ES2017', 'ES2018', 'ES2019', 'ES2020', or 'ESNEXT'. */ | |
"module": "commonjs", /* Specify module code generation: 'none', 'commonjs', 'amd', 'system', 'umd', 'es2015', 'es2020', or 'ESNext'. */ | |
// "lib": [], /* Specify library files to be included in the compilation. */ | |
// "allowJs": true, /* Allow javascript files to be compiled. */ |
NewerOlder