Move http.ListenAndServe to the top of the main() function, outside the 
http.HandleFunc call and it will work.

On Sunday, 18 September 2016 05:50:03 UTC+10, loc...@gmail.com wrote:
>
> Hello everyone,
>
> I am using Go version 1.7.1 on a 32-bit version of Windows 10 and cannot 
> view the contents of the address localhost:1234. 
> I created a server at the aforementioned address or at least, I think I 
> did and get nothing but an error message when I try to open my browser.
>
> Here's my code:
>
> package main
> import (
> "io"
> "net/http"
> "log"
> )
> func main(){
> http.HandleFunc("/", func(w http.ResponseWriter, r *http.Request){
> io.WriteString(w, "Golang web development")
> log.Fatal(http.ListenAndServe("localhost:1234", nil))
> })
> }
>
>

-- 
You received this message because you are subscribed to the Google Groups 
"golang-nuts" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to golang-nuts+unsubscr...@googlegroups.com.
For more options, visit https://groups.google.com/d/optout.

Reply via email to