Skip to content

Instantly share code, notes, and snippets.

@caesaneer
Last active April 16, 2020 09:25
Show Gist options
  • Save caesaneer/9cc91fca9c611a5f3d5dec1c7df0c165 to your computer and use it in GitHub Desktop.
Save caesaneer/9cc91fca9c611a5f3d5dec1c7df0c165 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() {
// Uncommented for single thread test
// 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