VS
Memory 7.7 GiB
Processor Intel® Core™ i5-6500 CPU @ 3.20GHz × 4
OS type 64-bit
Disk 483.8 GB
v8.11.3
go1.9
package main
import (
"fmt"
"log"
"net/http"
)
func handler(w http.ResponseWriter, r *http.Request) {
fmt.Fprintf(w, "GOLANG!")
}
func main() {
http.Handle("/", handler)
log.Fatal(http.ListenAndServe(":8080", nil))
}
const http = require('http');
function requestHandler = (request, response) => {
response.end('NODEJS!')
}
const server = http.createServer(requestHandler);
server.listen(8081, (err) => {
if(err) {
console.log('something bad happened', err)
}
})
After all, we're developers.
npm install express -S
go get -u gorilla/mux
const express = require('express');
const app = express();
app.get('/hello', (request, response) => {
response.send('NODEJS!')
});
app.listen(8081);
package main
import (
"fmt"
"log"
"net/http"
"gorilla/mux"
)
func HelloHandler(w http.ResponseWriter, r *http.Request) {
fmt.Fprintf(w, "GOLANG!")
}
func main() {
r := mux.NewRouter()
r.HandleFunc("/hello", HelloHandler)
log.Fatal(http.ListenAndServe(":8080", r));
}
const http = require('http');
const crypto = require('crypto');
const requestHandler = (request, response) => {
for(let i =0 ; i <= 100; i++) {
crypto.createHash('sha256')
.update("123456789")
.digest("hex");
}
response.end("");
}
const server = http.createServer(requestHandler)
server.listen(8081, (err) => {
if (err) {
return console.log('something bad happened', err);
}
});
n=100
package main
import (
"crypto/sha256"
"fmt"
"log"
"net/http"
"github.com/gorilla/mux"
)
func helloHandler(w http.ResponseWriter, r *http.Request) {
for i := 0; i <= 1000; i++ {
h := sha256.New()
h.Write([]byte("123456789"))
fmt.Sprintf("%x", h.Sum(nil))
}
fmt.Fprintf(w, "")
}
func main() {
r := mux.NewRouter()
r.HandleFunc("/hello", helloHandler)
log.Fatal(http.ListenAndServe(":8080", r))
}
n=1000
{
"apps": [{
"name": "node",
"script": "./app.js",
"exec_mode": "cluster",
"instances": 4
}]
}
const crypto = require('crypto')
const NUM_REQ = 2;
for (let i = 0 ;i < NUM_REQ; i++) {
crypto.pbkdf2('secret', 'salt', 10000, 512, 'sha512')
}
https://www.youtube.com/watch?v=zphcsoSJMvM
The Node.js Event Loop: Not So Single Threaded
const crypto = require('crypto')
const NUM_REQ = 2;
for (let i = 0 ;i < NUM_REQ; i++) {
crypto.pbkdf2('secret', 'salt', 10000, 512, 'sha512', () => {})
}
https://www.youtube.com/watch?v=zphcsoSJMvM
The Node.js Event Loop: Not So Single Threaded
https://www.youtube.com/watch?v=zphcsoSJMvM
The Node.js Event Loop: Not So Single Threaded
https://www.youtube.com/watch?v=zphcsoSJMvM
The Node.js Event Loop: Not So Single Threaded
https://www.youtube.com/watch?v=Yx6FBsGNOp4&t=215s
dotGO 2017 - JBD - Go's work stealing scheduler
const app = require('express')();
app.post('/login', (req, res) => {
authService.login(req.body).then(
authToken => res.json({ Authorization: authToken })
);
})
app.listen(3000);
If you really want it that way.
Lightweight, concurrent function execution. You can spawn tons of these if needed and the Go runtime multiplexes them onto the configured number of CPUs/Threads as needed.
Lorem ipsum dolor sit amet, consectetur adipiscing elit. Proin urna odio, aliquam vulputate faucibus id, elementum lobortis felis. Mauris urna dolor, placerat ac sagittis quis.
f() go f()
No whining for typescript anymore!
sql, driver, strconv, fmt, log, net, net/http, json
you don't have to dig down the right package to get your job done.
Unlike the third promise in
Promise.all([p1, p2, p3])
Let it be Windows, Linux, or MacOS
Go has its own test suite.
func intSeq() func() int {
i := 0
return func() int {
i++
return i
}
}
Just push your binary over to the server and bash it!
Your server doesn't need Golang to run Golang on it. Forget about version issues.
Package Management through dep
YouTube
Apple
Dropbox
Docker
Soundcloud
Mozilla Firefox
Medium
The New York Times
Github
UBER