Last active
April 16, 2020 09:25
-
-
Save caesaneer/9cc91fca9c611a5f3d5dec1c7df0c165 to your computer and use it in GitHub Desktop.
Go Goroutines vs Node.js Cluster & Worker Threads - Part 1 - Go Code
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" | |
"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