Rajeshs-MacBook-Pro:03_ParseForm_Form rajeshjain$ go version go version go1.8.3 darwin/amd64
WHEN I RUN MY PROGRAM I AM GETTING BELOW ERROR
Rajeshs-MacBook-Pro:03_ParseForm_Form rajeshjain$ go run main.go # runtime /usr/local/go/src/runtime/cgo.go:9:3: //go:cgo_export_static main only allowed in cgo-generated code
I am sorry i am a new bee in GOLANG.
The program which i am running is
PROGRAM***
package main
import (
"html/template"
"log"
"net/http"
"fmt"
)
type hotdog int
func (m hotdog) ServeHTTP(w http.ResponseWriter, req *http.Request) {
fmt.Println("I am in ServeHTTP")
/*
ParseForm is the method which needs to be call before we can use
req.Form - This for getting the data in the body
req.PostForm - this is for getting the data from body and header
*/
err := req.ParseForm()
if err != nil {
log.Fatalln(err)
}
fmt.Println(req.Form)
tpl.ExecuteTemplate(w, "index.html", req.Form)
}
var tpl *template.Template
func init() {
tpl = template.Must(template.ParseFiles("index.html"))
}
func main() {
var d hotdog
http.ListenAndServe(":7777", d)
}
Thanks for your response.
On my mac,when i started learning.I installed Go using brew and that has set it at
export GOROOT=/usr/local/opt/go/libexec
and that was working fine…now i installed the new version of GO from there official website and i can see this being installed at “/usr/local/go”
now i try to set the GOROOT as /usr/local/go.
Below are the parameters which i have set in to .bash_profile
Also PATH is checked left to right and you put the “new” one to the outer right, so the old one is probably seen first. You need to put the new one to the left, or make sure remove the old one.
Also, As a rule of thumb, you want user installations to be always be found before system installation, therefore in most cases you want to have PATH=/new/entry/bin:${PATH}.