Skip to content

Instantly share code, notes, and snippets.

@caesaneer
Created August 14, 2019 22:14
Show Gist options
  • Save caesaneer/2810c9fbcfdc2c5bd6804c966f2d80db to your computer and use it in GitHub Desktop.
Save caesaneer/2810c9fbcfdc2c5bd6804c966f2d80db to your computer and use it in GitHub Desktop.
Go Goroutines vs Node.js Cluster & Worker Threads - Part 1 - Go Code
package main
import (
"fmt"
"net/http"
"runtime"
)
func ok(w http.ResponseWriter, req *http.Request) {
fmt.Fprintf(w, "OK")
}
func main() {
c := runtime.GOMAXPROCS(1)
fmt.Println("PREVIOUS CPUs:", c)
a := "192.168.0.14:4000"
http.HandleFunc("/", ok)
fmt.Println("Go Standard Library HTTP server running at:", a)
http.ListenAndServe(a, nil)
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment