Created
May 27, 2014 22:47
-
-
Save feyeleanor/a1185dd622d1f9fbc6ca to your computer and use it in GitHub Desktop.
unexpected goroutine behaviour
This file contains hidden or 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" | |
) | |
const ADDRESS = ":1024" | |
const SECURE_ADDRESS = ":1025" | |
func main() { | |
message := "hello world" | |
HandleFunc("/hello", func(w ResponseWriter, r *Request) { | |
w.Header().Set("Content-Type", "text/plain") | |
Fprintf(w, message) | |
}) | |
go func() { | |
ListenAndServe(ADDRESS, nil) | |
}() | |
ListenAndServeTLS(SECURE_ADDRESS, "cert.pem", "key.pem", nil) | |
} |
This file contains hidden or 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" | |
) | |
const ADDRESS = ":1024" | |
const SECURE_ADDRESS = ":1025" | |
func main() { | |
message := "hello world" | |
HandleFunc("/hello", func(w ResponseWriter, r *Request) { | |
w.Header().Set("Content-Type", "text/plain") | |
Fprintf(w, message) | |
}) | |
go func() { | |
ListenAndServe(ADDRESS, nil) | |
}() | |
go func() { | |
ListenAndServeTLS(SECURE_ADDRESS, "cert.pem", "key.pem", nil) | |
}() | |
for {} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
does
runtime.GOMAXPROCS(2)
make the 2nd example work for you?