FAQ
Hi there,

I am trying to build a small http server sample,

*package main*
*
*
*import (*
* "fmt"*
* "net/http"*
*)*
*
*
*func handler(w http.ResponseWriter, r *http.Request) {*
* fmt.Fprintf(w, "Hi there, I love %s!", r.URL.Path[1:])*
*}*
*
*
*func main() {*
* http.HandleFunc("/", handler)*
* http.ListenAndServe(":8080", nil)*
*}*

and encounter a strconv error as below:

*# strconv
/home/a2n/opt/go/src/pkg/strconv/extfloat.go:244: syntax error: unexpected
name, expecting {
/home/a2n/opt/go/src/pkg/strconv/extfloat.go:244: non-declaration
statement outside function body
/home/a2n/opt/go/src/pkg/strconv/extfloat.go:246: non-declaration
statement outside function body
/home/a2n/opt/go/src/pkg/strconv/extfloat.go:249: non-declaration
statement outside function body
/home/a2n/opt/go/src/pkg/strconv/extfloat.go:250: non-declaration
statement outside function body
/home/a2n/opt/go/src/pkg/strconv/extfloat.go:253: non-declaration
statement outside function body
/home/a2n/opt/go/src/pkg/strconv/extfloat.go:254: non-declaration
statement outside function body
/home/a2n/opt/go/src/pkg/strconv/extfloat.go:256: non-declaration
statement outside function body
/home/a2n/opt/go/src/pkg/strconv/extfloat.go:258: non-declaration
statement outside function body
/home/a2n/opt/go/src/pkg/strconv/extfloat.go:259: non-declaration
statement outside function body
/home/a2n/opt/go/src/pkg/strconv/extfloat.go:259: too many errors*


I have no idea about this, don't know how to fix, help please.

--

Search Discussions

  • RM14 at Oct 22, 2012 at 5:06 am
    Maybe you should pull the latest go package and install it again, then take
    a try. Good luck!
    On Mon, Oct 22, 2012 at 1:32 PM, Alan Lu wrote:

    Hi there,

    I am trying to build a small http server sample,

    *package main*
    *
    *
    *import (*
    * "fmt"*
    * "net/http"*
    *)*
    *
    *
    *func handler(w http.ResponseWriter, r *http.Request) {*
    * fmt.Fprintf(w, "Hi there, I love %s!", r.URL.Path[1:])*
    *}*
    *
    *
    *func main() {*
    * http.HandleFunc("/", handler)*
    * http.ListenAndServe(":8080", nil)*
    *}*

    and encounter a strconv error as below:

    *# strconv
    /home/a2n/opt/go/src/pkg/strconv/extfloat.go:244: syntax error:
    unexpected name, expecting {
    /home/a2n/opt/go/src/pkg/strconv/extfloat.go:244: non-declaration
    statement outside function body
    /home/a2n/opt/go/src/pkg/strconv/extfloat.go:246: non-declaration
    statement outside function body
    /home/a2n/opt/go/src/pkg/strconv/extfloat.go:249: non-declaration
    statement outside function body
    /home/a2n/opt/go/src/pkg/strconv/extfloat.go:250: non-declaration
    statement outside function body
    /home/a2n/opt/go/src/pkg/strconv/extfloat.go:253: non-declaration
    statement outside function body
    /home/a2n/opt/go/src/pkg/strconv/extfloat.go:254: non-declaration
    statement outside function body
    /home/a2n/opt/go/src/pkg/strconv/extfloat.go:256: non-declaration
    statement outside function body
    /home/a2n/opt/go/src/pkg/strconv/extfloat.go:258: non-declaration
    statement outside function body
    /home/a2n/opt/go/src/pkg/strconv/extfloat.go:259: non-declaration
    statement outside function body
    /home/a2n/opt/go/src/pkg/strconv/extfloat.go:259: too many errors*


    I have no idea about this, don't know how to fix, help please.

    --

    --
  • Dave Cheney at Oct 22, 2012 at 5:08 am
    it looks like your source on disk is corrupt.

    If you checked out the source with hg, then hg st $GOROOT will show
    you files that have been modified, if you are not expecting them to be
    modified, hg revert $FILE should fix them.

    If you downloaded a source tarball, then I would suggest blowing away
    the directory, downloading a fresh tarball, and rebuild from source.

    Dave
    On Mon, Oct 22, 2012 at 4:06 PM, RM14 wrote:
    Maybe you should pull the latest go package and install it again, then take
    a try. Good luck!

    On Mon, Oct 22, 2012 at 1:32 PM, Alan Lu wrote:

    Hi there,

    I am trying to build a small http server sample,

    package main

    import (
    "fmt"
    "net/http"
    )

    func handler(w http.ResponseWriter, r *http.Request) {
    fmt.Fprintf(w, "Hi there, I love %s!", r.URL.Path[1:])
    }

    func main() {
    http.HandleFunc("/", handler)
    http.ListenAndServe(":8080", nil)
    }

    and encounter a strconv error as below:
    # strconv
    /home/a2n/opt/go/src/pkg/strconv/extfloat.go:244: syntax error:
    unexpected name, expecting {
    /home/a2n/opt/go/src/pkg/strconv/extfloat.go:244: non-declaration
    statement outside function body
    /home/a2n/opt/go/src/pkg/strconv/extfloat.go:246: non-declaration
    statement outside function body
    /home/a2n/opt/go/src/pkg/strconv/extfloat.go:249: non-declaration
    statement outside function body
    /home/a2n/opt/go/src/pkg/strconv/extfloat.go:250: non-declaration
    statement outside function body
    /home/a2n/opt/go/src/pkg/strconv/extfloat.go:253: non-declaration
    statement outside function body
    /home/a2n/opt/go/src/pkg/strconv/extfloat.go:254: non-declaration
    statement outside function body
    /home/a2n/opt/go/src/pkg/strconv/extfloat.go:256: non-declaration
    statement outside function body
    /home/a2n/opt/go/src/pkg/strconv/extfloat.go:258: non-declaration
    statement outside function body
    /home/a2n/opt/go/src/pkg/strconv/extfloat.go:259: non-declaration
    statement outside function body
    /home/a2n/opt/go/src/pkg/strconv/extfloat.go:259: too many errors


    I have no idea about this, don't know how to fix, help please.

    --

    --
    --
  • Alan Lu at Nov 9, 2012 at 5:33 am
    Thanks for your help.

    It was be solved that install from source.

    On Monday, October 22, 2012 1:08:36 PM UTC+8, Dave Cheney wrote:

    it looks like your source on disk is corrupt.

    If you checked out the source with hg, then hg st $GOROOT will show
    you files that have been modified, if you are not expecting them to be
    modified, hg revert $FILE should fix them.

    If you downloaded a source tarball, then I would suggest blowing away
    the directory, downloading a fresh tarball, and rebuild from source.

    Dave

    On Mon, Oct 22, 2012 at 4:06 PM, RM14 <guti...@gmail.com <javascript:>>
    wrote:
    Maybe you should pull the latest go package and install it again, then take
    a try. Good luck!

    On Mon, Oct 22, 2012 at 1:32 PM, Alan Lu wrote:

    Hi there,

    I am trying to build a small http server sample,

    package main

    import (
    "fmt"
    "net/http"
    )

    func handler(w http.ResponseWriter, r *http.Request) {
    fmt.Fprintf(w, "Hi there, I love %s!", r.URL.Path[1:])
    }

    func main() {
    http.HandleFunc("/", handler)
    http.ListenAndServe(":8080", nil)
    }

    and encounter a strconv error as below:
    # strconv
    /home/a2n/opt/go/src/pkg/strconv/extfloat.go:244: syntax error:
    unexpected name, expecting {
    /home/a2n/opt/go/src/pkg/strconv/extfloat.go:244: non-declaration
    statement outside function body
    /home/a2n/opt/go/src/pkg/strconv/extfloat.go:246: non-declaration
    statement outside function body
    /home/a2n/opt/go/src/pkg/strconv/extfloat.go:249: non-declaration
    statement outside function body
    /home/a2n/opt/go/src/pkg/strconv/extfloat.go:250: non-declaration
    statement outside function body
    /home/a2n/opt/go/src/pkg/strconv/extfloat.go:253: non-declaration
    statement outside function body
    /home/a2n/opt/go/src/pkg/strconv/extfloat.go:254: non-declaration
    statement outside function body
    /home/a2n/opt/go/src/pkg/strconv/extfloat.go:256: non-declaration
    statement outside function body
    /home/a2n/opt/go/src/pkg/strconv/extfloat.go:258: non-declaration
    statement outside function body
    /home/a2n/opt/go/src/pkg/strconv/extfloat.go:259: non-declaration
    statement outside function body
    /home/a2n/opt/go/src/pkg/strconv/extfloat.go:259: too many errors


    I have no idea about this, don't know how to fix, help please.

    --

    --
    --

Related Discussions

Discussion Navigation
viewthread | post
Discussion Overview
groupgolang-nuts @
categoriesgo
postedOct 22, '12 at 3:48a
activeNov 9, '12 at 5:33a
posts4
users3
websitegolang.org

3 users in discussion

Alan Lu: 2 posts Dave Cheney: 1 post RM14: 1 post

People

Translate

site design / logo © 2022 Grokbase