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
package main | |
import ( | |
"html/template" | |
"io" | |
"github.com/labstack/echo" | |
"gitlab.com/ykyuen/golang-echo-template-example/handler" | |
) |
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 grpc | |
import ( | |
"context" | |
"log" | |
"net" | |
"os" | |
"os/signal" | |
"google.golang.org/grpc" |
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
.was-validated .form-control:valid~.invalid-feedback { | |
display: none; | |
} |
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 m from "mithril"; | |
module.exports = (options, ...elements) => { | |
return ( | |
<form {...options.attrs} class="form needs-validation"> | |
{ | |
elements.map(e => { |
Various command line applications use an Interpreter Directive to define how they should be run.
#! js -m foo
#! node foo
apt-get install python-pip
pip install shadowsocks
sudo ssserver -p 443 -k password -m aes-256-cfb --user nobody -d start
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
FROM golang:1.9 | |
WORKDIR /go/src/github.com/purplebooth/example | |
COPY . . | |
RUN go build -ldflags "-linkmode external -extldflags -static" -a main.go | |
FROM scratch | |
COPY --from=0 /go/src/github.com/purplebooth/example/main /main | |
CMD ["/main"] |
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
# To host on root path just use "<Location />" for http://mydomainname.in | |
# To host on non-root path use "<Location /myreactapp>" for http://mydomainname.in/mypath | |
# If non-root path, don't forgot to add "homepage": "/myreactapp" in your app's package.json | |
<VirtualHost *:80> | |
ServerName mydomainname.in | |
DirectoryIndex index.html | |
DocumentRoot /var/www/html | |
ErrorLog ${APACHE_LOG_DIR}/error.log | |
CustomLog ${APACHE_LOG_DIR}/access.log combined |
NewerOlder